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 "number_styles.h"
14#include "optional.h"
15#include "static.h"
16#include "string_comparison.h"
18
20namespace xtd {
22
40 template<typename enum_t = std::nullptr_t>
41 class enum_object : public xtd::object, public xtd::icomparable<enum_object<enum_t>>, public xtd::iequatable<enum_object<enum_t>>, public xtd::iformatable {
42 public:
44
46 using enum_type = enum_t;
48
50
53 enum_object() noexcept = default;
56 explicit enum_object(enum_type value) : value_(value) {}
58
60 explicit enum_object(xtd::byte value) : value_(to_enum(value)) {}
61 explicit enum_object(sbyte value) : value_(to_enum(value)) {}
62 explicit enum_object(int16 value) : value_(to_enum(value)) {}
63 explicit enum_object(int32 value) : value_(to_enum(value)) {}
64 explicit enum_object(int64 value) : value_(to_enum(value)) {}
65 explicit enum_object(uint16 value) : value_(to_enum(value)) {}
66 explicit enum_object(uint32 value) : value_(to_enum(value)) {}
67 explicit enum_object(uint64 value) : value_(to_enum(value)) {}
68 enum_object(enum_object&&) noexcept = default;
69 enum_object(const enum_object&) noexcept = default;
70 enum_object& operator =(const enum_object&) noexcept = default;
71 operator enum_type() const noexcept {return value_;}
73
75
81 bool has_flag(enum_type flag) const noexcept {return (to_int(value_) & to_int(flag)) == to_int(flag);}
82
85 enum_type value() const noexcept {return value_;}
88 enum_object& value(enum_type value) {
89 value_ = value;
90 return *this;
91 }
93
95
97 int32 compare_to(const enum_object& value) const noexcept override {
98 if (to_int(value_) == to_int(value.value_)) return 0;
99 if (to_int(value_) < to_int(value.value_)) return -1;
100 return 1;
101 }
102
105 xtd::byte to_byte() const noexcept {return static_cast<xtd::byte>(value_);}
106
109 int16 to_int16() const noexcept {return static_cast<int16>(value_);}
110
113 int32 to_int32() const noexcept {return static_cast<int32>(value_);}
114
117 int64 to_int64() const noexcept {return static_cast<int64>(value_);}
118
121 sbyte to_sbyte() const noexcept {return static_cast<sbyte>(value_);}
122
125 uint16 to_uint16() const noexcept {return static_cast<uint16>(value_);}
126
129 uint32 to_uint32() const noexcept {return static_cast<uint32>(value_);}
130
133 uint64 to_uint64() const noexcept {return static_cast<uint64>(value_);}
134
135 xtd::string to_string() const noexcept override {
136 init();
137 if (attribute() == xtd::enum_attribute::flags) return to_string_flags();
138
139 auto iterator = std::find_if(entries().begin(), entries().end(), [&](auto value)->bool {return value.first == value_;});
140 if (iterator == entries().end()) return string::format("{}", to_int(value_));
141
142 return iterator->second;
143 }
144
161 xtd::string to_string(const xtd::string& format) const {return to_string(format, std::locale {});}
162
180 xtd::string to_string(const xtd::string& format, const std::locale& loc) const override;
182
184 using object::equals;
185 bool equals(const enum_object& value) const noexcept override {return value_ == value.value_;}
186 bool equals(enum_type value) const noexcept {return value_ == value;}
187 template<typename attribute_t>
188 bool equals(attribute_t value) const noexcept {return false;}
189
190 static enum_type parse(const xtd::string& str) {return parse(str, false);}
191 static enum_type parse(const xtd::string& str, bool ignore_case) {
192 enum_object<enum_type>().init();
193 if (enum_object<enum_type>().attribute() == xtd::enum_attribute::flags) return parse_flags(str, ignore_case);
194
195 for (auto item : enum_object<enum_type>().entries()) {
196 if (xtd::string::compare(str, item.second, ignore_case) == 0)
197 return static_cast<enum_type>(item.first);
198 }
199
200 return to_enum(xtd::parse<int64>(str));
201 }
202
203 static enum_type parse_flags(const xtd::string& value, bool ignore_case) {
204 std::vector<xtd::string> values = value.split(',');
205 for (xtd::string& str : values)
206 str = str.trim(' ');
207
208 if (values.size() == 1) {
209 for (auto item : enum_object<enum_type>().entries()) {
210 if (xtd::string::compare(value, item.second, ignore_case) == 0)
211 return to_enum(item.first);
212 }
213 return to_enum(xtd::parse<int64>(value));
214 }
215
216 int64 result = 0;
217 for (xtd::string str : values) {
218 bool found = false;
219 for (auto item : enum_object<enum_type>().entries()) {
220 if (xtd::string::compare(str, item.second, ignore_case) == 0) {
221 found = true;
222 result |= to_int(item.first);
223 break;
224 }
225 }
226 if (found == false)
228 }
229
230 return to_enum(result);
231 }
233
234 private:
235 friend class enum_object<std::nullptr_t>;
236
237 xtd::string get_name() const noexcept {
238 auto iterator = std::find_if(entries().begin(), entries().end(), [&](auto value)->bool {return value.first == value_;});
239 if (iterator == entries().end()) return xtd::string::format("{}", to_int(value_));
240 return iterator->second;
241 }
242
243 xtd::string to_string_flags() const noexcept {
244 auto iterator = std::find_if(entries().begin(), entries().end(), [&](auto value)->bool {return value.first == value_;});
245 if (to_int(value_) == 0 && iterator == entries().end()) return "0";
246
247 iterator = std::find_if(entries().begin(), entries().end(), [&](auto value)->bool {return value.first == to_enum(0);});
248 if (to_int(value_) == 0) return iterator == entries().end() ? "0" : iterator->second;
249
250 xtd::string str;
251 int64 rest = to_int(value_);
252 enum_collection<enum_type> reversed_entries = entries();
253 std::reverse(reversed_entries.begin(), reversed_entries.end());
254
255 for (auto item : reversed_entries) {
256 if (to_int(item.first) != 0 && (rest & to_int(item.first)) == to_int(item.first)) {
257 rest -= to_int(item.first);
258 if (!xtd::string::is_empty(str)) str = ", " + str;
259 str = item.second + str;
260 }
261 }
262
263 if (str.empty() || rest > 0) return xtd::string::format("{}", to_int(value_));
264
265 return str;
266 }
267
268 template<typename attribute_t>
269 static enum_type to_enum(attribute_t value) noexcept {return static_cast<enum_type>(value);}
270 static int64 to_int(enum_type value) noexcept {return static_cast<int64>(value);}
271
272 static xtd::enum_attribute attribute() noexcept {
273 if (attribute_.has_value()) return attribute_.value();
274 attribute_ = xtd::enum_attribute(enum_set_attribute<enum_type>());
275 return attribute_.value();
276 }
277
278 static enum_collection<enum_type>& entries() noexcept {
279 if (entries_.has_value()) return entries_.value();
280 entries_ = enum_collection<enum_type>(enum_register<enum_type>());
281 return entries_.value();
282 };
283
284 static void init() noexcept {
285 attribute();
286 entries();
287 }
288
289 inline static std::optional<xtd::enum_attribute> attribute_;
290 inline static std::optional<enum_collection<enum_type>> entries_;
291 enum_type value_ {};
292 };
293
304 template<>
305 class enum_object<std::nullptr_t> static_ {
306 public:
308
312 template<typename enum_t>
313 static const xtd::enum_collection<enum_t>& get_entries() noexcept {
314 return enum_object<enum_t>().entries();
315 }
316
319 template<typename enum_t>
322 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);});
323 return entries;
324 }
325
328 template<typename enum_t>
331 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);});
332 return entries;
333 }
334
337 template<typename enum_t>
340 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);});
341 return entries;
342 }
343
346 template<typename enum_t>
349 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);});
350 return entries;
351 }
352
355 template<typename enum_t>
358 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);});
359 return entries;
360 }
361
364 template<typename enum_t>
367 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);});
368 return entries;
369 }
370
373 template<typename enum_t>
376 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);});
377 return entries;
378 }
379
382 template<typename enum_t>
385 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);});
386 return entries;
387 }
388
393 template<typename enum_t>
394 static xtd::string get_name(enum_t value) noexcept {return enum_object<enum_t>(value).to_string();}
399 template<typename enum_t>
405 template<typename enum_t>
411 template<typename enum_t>
413
417 template<typename enum_t>
418 static std::vector<xtd::string> get_names() noexcept {
419 std::vector<xtd::string> names;
420 std::for_each(enum_object<enum_t>().entries().begin(), enum_object<enum_t>().entries().end(), [&](auto entry) {names.push_back(entry.second);});
421 return names;
422 }
423
427 template<typename enum_t>
428 static std::vector<enum_t> get_values() noexcept {
429 std::vector<enum_t> values;
430 std::for_each(enum_object<enum_t>().entries().begin(), enum_object<enum_t>().entries().end(), [&](auto entry) {values.push_back(entry.first);});
431 return values;
432 }
433
437 template<typename enum_t>
438 static std::vector<xtd::byte> get_values_as_byte() noexcept {
439 std::vector<xtd::byte> values;
440 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());});
441 return values;
442 }
443
447 template<typename enum_t>
448 static std::vector<int16> get_values_as_int16() noexcept {
449 std::vector<int16> values;
450 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());});
451 return values;
452 }
453
457 template<typename enum_t>
458 static std::vector<int32> get_values_as_int32() noexcept {
459 std::vector<int32> values;
460 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());});
461 return values;
462 }
463
467 template<typename enum_t>
468 static std::vector<int64> get_values_as_int64() noexcept {
469 std::vector<int64> values;
470 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());});
471 return values;
472 }
473
477 template<typename enum_t>
478 static std::vector<sbyte> get_values_as_sbyte() noexcept {
479 std::vector<sbyte> values;
480 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());});
481 return values;
482 }
483
487 template<typename enum_t>
488 static std::vector<uint16> get_values_as_uint16() noexcept {
489 std::vector<uint16> values;
490 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());});
491 return values;
492 }
493
497 template<typename enum_t>
498 static std::vector<uint32> get_values_as_uint32() noexcept {
499 std::vector<uint32> values;
500 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());});
501 return values;
502 }
503
507 template<typename enum_t>
508 static std::vector<uint64> get_values_as_uint64() noexcept {
509 std::vector<uint64> values;
510 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());});
511 return values;
512 }
513
518 template<typename enum_t>
519 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();}
524 template<typename enum_t>
525 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();}
526
531 template<typename enum_t>
532 static enum_t parse(const xtd::string& value) {return parse<enum_t>(value, false);}
538 template<typename enum_t>
539 static enum_t parse(const xtd::string& str, bool ignore_case) {
540 return enum_object<enum_t>::parse(str, ignore_case);
541 }
542
546 template<typename enum_t>
547 static xtd::byte to_byte(enum_t value) noexcept {return enum_object<enum_t>(value).to_byte();}
548
552 template<typename enum_t>
553 static int16 to_int16(enum_t value) noexcept {return enum_object<enum_t>(value).to_int16();}
554
558 template<typename enum_t>
559 static int32 to_int32(enum_t value) noexcept {return enum_object<enum_t>(value).to_int32();}
560
564 template<typename enum_t>
565 static int64 to_int64(enum_t value) noexcept {return enum_object<enum_t>(value).to_int64();}
566
570 template<typename enum_t>
571 static sbyte to_sbyte(enum_t value) noexcept {return enum_object<enum_t>(value).to_sbyte();}
572
576 template<typename enum_t>
577 static xtd::string to_string(enum_t value) noexcept {return enum_object<enum_t>(value).to_string();}
578
582 template<typename enum_t>
583 static uint16 to_uint16(enum_t value) noexcept {return enum_object<enum_t>(value).to_uint16();}
584
588 template<typename enum_t>
589 static uint32 to_uint32(enum_t value) noexcept {return enum_object<enum_t>(value).to_uint32();}
590
594 template<typename enum_t>
595 static uint64 to_uint64(enum_t value) noexcept {return enum_object<enum_t>(value).to_uint64();}
596
601 template<typename enum_t>
602 static bool try_parse(const xtd::string& value, enum_t& result) noexcept {return try_parse<enum_t>(value, false, result);}
603
609 template<typename enum_t>
610 static bool try_parse(const xtd::string& value, bool ignore_case, enum_t& result) noexcept {
611 try {
612 result = parse<enum_t>(value, ignore_case);
613 return true;
614 } catch (...) {
615 return false;
616 }
617 }
619 };
621
623 template<typename enum_t>
624 xtd::string enum_object<enum_t>::to_string(const xtd::string& format, const std::locale& loc) const {
625 init();
626 auto fmt = format;
627 if (fmt.empty()) fmt = "G";
628
629 switch (fmt[0]) {
630 case 'b':
631 case 'B':
632 case 'd':
633 case 'D':
634 case 'o':
635 case 'O':
636 case 'x':
637 case 'X': return __numeric_formatter(fmt.chars(), static_cast<long long int>(value_), std::locale());
638 case 'f':
639 case 'F':
640 case 'g':
641 case 'G': return xtd::enum_object<>::get_name(value_);
642 }
643 throw format_exception("Invalid format"_t);
644 }
646}
647
649template<typename enum_t>
650inline std::string __enum_to_string(enum_t value) noexcept {
651 return xtd::enum_object<>::get_name(value);
652}
653
654template<typename value_t>
655value_t __parse_enum(const std::string& str) {
657}
659
Represents the base class for custom attributes.
Definition attribute.h:25
bool is_empty() const noexcept
Indicates whether this basic_string is an empty basic_string ("").
Definition basic_string.h:1411
int32 compare(const basic_string &str) const
Compares two character sequences.
Definition basic_string.h:863
bool empty() const noexcept
Checks if the string has no characters, i.e. whether begin() == end().
Definition basic_string.h:804
Represents text as a sequence of character units.
Definition basic_string.h:79
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:468
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:532
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:374
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:338
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:488
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:458
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:406
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:610
static xtd::string to_string(enum_t value) noexcept
Converts this instance to string.
Definition enum_object.h:577
static int16 to_int16(enum_t value) noexcept
Converts this instance to int16.
Definition enum_object.h:553
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:400
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:347
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:448
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:478
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:418
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:602
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:498
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:428
static sbyte to_sbyte(enum_t value) noexcept
Converts this instance to signed byte.
Definition enum_object.h:571
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:412
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:313
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:519
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:508
static xtd::byte to_byte(enum_t value) noexcept
Converts this instance to byte.
Definition enum_object.h:547
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:365
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:320
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:525
static int32 to_int32(enum_t value) noexcept
Converts this instance to int32.
Definition enum_object.h:559
static uint32 to_uint32(enum_t value) noexcept
Converts this instance to unsigned int32.
Definition enum_object.h:589
static int64 to_int64(enum_t value) noexcept
Converts this instance to int64.
Definition enum_object.h:565
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:539
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:438
static uint16 to_uint16(enum_t value) noexcept
Converts this instance to unsigned int16.
Definition enum_object.h:583
static uint64 to_uint64(enum_t value) noexcept
Converts this instance to unsigned int64.
Definition enum_object.h:595
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:356
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:394
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:383
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:329
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:81
int64 to_int64() const noexcept
Converts this instance to int64.
Definition enum_object.h:117
uint32 to_uint32() const noexcept
Converts this instance to unsigned int32.
Definition enum_object.h:129
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:161
uint16 to_uint16() const noexcept
Converts this instance to unsigned int16.
Definition enum_object.h:125
enum_type value() const noexcept
Gets the value of the enum.
Definition enum_object.h:85
sbyte to_sbyte() const noexcept
Converts this instance to signed byte.
Definition enum_object.h:121
xtd::string to_string() const noexcept override
Returns a xtd::string that represents the current object.
Definition enum_object.h:135
enum_object & value(enum_type value)
Sets the value of the enum.
Definition enum_object.h:88
xtd::byte to_byte() const noexcept
Converts this instance to byte.
Definition enum_object.h:105
uint64 to_uint64() const noexcept
Converts this instance to unsigned int64.
Definition enum_object.h:133
int32 to_int32() const noexcept
Converts this instance to int32.
Definition enum_object.h:113
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:109
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...
Provides the base class for enumerations.
Definition enum_object.h:41
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:21
virtual bool equals(const type_t &) const noexcept=0
Indicates wheth er the current object is equal to another object of the same type.
Defines a generalized method that a value type or class implements to create a type-specific method f...
Definition iequatable.h:22
Provides functionality to format the value of an object into a string representation.
Definition iformatable.h:35
virtual bool equals(const object &obj) const noexcept
Determines whether the specified object is equal to the current object.
Supports all classes in the xtd class hierarchy and provides low-level services to derived classes....
Definition object.h:42
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
#define csf_
Provides information about the current stack frame.
Definition current_stack_frame.h:30
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
@ flags
Enum flags attribute.
@ end
The END key.
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
Contains xtd::icomparable interface.
Contains xtd::iequatable interface.
Contains xtd::iformatable 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.