xtd - Reference Guide  0.1.2
Modern c++17/20 framework to create console, GUI and unit test applications on Windows, macOS, Linux, iOS and android.
Loading...
Searching...
No Matches
property.h
Go to the documentation of this file.
1
4#pragma once
5#include <ostream>
6#include "../../object.h"
7#include "../../ustring.h"
8
10namespace xtd {
11 namespace web {
12 namespace css {
13 class property : public object{
14 public:
15 property() = default;
16 explicit property(const xtd::ustring& value) : value_(value) {}
17 operator xtd::ustring() {return value_;}
18
19 static property from(bool value) {return property(ustring::format("{}", value));}
20 static property from(double value) {return property(ustring::format("{}", value));}
21 static property from(float value) {return property(ustring::format("{}", value));}
22 static property from(int8_t value) {return property(ustring::format("{}", value));}
23 static property from(int16_t value) {return property(ustring::format("{}", value));}
24 static property from(int32_t value) {return property(ustring::format("{}", value));}
25 static property from(int64_t value) {return property(ustring::format("{}", value));}
26 static property from(const xtd::ustring& value) {return property(ustring::format("{}", value));}
27 static property from(uint8_t value) {return property(ustring::format("{}", value));}
28 static property from(uint16_t value) {return property(ustring::format("{}", value));}
29 static property from(uint32_t value) {return property(ustring::format("{}", value));}
30 static property from(uint64_t value) {return property(ustring::format("{}", value));}
31 template<typename value_t>
32 static property from(value_t value) {return property(ustring::format("{}", value));}
33
34 const xtd::ustring& value() const {return value_;}
35 template<typename value_t>
36 uintptr_t value() const {return xtd::parse<value_t>(value_);}
37
38 bool to_boolean() const {return xtd::parse<bool>(value_);}
39 double to_double() const {return xtd::parse<double>(value_);}
40 int8_t to_int8() const {return xtd::parse<int8_t>(value_);}
41 int16_t to_int16() const {return xtd::parse<int16_t>(value_);}
42 int32_t to_int32() const {return xtd::parse<int32_t>(value_);}
43 int64_t to_int64() const {return xtd::parse<int64_t>(value_);}
44 intptr_t to_intptr() const {return xtd::parse<intptr_t>(value_);}
45 float to_single() const {return xtd::parse<float>(value_);}
46 xtd::ustring to_string() const noexcept override {return value_;}
47 uint8_t to_uint8() const {return xtd::parse<uint8_t>(value_);}
48 uint16_t to_uint16() const {return xtd::parse<uint16_t>(value_);}
49 uint32_t to_uint32() const {return xtd::parse<uint32_t>(value_);}
50 uint64_t to_uint64() const {return xtd::parse<uint64_t>(value_);}
51 uintptr_t to_uintptr() const {return xtd::parse<uintptr_t>(value_);}
52 template<typename value_t>
53 uintptr_t to() const {return xtd::parse<value_t>(value_);}
54
55 friend std::ostream& operator <<(std::ostream& os, const property& property) noexcept {return os << property.to_string();}
56
57 private:
58 xtd::ustring value_;
59 };
60 }
61 }
62}
Supports all classes in the xtd class hierarchy and provides low-level services to derived classes....
Definition object.h:26
Represents text as a sequence of UTF-8 code units.
Definition ustring.h:48
Definition property.h:13
xtd::ustring to_string() const noexcept override
Returns a std::string that represents the current object.
Definition property.h:46
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:689
double parse< double >(const std::string &str, number_styles styles)
Convert a type into a string.
Definition parse.h:166
int8_t parse< int8_t >(const std::string &str, number_styles styles)
Convert a type into a string.
Definition parse.h:58
bool parse< bool >(const std::string &str)
Convert a type into a string.
Definition parse.h:310
float parse< float >(const std::string &str, number_styles styles)
Convert a type into a string.
Definition parse.h:157
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition system_report.h:17