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 "iformatable.h"
13#include "literals.h"
14#include "number_styles.h"
15#include "optional.h"
16#include "static.h"
17#include "string_comparison.h"
19
21namespace xtd {
23
41 template<typename enum_t = std::nullptr_t>
42 class enum_object : public xtd::object, public xtd::icomparable<enum_object<enum_t>>, public xtd::iequatable<enum_object<enum_t>>, public xtd::iformatable {
43 public:
45
47 using enum_type = enum_t;
49
51
54 enum_object() noexcept = default;
57 explicit enum_object(enum_type value) : value_(value) {}
59
61 explicit enum_object(xtd::byte value) : value_(to_enum(value)) {}
62 explicit enum_object(sbyte value) : value_(to_enum(value)) {}
63 explicit enum_object(int16 value) : value_(to_enum(value)) {}
64 explicit enum_object(int32 value) : value_(to_enum(value)) {}
65 explicit enum_object(int64 value) : value_(to_enum(value)) {}
66 explicit enum_object(uint16 value) : value_(to_enum(value)) {}
67 explicit enum_object(uint32 value) : value_(to_enum(value)) {}
68 explicit enum_object(uint64 value) : value_(to_enum(value)) {}
69 enum_object(enum_object&&) noexcept = default;
70 enum_object(const enum_object&) noexcept = default;
71 enum_object& operator =(const enum_object&) noexcept = default;
72 operator enum_type() const noexcept {return value_;}
74
76
82 bool has_flag(enum_type flag) const noexcept {return (to_int(value_) & to_int(flag)) == to_int(flag);}
83
86 enum_type value() const noexcept {return value_;}
89 enum_object& value(enum_type value) {
90 value_ = value;
91 return *this;
92 }
94
96
98 int32 compare_to(const enum_object& value) const noexcept override {
99 if (to_int(value_) == to_int(value.value_)) return 0;
100 if (to_int(value_) < to_int(value.value_)) return -1;
101 return 1;
102 }
103
106 xtd::byte to_byte() const noexcept {return static_cast<xtd::byte>(value_);}
107
110 int16 to_int16() const noexcept {return static_cast<int16>(value_);}
111
114 int32 to_int32() const noexcept {return static_cast<int32>(value_);}
115
118 int64 to_int64() const noexcept {return static_cast<int64>(value_);}
119
122 sbyte to_sbyte() const noexcept {return static_cast<sbyte>(value_);}
123
126 uint16 to_uint16() const noexcept {return static_cast<uint16>(value_);}
127
130 uint32 to_uint32() const noexcept {return static_cast<uint32>(value_);}
131
134 uint64 to_uint64() const noexcept {return static_cast<uint64>(value_);}
135
136 xtd::string to_string() const noexcept override {
137 init();
138 if (attribute() == xtd::enum_attribute::flags) return to_string_flags();
139
140 auto iterator = std::find_if(entries().begin(), entries().end(), [&](auto value)->bool {return value.first == value_;});
141 if (iterator == entries().end()) return string::format("{}", to_int(value_));
142
143 return iterator->second;
144 }
145
162 xtd::string to_string(const xtd::string& format) const {return to_string(format, std::locale {});}
163
181 xtd::string to_string(const xtd::string& format, const std::locale& loc) const override;
183
185 using object::equals;
186 bool equals(const enum_object& value) const noexcept override {return value_ == value.value_;}
187 bool equals(enum_type value) const noexcept {return value_ == value;}
188 template<typename attribute_t>
189 bool equals(attribute_t value) const noexcept {return false;}
190
191 static enum_type parse(const xtd::string& str) {return parse(str, false);}
192 static enum_type parse(const xtd::string& str, bool ignore_case) {
193 enum_object<enum_type>().init();
194 if (enum_object<enum_type>().attribute() == xtd::enum_attribute::flags) return parse_flags(str, ignore_case);
195
196 for (auto item : enum_object<enum_type>().entries()) {
197 if (xtd::string::compare(str, item.second, ignore_case) == 0)
198 return static_cast<enum_type>(item.first);
199 }
200
201 return to_enum(xtd::parse<int64>(str));
202 }
203
204 static enum_type parse_flags(const xtd::string& value, bool ignore_case) {
205 std::vector<xtd::string> values = value.split(',');
206 for (xtd::string& str : values)
207 str = str.trim(' ');
208
209 if (values.size() == 1) {
210 for (auto item : enum_object<enum_type>().entries()) {
211 if (xtd::string::compare(value, item.second, ignore_case) == 0)
212 return to_enum(item.first);
213 }
214 return to_enum(xtd::parse<int64>(value));
215 }
216
217 int64 result = 0;
218 for (xtd::string str : values) {
219 bool found = false;
220 for (auto item : enum_object<enum_type>().entries()) {
221 if (xtd::string::compare(str, item.second, ignore_case) == 0) {
222 found = true;
223 result |= to_int(item.first);
224 break;
225 }
226 }
227 if (found == false)
228 throw xtd::format_exception {};
229 }
230
231 return to_enum(result);
232 }
234
235 private:
236 friend class enum_object<std::nullptr_t>;
237
238 xtd::string get_name() const noexcept {
239 auto iterator = std::find_if(entries().begin(), entries().end(), [&](auto value)->bool {return value.first == value_;});
240 if (iterator == entries().end()) return xtd::string::format("{}", to_int(value_));
241 return iterator->second;
242 }
243
244 xtd::string to_string_flags() const noexcept {
245 auto iterator = std::find_if(entries().begin(), entries().end(), [&](auto value)->bool {return value.first == value_;});
246 if (to_int(value_) == 0 && iterator == entries().end()) return "0";
247
248 iterator = std::find_if(entries().begin(), entries().end(), [&](auto value)->bool {return value.first == to_enum(0);});
249 if (to_int(value_) == 0) return iterator == entries().end() ? "0" : iterator->second;
250
251 xtd::string str;
252 int64 rest = to_int(value_);
253 enum_collection<enum_type> reversed_entries = entries();
254 std::reverse(reversed_entries.begin(), reversed_entries.end());
255
256 for (auto item : reversed_entries) {
257 if (to_int(item.first) != 0 && (rest & to_int(item.first)) == to_int(item.first)) {
258 rest -= to_int(item.first);
259 if (!xtd::string::is_empty(str)) str = ", " + str;
260 str = item.second + str;
261 }
262 }
263
264 if (str.empty() || rest > 0) return xtd::string::format("{}", to_int(value_));
265
266 return str;
267 }
268
269 template<typename attribute_t>
270 static enum_type to_enum(attribute_t value) noexcept {return static_cast<enum_type>(value);}
271 static int64 to_int(enum_type value) noexcept {return static_cast<int64>(value);}
272
273 static xtd::enum_attribute attribute() noexcept {
274 if (attribute_.has_value()) return attribute_.value();
275 attribute_ = xtd::enum_attribute(enum_set_attribute<enum_type>());
276 return attribute_.value();
277 }
278
279 static enum_collection<enum_type>& entries() noexcept {
280 if (entries_.has_value()) return entries_.value();
281 entries_ = enum_collection<enum_type>(enum_register<enum_type>());
282 return entries_.value();
283 };
284
285 static void init() noexcept {
286 attribute();
287 entries();
288 }
289
290 inline static std::optional<xtd::enum_attribute> attribute_;
291 inline static std::optional<enum_collection<enum_type>> entries_;
292 enum_type value_ {};
293 };
294
305 template<>
306 class enum_object<std::nullptr_t> static_ {
307 public:
309
313 template<typename enum_t>
314 static const xtd::enum_collection<enum_t>& get_entries() noexcept {
315 return enum_object<enum_t>().entries();
316 }
317
320 template<typename enum_t>
323 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);});
324 return entries;
325 }
326
329 template<typename enum_t>
332 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);});
333 return entries;
334 }
335
338 template<typename enum_t>
341 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);});
342 return entries;
343 }
344
347 template<typename enum_t>
350 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);});
351 return entries;
352 }
353
356 template<typename enum_t>
359 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);});
360 return entries;
361 }
362
365 template<typename enum_t>
368 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);});
369 return entries;
370 }
371
374 template<typename enum_t>
377 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);});
378 return entries;
379 }
380
383 template<typename enum_t>
386 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);});
387 return entries;
388 }
389
394 template<typename enum_t>
395 static xtd::string get_name(enum_t value) noexcept {return enum_object<enum_t>(value).to_string();}
400 template<typename enum_t>
406 template<typename enum_t>
412 template<typename enum_t>
414
418 template<typename enum_t>
419 static std::vector<xtd::string> get_names() noexcept {
420 std::vector<xtd::string> names;
421 std::for_each(enum_object<enum_t>().entries().begin(), enum_object<enum_t>().entries().end(), [&](auto entry) {names.push_back(entry.second);});
422 return names;
423 }
424
428 template<typename enum_t>
429 static std::vector<enum_t> get_values() noexcept {
430 std::vector<enum_t> values;
431 std::for_each(enum_object<enum_t>().entries().begin(), enum_object<enum_t>().entries().end(), [&](auto entry) {values.push_back(entry.first);});
432 return values;
433 }
434
438 template<typename enum_t>
439 static std::vector<xtd::byte> get_values_as_byte() noexcept {
440 std::vector<xtd::byte> values;
441 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());});
442 return values;
443 }
444
448 template<typename enum_t>
449 static std::vector<int16> get_values_as_int16() noexcept {
450 std::vector<int16> values;
451 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());});
452 return values;
453 }
454
458 template<typename enum_t>
459 static std::vector<int32> get_values_as_int32() noexcept {
460 std::vector<int32> values;
461 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());});
462 return values;
463 }
464
468 template<typename enum_t>
469 static std::vector<int64> get_values_as_int64() noexcept {
470 std::vector<int64> values;
471 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());});
472 return values;
473 }
474
478 template<typename enum_t>
479 static std::vector<sbyte> get_values_as_sbyte() noexcept {
480 std::vector<sbyte> values;
481 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());});
482 return values;
483 }
484
488 template<typename enum_t>
489 static std::vector<uint16> get_values_as_uint16() noexcept {
490 std::vector<uint16> values;
491 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());});
492 return values;
493 }
494
498 template<typename enum_t>
499 static std::vector<uint32> get_values_as_uint32() noexcept {
500 std::vector<uint32> values;
501 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());});
502 return values;
503 }
504
508 template<typename enum_t>
509 static std::vector<uint64> get_values_as_uint64() noexcept {
510 std::vector<uint64> values;
511 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());});
512 return values;
513 }
514
519 template<typename enum_t>
520 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();}
525 template<typename enum_t>
526 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();}
527
532 template<typename enum_t>
533 static enum_t parse(const xtd::string& value) {return parse<enum_t>(value, false);}
539 template<typename enum_t>
540 static enum_t parse(const xtd::string& str, bool ignore_case) {
541 return enum_object<enum_t>::parse(str, ignore_case);
542 }
543
547 template<typename enum_t>
548 static xtd::byte to_byte(enum_t value) noexcept {return enum_object<enum_t>(value).to_byte();}
549
553 template<typename enum_t>
554 static int16 to_int16(enum_t value) noexcept {return enum_object<enum_t>(value).to_int16();}
555
559 template<typename enum_t>
560 static int32 to_int32(enum_t value) noexcept {return enum_object<enum_t>(value).to_int32();}
561
565 template<typename enum_t>
566 static int64 to_int64(enum_t value) noexcept {return enum_object<enum_t>(value).to_int64();}
567
571 template<typename enum_t>
572 static sbyte to_sbyte(enum_t value) noexcept {return enum_object<enum_t>(value).to_sbyte();}
573
577 template<typename enum_t>
578 static xtd::string to_string(enum_t value) noexcept {return enum_object<enum_t>(value).to_string();}
579
583 template<typename enum_t>
584 static uint16 to_uint16(enum_t value) noexcept {return enum_object<enum_t>(value).to_uint16();}
585
589 template<typename enum_t>
590 static uint32 to_uint32(enum_t value) noexcept {return enum_object<enum_t>(value).to_uint32();}
591
595 template<typename enum_t>
596 static uint64 to_uint64(enum_t value) noexcept {return enum_object<enum_t>(value).to_uint64();}
597
602 template<typename enum_t>
603 static bool try_parse(const xtd::string& value, enum_t& result) noexcept {return try_parse<enum_t>(value, false, result);}
604
610 template<typename enum_t>
611 static bool try_parse(const xtd::string& value, bool ignore_case, enum_t& result) noexcept {
612 try {
613 result = parse<enum_t>(value, ignore_case);
614 return true;
615 } catch (...) {
616 return false;
617 }
618 }
620 };
622
624 template<typename enum_t>
625 xtd::string enum_object<enum_t>::to_string(const xtd::string& format, const std::locale& loc) const {
626 init();
627 auto fmt = format;
628 if (fmt.empty()) fmt = "G";
629
630 switch (fmt[0]) {
631 case 'b':
632 case 'B':
633 case 'd':
634 case 'D':
635 case 'o':
636 case 'O':
637 case 'x':
638 case 'X': return __numeric_formatter(fmt.chars(), static_cast<long long int>(value_), std::locale());
639 case 'f':
640 case 'F':
641 case 'g':
642 case 'G': return xtd::enum_object<>::get_name(value_);
643 }
644 throw format_exception("Invalid format"_t);
645 }
647}
648
650template<typename enum_t>
651inline std::string __enum_to_string(enum_t value) noexcept {
652 return xtd::enum_object<>::get_name(value);
653}
654
655template<typename value_t>
656value_t __parse_enum(const std::string& str) {
658}
660
Represents the base class for custom attributes.
Definition attribute.h:25
Represents text as a sequence of character units.
Definition basic_string.h:79
bool is_empty() const noexcept
Indicates whether this basic_string is an empty basic_string ("").
Definition basic_string.h:1511
int32 compare(const basic_string &str) const
Compares two character sequences.
Definition basic_string.h:963
bool empty() const noexcept
Checks if the string has no characters, i.e. whether begin() == end().
Definition basic_string.h:904
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:469
static enum_t parse(const xtd::string &value)
Converts the xtd::string representation of the name or numeric value of one or more enumerated consta...
Definition enum_object.h:533
static xtd::enum_collection< uint32 > get_entries_as_uint32() noexcept
Retrieves an array of the xtd::collections::generic::key_value_pair<uint32, xtd::string> of the const...
Definition enum_object.h:375
static xtd::enum_collection< int32 > get_entries_as_int32() noexcept
Retrieves an array of the xtd::collections::generic::key_value_pair<int32, xtd::string> of the consta...
Definition enum_object.h:339
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:489
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:459
static xtd::string get_name(int32 value) noexcept
Retrieves the name of the constant in the specified enumeration that has the specified value.
Definition enum_object.h:407
static bool try_parse(const xtd::string &value, bool ignore_case, enum_t &result) noexcept
Converts the xtd::string representation of the name or numeric value of one or more enumerated consta...
Definition enum_object.h:611
static xtd::string to_string(enum_t value) noexcept
Converts this instance to string.
Definition enum_object.h:578
static int16 to_int16(enum_t value) noexcept
Converts this instance to int16.
Definition enum_object.h:554
static xtd::string 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:401
static xtd::enum_collection< int64 > get_entries_as_int64() noexcept
Retrieves an array of the xtd::collections::generic::key_value_pair<int64, xtd::string> of the consta...
Definition enum_object.h:348
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:449
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:479
static std::vector< xtd::string > get_names() noexcept
Retrieves an array of the names of the constants in a specified enumeration.
Definition enum_object.h:419
static bool try_parse(const xtd::string &value, enum_t &result) noexcept
Converts the xtd::string representation of the name or numeric value of one or more enumerated consta...
Definition enum_object.h:603
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:499
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:429
static sbyte to_sbyte(enum_t value) noexcept
Converts this instance to signed byte.
Definition enum_object.h:572
static xtd::string get_name(int64 value) noexcept
Retrieves the name of the constant in the specified enumeration that has the specified value.
Definition enum_object.h:413
static const xtd::enum_collection< enum_t > & get_entries() noexcept
Retrieves an array of the xtd::collections::generic::key_value_pair<enum_t, xtd::string> of the const...
Definition enum_object.h:314
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:520
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:509
static xtd::byte to_byte(enum_t value) noexcept
Converts this instance to byte.
Definition enum_object.h:548
static xtd::enum_collection< uint16 > get_entries_as_uint16() noexcept
Retrieves an array of the xtd::collections::generic::key_value_pair<uint16, xtd::string> of the const...
Definition enum_object.h:366
static xtd::enum_collection< xtd::byte > get_entries_as_byte() noexcept
Retrieves an array of the xtd::collections::generic::key_value_pair<xtd::byte, xtd::string> of the co...
Definition enum_object.h:321
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:526
static int32 to_int32(enum_t value) noexcept
Converts this instance to int32.
Definition enum_object.h:560
static uint32 to_uint32(enum_t value) noexcept
Converts this instance to unsigned int32.
Definition enum_object.h:590
static int64 to_int64(enum_t value) noexcept
Converts this instance to int64.
Definition enum_object.h:566
static enum_t parse(const xtd::string &str, bool ignore_case)
Converts the xtd::string representation of the name or numeric value of one or more enumerated consta...
Definition enum_object.h:540
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:439
static uint16 to_uint16(enum_t value) noexcept
Converts this instance to unsigned int16.
Definition enum_object.h:584
static uint64 to_uint64(enum_t value) noexcept
Converts this instance to unsigned int64.
Definition enum_object.h:596
static xtd::enum_collection< sbyte > get_entries_as_sbyte() noexcept
Retrieves an array of the xtd::collections::generic::key_value_pair<sbyte, xtd::string> of the consta...
Definition enum_object.h:357
static xtd::string 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:395
static xtd::enum_collection< uint64 > get_entries_as_uint64() noexcept
Retrieves an array of the xtd::collections::generic::key_value_pair<uint64, xtd::string> of the const...
Definition enum_object.h:384
static xtd::enum_collection< int16 > get_entries_as_int16() noexcept
Retrieves an array of the xtd::collections::generic::key_value_pair<int16, xtd::string> of the consta...
Definition enum_object.h:330
Provides the base class for enumerations.
Definition enum_object.h:42
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:82
int64 to_int64() const noexcept
Converts this instance to int64.
Definition enum_object.h:118
uint32 to_uint32() const noexcept
Converts this instance to unsigned int32.
Definition enum_object.h:130
xtd::string to_string(const xtd::string &format) const
Converts the value of this instance to its equivalent string representation using the specified forma...
Definition enum_object.h:162
uint16 to_uint16() const noexcept
Converts this instance to unsigned int16.
Definition enum_object.h:126
enum_type value() const noexcept
Gets the value of the enum.
Definition enum_object.h:86
sbyte to_sbyte() const noexcept
Converts this instance to signed byte.
Definition enum_object.h:122
xtd::string to_string() const noexcept override
Returns a xtd::string that represents the current object.
Definition enum_object.h:136
enum_object & value(enum_type value)
Sets the value of the enum.
Definition enum_object.h:89
xtd::byte to_byte() const noexcept
Converts this instance to byte.
Definition enum_object.h:106
uint64 to_uint64() const noexcept
Converts this instance to unsigned int64.
Definition enum_object.h:134
int32 to_int32() const noexcept
Converts this instance to int32.
Definition enum_object.h:114
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:110
xtd::string to_string(const xtd::string &format, const std::locale &loc) const override
Converts the value of this instance to its equivalent string representation using the specified forma...
The exception that is thrown when the format of an argument does not meet the parameter specification...
Definition format_exception.h:19
Defines a generalized comparison method that a value type or class implements to create a type-specif...
Definition icomparable.h:21
Defines a generalized method that a value type or class implements to create a type-specific method f...
Definition iequatable.h:22
virtual bool equals(const type_t &) const noexcept=0
Indicates whether the current object is equal to another object of the same type.
Provides functionality to format the value of an object into a string representation.
Definition iformatable.h:35
Supports all classes in the xtd class hierarchy and provides low-level services to derived classes....
Definition object.h:42
virtual bool equals(const object &obj) const noexcept
Determines whether the specified object is equal to the current object.
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 basic_string format(const basic_string< char > &fmt, args_t &&... args)
Writes the text representation of the specified arguments list, to string using the specified format ...
#define static_
This keyword is use to represent a static object. A static object can't be instantiated (constructors...
Definition static.h:37
int16_t int16
Represents a 16-bit signed integer.
Definition int16.h:23
int32_t int32
Represents a 32-bit signed integer.
Definition int32.h:23
int64_t int64
Represents a 64-bit signed integer.
Definition int64.h:23
int8_t sbyte
Represents a 8-bit signed integer.
Definition sbyte.h:23
uint32_t uint32
Represents a 32-bit unsigned integer.
Definition uint32.h:23
uint64_t uint64
Represents a 64-bit unsigned integer.
Definition uint64.h:23
uint8_t byte
Represents a 8-bit unsigned integer.
Definition byte.h:23
uint16_t uint16
Represents a 16-bit unsigned integer.
Definition uint16.h:23
enum_attribute
Specifies the enum attribute.
Definition enum_attribute.h:22
std::vector< xtd::collections::generic::key_value_pair< enum_t, xtd::string > > enum_collection
Represents a pair of an enum_t value and a string of an enum of type enum_t.
Definition enum_collection.h:22
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.
Contains xtd::iformatable interface.
Contains xtd literals.
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 xtd::optional type.
Contains xtd::static_object class.
Contains xtd::string_comparison enum class.
Contains xtd::string_split_options enum class.