xtd 0.2.0
Loading...
Searching...
No Matches
enum_object.h
Go to the documentation of this file.
1
4#pragma once
5#include "enum_attribute.h"
6#include "enum_collection.h"
7#include "enum_register.h"
9#include "format_exception.h"
10#include "icomparable.h"
11#include "iequatable.h"
12#include "number_styles.h"
13#include "optional.h"
14#include "static.h"
15#include "string_comparison.h"
17
19namespace xtd {
21
37 template<typename enum_t = std::nullptr_t>
38 class enum_object : public xtd::object, public xtd::icomparable<enum_object<enum_t>>, public xtd::iequatable<enum_object<enum_t>> {
39 public:
41
43 using enum_type = enum_t;
45
47
50 enum_object() noexcept = default;
53 explicit enum_object(enum_type value) : value_(value) {}
55
57 explicit enum_object(xtd::byte value) : value_(to_enum(value)) {}
58 explicit enum_object(sbyte value) : value_(to_enum(value)) {}
59 explicit enum_object(int16 value) : value_(to_enum(value)) {}
60 explicit enum_object(int32 value) : value_(to_enum(value)) {}
61 explicit enum_object(int64 value) : value_(to_enum(value)) {}
62 explicit enum_object(uint16 value) : value_(to_enum(value)) {}
63 explicit enum_object(uint32 value) : value_(to_enum(value)) {}
64 explicit enum_object(uint64 value) : value_(to_enum(value)) {}
65 enum_object(enum_object&&) noexcept = default;
66 enum_object(const enum_object&) noexcept = default;
67 enum_object& operator =(const enum_object&) noexcept = default;
68 operator enum_type() const noexcept {return value_;}
70
72
78 bool has_flag(enum_type flag) const noexcept {return (to_int(value_) & to_int(flag)) == to_int(flag);}
79
82 enum_type value() const noexcept {return value_;}
85 enum_object& value(enum_type value) {
86 value_ = value;
87 return *this;
88 }
90
92
94 int32 compare_to(const enum_object& value) const noexcept override {
95 if (to_int(value_) == to_int(value.value_)) return 0;
96 if (to_int(value_) < to_int(value.value_)) return -1;
97 return 1;
98 }
99
102 xtd::byte to_byte() const noexcept {return static_cast<xtd::byte>(value_);}
103
106 int16 to_int16() const noexcept {return static_cast<int16>(value_);}
107
110 int32 to_int32() const noexcept {return static_cast<int32>(value_);}
111
114 int64 to_int64() const noexcept {return static_cast<int64>(value_);}
115
118 sbyte to_sbyte() const noexcept {return static_cast<sbyte>(value_);}
119
122 uint16 to_uint16() const noexcept {return static_cast<uint16>(value_);}
123
126 uint32 to_uint32() const noexcept {return static_cast<uint32>(value_);}
127
130 uint64 to_uint64() const noexcept {return static_cast<uint64>(value_);}
131
132 xtd::ustring to_string() const noexcept override {
133 init();
134 if (attribute() == xtd::enum_attribute::flags) return to_string_flags();
135
136 auto iterator = std::find_if(entries().begin(), entries().end(), [&](auto value)->bool {return value.first == value_;});
137 if (iterator == entries().end()) return ustring::format("{}", to_int(value_));
138
139 return iterator->second;
140 }
141
158 xtd::ustring to_string(const xtd::ustring& format) const {
159 init();
160 auto fmt = format;
161 if (fmt.empty()) fmt = "G";
162
163 switch (fmt[0]) {
164 case 'b':
165 case 'B':
166 case 'd':
167 case 'D':
168 case 'o':
169 case 'O':
170 case 'x':
171 case 'X': return __numeric_formatter(fmt, static_cast<long long int>(value_), std::locale());
172 case 'f':
173 case 'F':
174 case 'g':
175 case 'G': return __format_stringer<char>(value_);
176 }
177 throw format_exception("Invalid format"_t);
178 }
180
182 bool equals(const enum_object& value) const noexcept override {return value_ == value.value_;}
183 bool equals(enum_type value) const noexcept {return value_ == value;}
184 template<typename attribute_t>
185 bool equals(attribute_t value) const noexcept {return false;}
186
187 static enum_type parse(const xtd::ustring& str) {return parse(str, false);}
188 static enum_type parse(const xtd::ustring& str, bool ignore_case) {
189 enum_object<enum_type>().init();
190 if (enum_object<enum_type>().attribute() == xtd::enum_attribute::flags) return parse_flags(str, ignore_case);
191
192 for (auto item : enum_object<enum_type>().entries()) {
193 if (xtd::ustring::compare(str, item.second, ignore_case) == 0)
194 return static_cast<enum_type>(item.first);
195 }
196
197 return to_enum(xtd::parse<int64>(str));
198 }
199
200 static enum_type parse_flags(const xtd::ustring& value, bool ignore_case) {
201 std::vector<xtd::ustring> values = value.split({','});
202 for (xtd::ustring& str : values)
203 str = str.trim(' ');
204
205 if (values.size() == 1) {
206 for (auto item : enum_object<enum_type>().entries()) {
207 if (xtd::ustring::compare(value, item.second, ignore_case) == 0)
208 return to_enum(item.first);
209 }
210 return to_enum(xtd::parse<int64>(value));
211 }
212
213 int64 result = 0;
214 for (xtd::ustring str : values) {
215 bool found = false;
216 for (auto item : enum_object<enum_type>().entries()) {
217 if (xtd::ustring::compare(str, item.second, ignore_case) == 0) {
218 found = true;
219 result |= to_int(item.first);
220 break;
221 }
222 }
223 if (found == false)
225 }
226
227 return to_enum(result);
228 }
230
231 private:
232 friend class enum_object<std::nullptr_t>;
233
234 xtd::ustring get_name() const noexcept {
235 auto iterator = std::find_if(entries().begin(), entries().end(), [&](auto value)->bool {return value.first == value_;});
236 if (iterator == entries().end()) return xtd::ustring::format("{}", to_int(value_));
237 return iterator->second;
238 }
239
240 xtd::ustring to_string_flags() const noexcept {
241 auto iterator = std::find_if(entries().begin(), entries().end(), [&](auto value)->bool {return value.first == value_;});
242 if (to_int(value_) == 0 && iterator == entries().end()) return "0";
243
244 iterator = std::find_if(entries().begin(), entries().end(), [&](auto value)->bool {return value.first == to_enum(0);});
245 if (to_int(value_) == 0) return iterator == entries().end() ? "0" : iterator->second;
246
247 xtd::ustring str;
248 int64 rest = to_int(value_);
249 enum_collection<enum_type> reversed_entries = entries();
250 std::reverse(reversed_entries.begin(), reversed_entries.end());
251
252 for (auto item : reversed_entries) {
253 if (to_int(item.first) != 0 && (rest & to_int(item.first)) == to_int(item.first)) {
254 rest -= to_int(item.first);
255 if (!xtd::ustring::is_empty(str)) str = ", " + str;
256 str = item.second + str;
257 }
258 }
259
260 if (str.empty() || rest > 0) return xtd::ustring::format("{}", to_int(value_));
261
262 return str;
263 }
264
265 template<typename attribute_t>
266 static enum_type to_enum(attribute_t value) noexcept {return static_cast<enum_type>(value);}
267 static int64 to_int(enum_type value) noexcept {return static_cast<int64>(value);}
268
269 static xtd::enum_attribute attribute() noexcept {
270 if (attribute_.has_value()) return attribute_.value();
271 attribute_ = xtd::enum_attribute(enum_set_attribute<enum_type>());
272 return attribute_.value();
273 }
274
275 static enum_collection<enum_type>& entries() noexcept {
276 if (entries_.has_value()) return entries_.value();
277 entries_ = enum_collection<enum_type>(enum_register<enum_type>());
278 return entries_.value();
279 };
280
281 static void init() noexcept {
282 attribute();
283 entries();
284 }
285
286 inline static std::optional<xtd::enum_attribute> attribute_;
287 inline static std::optional<enum_collection<enum_type>> entries_;
288 enum_type value_ {};
289 };
290
299 template<>
300 class enum_object<std::nullptr_t> static_ {
301 public:
303
307 template<typename enum_t>
308 static const xtd::enum_collection<enum_t>& get_entries() noexcept {
309 return enum_object<enum_t>().entries();
310 }
311
314 template<typename enum_t>
317 std::for_each(enum_object<enum_t>().entries().begin(), enum_object<enum_t>().entries().end(), [&](auto entry) {entries.emplace_back(enum_object<enum_t>(entry.first).to_byte(), entry.second);});
318 return entries;
319 }
320
323 template<typename enum_t>
326 std::for_each(enum_object<enum_t>().entries().begin(), enum_object<enum_t>().entries().end(), [&](auto entry) {entries.emplace_back(enum_object<enum_t>(entry.first).to_int16(), entry.second);});
327 return entries;
328 }
329
332 template<typename enum_t>
335 std::for_each(enum_object<enum_t>().entries().begin(), enum_object<enum_t>().entries().end(), [&](auto entry) {entries.emplace_back(enum_object<enum_t>(entry.first).to_int32(), entry.second);});
336 return entries;
337 }
338
341 template<typename enum_t>
344 std::for_each(enum_object<enum_t>().entries().begin(), enum_object<enum_t>().entries().end(), [&](auto entry) {entries.emplace_back(enum_object<enum_t>(entry.first).to_int64(), entry.second);});
345 return entries;
346 }
347
350 template<typename enum_t>
353 std::for_each(enum_object<enum_t>().entries().begin(), enum_object<enum_t>().entries().end(), [&](auto entry) {entries.emplace_back(enum_object<enum_t>(entry.first).to_sbyte(), entry.second);});
354 return entries;
355 }
356
359 template<typename enum_t>
362 std::for_each(enum_object<enum_t>().entries().begin(), enum_object<enum_t>().entries().end(), [&](auto entry) {entries.emplace_back(enum_object<enum_t>(entry.first).to_uint16(), entry.second);});
363 return entries;
364 }
365
368 template<typename enum_t>
371 std::for_each(enum_object<enum_t>().entries().begin(), enum_object<enum_t>().entries().end(), [&](auto entry) {entries.emplace_back(enum_object<enum_t>(entry.first).to_uint32(), entry.second);});
372 return entries;
373 }
374
377 template<typename enum_t>
380 std::for_each(enum_object<enum_t>().entries().begin(), enum_object<enum_t>().entries().end(), [&](auto entry) {entries.emplace_back(enum_object<enum_t>(entry.first).to_uint64(), entry.second);});
381 return entries;
382 }
383
388 template<typename enum_t>
389 static xtd::ustring get_name(enum_t value) noexcept {return enum_object<enum_t>(value).to_string();}
394 template<typename enum_t>
400 template<typename enum_t>
406 template<typename enum_t>
408
412 template<typename enum_t>
413 static std::vector<xtd::ustring> get_names() noexcept {
414 std::vector<xtd::ustring> names;
415 std::for_each(enum_object<enum_t>().entries().begin(), enum_object<enum_t>().entries().end(), [&](auto entry) {names.push_back(entry.second);});
416 return names;
417 }
418
422 template<typename enum_t>
423 static std::vector<enum_t> get_values() noexcept {
424 std::vector<enum_t> values;
425 std::for_each(enum_object<enum_t>().entries().begin(), enum_object<enum_t>().entries().end(), [&](auto entry) {values.push_back(entry.first);});
426 return values;
427 }
428
432 template<typename enum_t>
433 static std::vector<xtd::byte> get_values_as_byte() noexcept {
434 std::vector<xtd::byte> values;
435 std::for_each(enum_object<enum_t>().entries().begin(), enum_object<enum_t>().entries().end(), [&](auto entry) {values.push_back(enum_object<enum_t>(entry.first).to_byte());});
436 return values;
437 }
438
442 template<typename enum_t>
443 static std::vector<int16> get_values_as_int16() noexcept {
444 std::vector<int16> values;
445 std::for_each(enum_object<enum_t>().entries().begin(), enum_object<enum_t>().entries().end(), [&](auto entry) {values.push_back(enum_object<enum_t>(entry.first).to_int16());});
446 return values;
447 }
448
452 template<typename enum_t>
453 static std::vector<int32> get_values_as_int32() noexcept {
454 std::vector<int32> values;
455 std::for_each(enum_object<enum_t>().entries().begin(), enum_object<enum_t>().entries().end(), [&](auto entry) {values.push_back(enum_object<enum_t>(entry.first).to_int32());});
456 return values;
457 }
458
462 template<typename enum_t>
463 static std::vector<int64> get_values_as_int64() noexcept {
464 std::vector<int64> values;
465 std::for_each(enum_object<enum_t>().entries().begin(), enum_object<enum_t>().entries().end(), [&](auto entry) {values.push_back(enum_object<enum_t>(entry.first).to_int64());});
466 return values;
467 }
468
472 template<typename enum_t>
473 static std::vector<sbyte> get_values_as_sbyte() noexcept {
474 std::vector<sbyte> values;
475 std::for_each(enum_object<enum_t>().entries().begin(), enum_object<enum_t>().entries().end(), [&](auto entry) {values.push_back(enum_object<enum_t>(entry.first).to_sbyte());});
476 return values;
477 }
478
482 template<typename enum_t>
483 static std::vector<uint16> get_values_as_uint16() noexcept {
484 std::vector<uint16> values;
485 std::for_each(enum_object<enum_t>().entries().begin(), enum_object<enum_t>().entries().end(), [&](auto entry) {values.push_back(enum_object<enum_t>(entry.first).to_uint16());});
486 return values;
487 }
488
492 template<typename enum_t>
493 static std::vector<uint32> get_values_as_uint32() noexcept {
494 std::vector<uint32> values;
495 std::for_each(enum_object<enum_t>().entries().begin(), enum_object<enum_t>().entries().end(), [&](auto entry) {values.push_back(enum_object<enum_t>(entry.first).to_uint32());});
496 return values;
497 }
498
502 template<typename enum_t>
503 static std::vector<uint64> get_values_as_uint64() noexcept {
504 std::vector<uint64> values;
505 std::for_each(enum_object<enum_t>().entries().begin(), enum_object<enum_t>().entries().end(), [&](auto entry) {values.push_back(enum_object<enum_t>(entry.first).to_uint64());});
506 return values;
507 }
508
513 template<typename enum_t>
514 static bool is_defined(enum_t value) noexcept {return std::find_if(enum_object<enum_t>().entries().begin(), enum_object<enum_t>().entries().end(), [&](auto item)->bool {return item.first == value;}) != enum_object<enum_t>().entries().end();}
519 template<typename enum_t>
520 static bool is_defined(enum_object<enum_t> value) noexcept {return std::find_if(enum_object<enum_t>().entries().begin(), enum_object<enum_t>().entries().end(), [&](auto item)->bool {return item.first == value;}) != enum_object<enum_t>().entries().end();}
521
526 template<typename enum_t>
527 static enum_t parse(const xtd::ustring& value) {return parse<enum_t>(value, false);}
533 template<typename enum_t>
534 static enum_t parse(const xtd::ustring& str, bool ignore_case) {
535 return enum_object<enum_t>::parse(str, ignore_case);
536 }
537
541 template<typename enum_t>
542 static xtd::byte to_byte(enum_t value) noexcept {return enum_object<enum_t>(value).to_byte();}
543
547 template<typename enum_t>
548 static int16 to_int16(enum_t value) noexcept {return enum_object<enum_t>(value).to_int16();}
549
553 template<typename enum_t>
554 static int32 to_int32(enum_t value) noexcept {return enum_object<enum_t>(value).to_int32();}
555
559 template<typename enum_t>
560 static int64 to_int64(enum_t value) noexcept {return enum_object<enum_t>(value).to_int64();}
561
565 template<typename enum_t>
566 static sbyte to_sbyte(enum_t value) noexcept {return enum_object<enum_t>(value).to_sbyte();}
567
571 template<typename enum_t>
572 static xtd::ustring to_string(enum_t value) noexcept {return enum_object<enum_t>(value).to_string();}
573
577 template<typename enum_t>
578 static uint16 to_uint16(enum_t value) noexcept {return enum_object<enum_t>(value).to_uint16();}
579
583 template<typename enum_t>
584 static uint32 to_uint32(enum_t value) noexcept {return enum_object<enum_t>(value).to_uint32();}
585
589 template<typename enum_t>
590 static uint64 to_uint64(enum_t value) noexcept {return enum_object<enum_t>(value).to_uint64();}
591
596 template<typename enum_t>
597 static bool try_parse(const xtd::ustring& value, enum_t& result) noexcept {return try_parse<enum_t>(value, false, result);}
598
604 template<typename enum_t>
605 static bool try_parse(const xtd::ustring& value, bool ignore_case, enum_t& result) noexcept {
606 try {
607 result = parse<enum_t>(value, ignore_case);
608 return true;
609 } catch (...) {
610 return false;
611 }
612 }
614 };
616
618 template<typename type_t>
619 inline std::string to_string(const xtd::enum_object<type_t>& value, const std::string& fmt, const std::locale& loc) {
620 return value.to_string(fmt);
621 }
623}
624
626template<typename enum_t>
627inline std::string __enum_to_string(enum_t value) noexcept {
628 return xtd::enum_object<>::get_name(value);
629}
630
631template<typename value_t>
632value_t __parse_enum(const std::string& str) {
634}
636
Represents the base class for custom attributes.
Definition attribute.h:23
static std::vector< int64 > get_values_as_int64() noexcept
Retrieves an array of the values of the constants in a specified enumeration.
Definition enum_object.h:463
static xtd::ustring get_name(int64 value) noexcept
Retrieves the name of the constant in the specified enumeration that has the specified value.
Definition enum_object.h:407
static xtd::enum_collection< uint32 > get_entries_as_uint32() noexcept
Retrieves an array of the std::pair<uint32, xtd::ustring> of the constants in a specified enumeration...
Definition enum_object.h:369
static xtd::enum_collection< int32 > get_entries_as_int32() noexcept
Retrieves an array of the std::pair<int32, xtd::ustring> of the constants in a specified enumeration.
Definition enum_object.h:333
static std::vector< uint16 > get_values_as_uint16() noexcept
Retrieves an array of the values of the constants in a specified enumeration.
Definition enum_object.h:483
static std::vector< int32 > get_values_as_int32() noexcept
Retrieves an array of the values of the constants in a specified enumeration.
Definition enum_object.h:453
static enum_t parse(const xtd::ustring &value)
Converts the xtd::ustring representation of the name or numeric value of one or more enumerated const...
Definition enum_object.h:527
static xtd::ustring get_name(enum_object< enum_t > value) noexcept
Retrieves the name of the constant in the specified enumeration that has the specified value.
Definition enum_object.h:395
static int16 to_int16(enum_t value) noexcept
Converts this instance to int16.
Definition enum_object.h:548
static xtd::enum_collection< int64 > get_entries_as_int64() noexcept
Retrieves an array of the std::pair<int64, xtd::ustring> of the constants in a specified enumeration.
Definition enum_object.h:342
static std::vector< int16 > get_values_as_int16() noexcept
Retrieves an array of the values of the constants in a specified enumeration.
Definition enum_object.h:443
static std::vector< sbyte > get_values_as_sbyte() noexcept
Retrieves an array of the values of the constants in a specified enumeration.
Definition enum_object.h:473
static enum_t parse(const xtd::ustring &str, bool ignore_case)
Converts the xtd::ustring representation of the name or numeric value of one or more enumerated const...
Definition enum_object.h:534
static bool try_parse(const xtd::ustring &value, enum_t &result) noexcept
Converts the xtd::ustring representation of the name or numeric value of one or more enumerated const...
Definition enum_object.h:597
static std::vector< uint32 > get_values_as_uint32() noexcept
Retrieves an array of the values of the constants in a specified enumeration.
Definition enum_object.h:493
static std::vector< enum_t > get_values() noexcept
Retrieves an array of the values of the constants in a specified enumeration.
Definition enum_object.h:423
static xtd::ustring get_name(int32 value) noexcept
Retrieves the name of the constant in the specified enumeration that has the specified value.
Definition enum_object.h:401
static sbyte to_sbyte(enum_t value) noexcept
Converts this instance to signed byte.
Definition enum_object.h:566
static xtd::ustring get_name(enum_t value) noexcept
Retrieves the name of the constant in the specified enumeration that has the specified value.
Definition enum_object.h:389
static const xtd::enum_collection< enum_t > & get_entries() noexcept
Retrieves an array of the std::pair<enum_t, xtd::ustring> of the constants in a specified enumeration...
Definition enum_object.h:308
static bool try_parse(const xtd::ustring &value, bool ignore_case, enum_t &result) noexcept
Converts the xtd::ustring representation of the name or numeric value of one or more enumerated const...
Definition enum_object.h:605
static bool is_defined(enum_t value) noexcept
Returns an indication whether a constant with a specified value exists in a specified enumeration.
Definition enum_object.h:514
static std::vector< uint64 > get_values_as_uint64() noexcept
Retrieves an array of the values of the constants in a specified enumeration.
Definition enum_object.h:503
static xtd::byte to_byte(enum_t value) noexcept
Converts this instance to byte.
Definition enum_object.h:542
static xtd::enum_collection< uint16 > get_entries_as_uint16() noexcept
Retrieves an array of the std::pair<uint16, xtd::ustring> of the constants in a specified enumeration...
Definition enum_object.h:360
static xtd::enum_collection< xtd::byte > get_entries_as_byte() noexcept
Retrieves an array of the std::pair<xtd::byte, xtd::ustring> of the constants in a specified enumerat...
Definition enum_object.h:315
static bool is_defined(enum_object< enum_t > value) noexcept
Returns an indication whether a constant with a specified value exists in a specified enumeration.
Definition enum_object.h:520
static xtd::ustring to_string(enum_t value) noexcept
Converts this instance to string.
Definition enum_object.h:572
static int32 to_int32(enum_t value) noexcept
Converts this instance to int32.
Definition enum_object.h:554
static uint32 to_uint32(enum_t value) noexcept
Converts this instance to unsigned int32.
Definition enum_object.h:584
static int64 to_int64(enum_t value) noexcept
Converts this instance to int64.
Definition enum_object.h:560
static std::vector< xtd::byte > get_values_as_byte() noexcept
Retrieves an array of the values of the constants in a specified enumeration.
Definition enum_object.h:433
static std::vector< xtd::ustring > get_names() noexcept
Retrieves an array of the names of the constants in a specified enumeration.
Definition enum_object.h:413
static uint16 to_uint16(enum_t value) noexcept
Converts this instance to unsigned int16.
Definition enum_object.h:578
static uint64 to_uint64(enum_t value) noexcept
Converts this instance to unsigned int64.
Definition enum_object.h:590
static xtd::enum_collection< sbyte > get_entries_as_sbyte() noexcept
Retrieves an array of the std::pair<sbyte, xtd::ustring> of the constants in a specified enumeration.
Definition enum_object.h:351
static xtd::enum_collection< uint64 > get_entries_as_uint64() noexcept
Retrieves an array of the std::pair<uint64, xtd::ustring> of the constants in a specified enumeration...
Definition enum_object.h:378
static xtd::enum_collection< int16 > get_entries_as_int16() noexcept
Retrieves an array of the std::pair<int16, xtd::ustring> of the constants in a specified enumeration.
Definition enum_object.h:324
Provides the base class for enumerations.
Definition enum_object.h:38
bool has_flag(enum_type flag) const noexcept
Retrieves an array of the values of the constants in a specified enumeration.
Definition enum_object.h:78
int64 to_int64() const noexcept
Converts this instance to int64.
Definition enum_object.h:114
uint32 to_uint32() const noexcept
Converts this instance to unsigned int32.
Definition enum_object.h:126
uint16 to_uint16() const noexcept
Converts this instance to unsigned int16.
Definition enum_object.h:122
enum_type value() const noexcept
Gets the value of the enum.
Definition enum_object.h:82
sbyte to_sbyte() const noexcept
Converts this instance to signed byte.
Definition enum_object.h:118
xtd::ustring to_string(const xtd::ustring &format) const
Converts the value of this instance to its equivalent string representation using the specified forma...
Definition enum_object.h:158
enum_object & value(enum_type value)
Sets the value of the enum.
Definition enum_object.h:85
xtd::ustring to_string() const noexcept override
Returns a sxd::ustring that represents the current object.
Definition enum_object.h:132
xtd::byte to_byte() const noexcept
Converts this instance to byte.
Definition enum_object.h:102
uint64 to_uint64() const noexcept
Converts this instance to unsigned int64.
Definition enum_object.h:130
int32 to_int32() const noexcept
Converts this instance to int32.
Definition enum_object.h:110
enum_object() noexcept=default
Initializes a new instance of the xtd::enum_object class.
int16 to_int16() const noexcept
Converts this instance to int16.
Definition enum_object.h:106
The exception that is thrown when the format of an argument does not meet the parameter specification...
Definition format_exception.h:18
Defines a generalized comparison method that a value type or class implements to create a type-specif...
Definition icomparable.h:17
Defines a generalized method that a value type or class implements to create a type-specific method f...
Definition iequatable.h:18
virtual bool equals(const type_t &) const noexcept=0
Indicates whether the current object is equal to another object of the same type.
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
bool is_empty() const noexcept
Indicates whether this string is an empty string ("").
Definition ustring.h:597
static int32 compare(const ustring &str_a, const ustring &str_b) noexcept
Compares two specified string objects and returns an integer that indicates their relative position i...
Contains xtd::enum_attribute enum class.
Contains xtd::enum_collection.
Contains xtd::enum_register.
Contains xtd::enum_set_attribute strcut.
Contains xtd::format_exception exception.
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
#define static_
This keyword is use to represent a static object. A static object can't be instantiated (constructors...
Definition static.h:37
#define csf_
Provides information about the current stack frame.
Definition current_stack_frame.h:30
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
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
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
enum_attribute
Specifies the enum attribute.
Definition enum_attribute.h:20
std::vector< std::pair< enum_t, xtd::ustring > > enum_collection
Represents a pair of an enum_t value and a string of an enum of type enum_t.
Definition enum_collection.h:19
std::string to_string(const date_time &value, const std::string &fmt, const std::locale &loc)
Convert a specified value into a string with specified format and locale.
Definition date_time.h:1080
value_t parse(const std::string &str)
Convert a string into a type.
Definition parse.h:34
@ flags
Enum flags attribute.
@ end
The END key.
Contains xtd::icomparable interface.
Contains xtd::iequatable interface.
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition xtd_about_box.h:10
Contains xtd::number_styles enum class.
Contains std::optional type and std::bad_optional_access exception.
Contains xtd::static_object class.
Contains xtd::string_comparison enum class.
Contains xtd::string_split_options enum class.