xtd 0.2.0
Loading...
Searching...
No Matches
property.h
Go to the documentation of this file.
1
4#pragma once
5#include "../../object.h"
6#include "../../ustring.h"
7#include <ostream>
8
10namespace xtd {
11 namespace web {
12 namespace css {
13 class property : public object {
14 public:
16
18 property() = default;
19 explicit property(const xtd::ustring& value) : value_(value) {}
21
23
25 operator xtd::ustring() noexcept {return value_;}
27
29
31 const xtd::ustring& value() const noexcept {return value_;}
32 template<typename value_t>
33 uintptr value() const noexcept {return xtd::parse<value_t>(value_);}
35
37
39 bool to_boolean() const {return xtd::parse<bool>(value_);}
40 double to_double() const {return xtd::parse<double>(value_);}
41 sbyte to_int8() const {return xtd::parse<sbyte>(value_);}
42 int16 to_int16() const {return xtd::parse<int16>(value_);}
43 int32 to_int32() const {return xtd::parse<int32>(value_);}
44 int64 to_int64() const {return xtd::parse<int64>(value_);}
45 intptr to_intptr() const {return xtd::parse<intptr>(value_);}
46 float to_single() const {return xtd::parse<float>(value_);}
47 xtd::ustring to_string() const noexcept override {return value_;}
48 xtd::byte to_uint8() const {return xtd::parse<xtd::byte>(value_);}
49 uint16 to_uint16() const {return xtd::parse<uint16>(value_);}
50 uint32 to_uint32() const {return xtd::parse<uint32>(value_);}
51 uint64 to_uint64() const {return xtd::parse<uint64>(value_);}
52 uintptr to_uintptr() const {return xtd::parse<uintptr>(value_);}
53 template<typename value_t>
54 uintptr to() const {return xtd::parse<value_t>(value_);}
56
58
60 static property from(bool value) {return property(ustring::format("{}", value));}
61 static property from(double value) {return property(ustring::format("{}", value));}
62 static property from(float value) {return property(ustring::format("{}", value));}
63 static property from(sbyte value) {return property(ustring::format("{}", value));}
64 static property from(int16 value) {return property(ustring::format("{}", value));}
65 static property from(int32 value) {return property(ustring::format("{}", value));}
66 static property from(int64 value) {return property(ustring::format("{}", value));}
67 static property from(const xtd::ustring& value) {return property(ustring::format("{}", value));}
68 static property from(xtd::byte value) {return property(ustring::format("{}", value));}
69 static property from(uint16 value) {return property(ustring::format("{}", value));}
70 static property from(uint32 value) {return property(ustring::format("{}", value));}
71 static property from(uint64 value) {return property(ustring::format("{}", value));}
72 template<typename value_t>
73 static property from(value_t value) {return property(ustring::format("{}", value));}
75
76 private:
77 xtd::ustring value_;
78 };
79 }
80 }
81}
Supports all classes in the xtd class hierarchy and provides low-level services to derived classes....
Definition object.h:32
Represents text as a sequence of UTF-8 code units.
Definition ustring.h:47
Definition property.h:13
xtd::ustring to_string() const noexcept override
Returns a sxd::ustring that represents the current object.
Definition property.h:47
static ustring format(const ustring &fmt, args_t &&... args)
Writes the text representation of the specified arguments list, to string using the specified format ...
Definition ustring.h:1131
int_least16_t int16
Represents a 16-bit signed integer.
Definition types.h:120
int_least8_t sbyte
Represents a 8-bit signed integer.
Definition types.h:175
uintmax_t uintptr
Represent a pointer or a handle.
Definition types.h:263
int_least64_t int64
Represents a 64-bit signed integer.
Definition types.h:142
uint_least16_t uint16
Represents a 16-bit unsigned integer.
Definition types.h:230
int_least32_t int32
Represents a 32-bit signed integer.
Definition types.h:131
intmax_t intptr
Represent a pointer or a handle.
Definition types.h:153
uint_least64_t uint64
Represents a 64-bit unsigned integer.
Definition types.h:252
uint_least32_t uint32
Represents a 32-bit unsigned integer.
Definition types.h:241
uint_least8_t byte
Represents a 8-bit unsigned integer.
Definition types.h:41
double parse< double >(const std::string &str, number_styles styles)
Convert a string into a type.
Definition parse.h:209
bool parse< bool >(const std::string &str)
Convert a string into a type.
Definition parse.h:371
float parse< float >(const std::string &str, number_styles styles)
Convert a string into a type.
Definition parse.h:191
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition xtd_about_box.h:10