xtd 0.2.0
property.h
Go to the documentation of this file.
1 #pragma once
5 #include "../../object.h"
6 #include "../../ustring.h"
7 #include <ostream>
8 
10 namespace 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  static property from(bool value) {return property(ustring::format("{}", value));}
40  static property from(double value) {return property(ustring::format("{}", value));}
41  static property from(float value) {return property(ustring::format("{}", value));}
42  static property from(sbyte value) {return property(ustring::format("{}", value));}
43  static property from(int16 value) {return property(ustring::format("{}", value));}
44  static property from(int32 value) {return property(ustring::format("{}", value));}
45  static property from(int64 value) {return property(ustring::format("{}", value));}
46  static property from(const xtd::ustring& value) {return property(ustring::format("{}", value));}
47  static property from(xtd::byte value) {return property(ustring::format("{}", value));}
48  static property from(uint16 value) {return property(ustring::format("{}", value));}
49  static property from(uint32 value) {return property(ustring::format("{}", value));}
50  static property from(uint64 value) {return property(ustring::format("{}", value));}
51  template<typename value_t>
52  static property from(value_t value) {return property(ustring::format("{}", value));}
53 
54  bool to_boolean() const {return xtd::parse<bool>(value_);}
55  double to_double() const {return xtd::parse<double>(value_);}
56  sbyte to_int8() const {return xtd::parse<sbyte>(value_);}
57  int16 to_int16() const {return xtd::parse<int16>(value_);}
58  int32 to_int32() const {return xtd::parse<int32>(value_);}
59  int64 to_int64() const {return xtd::parse<int64>(value_);}
60  intptr to_intptr() const {return xtd::parse<intptr>(value_);}
61  float to_single() const {return xtd::parse<float>(value_);}
62  xtd::ustring to_string() const noexcept override {return value_;}
63  xtd::byte to_uint8() const {return xtd::parse<xtd::byte>(value_);}
64  uint16 to_uint16() const {return xtd::parse<uint16>(value_);}
65  uint32 to_uint32() const {return xtd::parse<uint32>(value_);}
66  uint64 to_uint64() const {return xtd::parse<uint64>(value_);}
67  uintptr to_uintptr() const {return xtd::parse<uintptr>(value_);}
68  template<typename value_t>
69  uintptr to() const {return xtd::parse<value_t>(value_);}
71 
72  private:
73  xtd::ustring value_;
74  };
75  }
76  }
77 }
intmax_t intptr
Represent a pointer or a handle.
Definition: types.h:151
int_least8_t sbyte
Represents a 8-bit signed integer.
Definition: types.h:173
xtd::ustring to_string() const noexcept override
Returns a sxd::ustring that represents the current object.
Definition: property.h:62
Definition: property.h:13
The xtd namespace contains all fundamental classes to access Hardware, Os, System, and more.
Definition: system_report.h:17
uint_least16_t uint16
Represents a 16-bit unsigned integer.
Definition: types.h:228
Represents text as a sequence of UTF-8 code units.
Definition: ustring.h:46
double parse< double >(const std::string &str, number_styles styles)
Convert a string into a type.
Definition: parse.h:198
uintmax_t uintptr
Represent a pointer or a handle.
Definition: types.h:261
bool parse< bool >(const std::string &str)
Convert a string into a type.
Definition: parse.h:360
float parse< float >(const std::string &str, number_styles styles)
Convert a string into a type.
Definition: parse.h:180
int_least16_t int16
Represents a 16-bit signed integer.
Definition: types.h:118
Supports all classes in the xtd class hierarchy and provides low-level services to derived classes...
Definition: object.h:32
int_least32_t int32
Represents a 32-bit signed integer.
Definition: types.h:129
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:744
uint_least64_t uint64
Represents a 64-bit unsigned integer.
Definition: types.h:250
int_least64_t int64
Represents a 64-bit signed integer.
Definition: types.h:140
uint_least8_t byte
Represents a 8-bit unsigned integer.
Definition: types.h:39
uint_least32_t uint32
Represents a 32-bit unsigned integer.
Definition: types.h:239