48 template<
class enum_t = std::
nullptr_t>
112 if (to_int(this->
value) == to_int(
value.value))
return 0;
113 if (to_int(this->
value) < to_int(
value.value))
return -1;
132 template<
class attribute_t>
177 auto iterator = std::find_if(entries().begin(), entries().
end(), [&](
auto value)->
bool {
return value.first == this->
value;});
180 return iterator->second;
239 return static_cast<enum_type>(item.first);
242 return to_enum(xtd::parse<int64>(str));
250 auto iterator = std::find_if(entries().begin(), entries().
end(), [&](
auto value)->
bool {
return value.first == this->
value;});
252 return iterator->second;
260 if (values.
size() == 1) {
263 return to_enum(item.first);
265 return to_enum(xtd::parse<int64>(
value));
274 result |= to_int(item.first);
282 return to_enum(result);
286 auto iterator = std::find_if(entries().
begin(), entries().
end(), [&](
auto value)->
bool {
return value.first == this->
value;});
287 if (to_int(
value) == 0 && iterator == entries().
end())
return "0";
289 iterator = std::find_if(entries().
begin(), entries().
end(), [&](
auto value)->
bool {
return value.first == to_enum(0);});
290 if (to_int(
value) == 0)
return iterator == entries().end() ?
"0" : iterator->second;
294 enum_collection<enum_type> reversed_entries = entries();
295 std::reverse(reversed_entries.begin(), reversed_entries.end());
297 for (
auto item : reversed_entries) {
298 if (to_int(item.first) != 0 && (rest & to_int(item.first)) == to_int(item.first)) {
299 rest -= to_int(item.first);
301 str = item.second + str;
310 template<
class attribute_t>
315 if (attribute_.has_value())
return attribute_.value();
317 return attribute_.value();
320 static enum_collection<enum_type>& entries() noexcept {
321 if (entries_.has_value())
return entries_.value();
322 entries_ = enum_collection<enum_type>(enum_register<enum_type>());
323 return entries_.value();
326 static void init() noexcept {
331 inline static std::optional<xtd::enum_attribute> attribute_;
332 inline static std::optional<enum_collection<enum_type>> entries_;
358 template<
class enum_t>
365 template<
class enum_t>
374 template<
class enum_t>
383 template<
class enum_t>
392 template<
class enum_t>
401 template<
class enum_t>
410 template<
class enum_t>
419 template<
class enum_t>
428 template<
class enum_t>
439 template<
class enum_t>
445 template<
class enum_t>
451 template<
class enum_t>
457 template<
class enum_t>
463 template<
class enum_t>
473 template<
class enum_t>
483 template<
class enum_t>
493 template<
class enum_t>
503 template<
class enum_t>
513 template<
class enum_t>
523 template<
class enum_t>
533 template<
class enum_t>
543 template<
class enum_t>
553 template<
class enum_t>
564 template<
class enum_t>
570 template<
class enum_t>
577 template<
class enum_t>
584 template<
class enum_t>
592 template<
class enum_t>
598 template<
class enum_t>
604 template<
class enum_t>
610 template<
class enum_t>
616 template<
class enum_t>
622 template<
class enum_t>
628 template<
class enum_t>
634 template<
class enum_t>
640 template<
class enum_t>
647 template<
class enum_t>
655 template<
class enum_t>
658 result = parse<enum_t>(
value, ignore_case);
669 template<
class enum_t>
673 if (fmt.empty()) fmt =
"G";
683 case 'X':
return __numeric_formatter(fmt.chars(),
static_cast<long long int>(value), std::locale());
695template<
class enum_t>
696inline std::string __enum_to_string__(enum_t value)
noexcept {
700template<
class value_t>
701value_t __parse_enum(
const std::string& str) {
Contains xtd::array class.
Provides methods for creating, manipulating, searching, and sorting arrays, thereby serving as the ba...
Definition array.hpp:61
Represents the base class for custom attributes.
Definition attribute.hpp:25
void resize(size_type new_size)
Resizes the container to contain count elements, does nothing if count == size(). @param new_size The...
Definition basic_array.hpp:377
virtual size_type size() const noexcept
Returns the number of elements in the container, i.e. std::distance(xtd::array::begin(),...
Definition basic_array.hpp:229
Represents text as a sequence of character units.
Definition basic_string.hpp:71
bool is_empty() const noexcept
Indicates whether this basic_string is an empty basic_string ("").
Definition basic_string.hpp:1503
int32 compare(const basic_string &str) const
Compares two character sequences.
Definition basic_string.hpp:955
bool empty() const noexcept
Checks if the string has no characters, i.e. whether begin() == end().
Definition basic_string.hpp:896
static xtd::size combine(args_t... values) noexcept
Combines values into a hash code.
Definition hash_code.hpp:70
static void throws(xtd::helpers::exception_case exception_case, const source_location &location=source_location::current())
Throws an exption with specified exception case.
Defines a generalized comparison method that a value type or class implements to create a type-specif...
Definition icomparable.hpp:21
Defines a generalized method that a value type or class implements to create a type-specific method f...
Definition iequatable.hpp:22
Supports all classes in the xtd class hierarchy and provides low-level services to derived classes....
Definition object.hpp:43
Contains xtd::enum_attribute enum class.
Contains xtd::enum_collection.
Contains xtd::enum_register.
Contains xtd::enum_set_attribute strcut.
@ format
The format is not valid.
#define static_
This keyword is use to represent a static object. A static object can't be instantiated (constructors...
Definition static.hpp:37
int16_t int16
Represents a 16-bit signed integer.
Definition int16.hpp:23
int32_t int32
Represents a 32-bit signed integer.
Definition int32.hpp:23
int64_t int64
Represents a 64-bit signed integer.
Definition int64.hpp:23
int8_t sbyte
Represents a 8-bit signed integer.
Definition sbyte.hpp:23
uint32_t uint32
Represents a 32-bit unsigned integer.
Definition uint32.hpp:23
size_t size
Represents a size of any object in bytes.
Definition size.hpp:23
uint64_t uint64
Represents a 64-bit unsigned integer.
Definition uint64.hpp:23
uint8_t byte
Represents a 8-bit unsigned integer.
Definition byte.hpp:23
uint16_t uint16
Represents a 16-bit unsigned integer.
Definition uint16.hpp:23
enum_attribute
Specifies the enum attribute.
Definition enum_attribute.hpp: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.hpp:23
@ flags
Enum flags attribute.
@ begin
Specifies the beginning of a stream.
Contains xtd::icomparable interface.
Contains xtd::iequatable interface.
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition xtd_about_box.hpp: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.
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.hpp:578
static xtd::array< xtd::byte > get_values_as_byte() noexcept
Retrieves an array of the values of the constants in a specified enumeration.
Definition enum_object.hpp:484
static xtd::enum_collection< uint32 > get_entries_as_uint32() noexcept
Retrieves an array of the xtd::enum_collection<uint32> of the constants in a specified enumeration.
Definition enum_object.hpp:420
static xtd::array< uint16 > get_values_as_uint16() noexcept
Retrieves an array of the values of the constants in a specified enumeration.
Definition enum_object.hpp:534
static xtd::enum_collection< int32 > get_entries_as_int32() noexcept
Retrieves an array of the xtd::enum_collection<int32> of the constants in a specified enumeration.
Definition enum_object.hpp:384
static xtd::array< int32 > get_values_as_int32() noexcept
Retrieves an array of the values of the constants in a specified enumeration.
Definition enum_object.hpp:504
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.hpp:452
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.hpp:656
static xtd::string to_string(enum_t value) noexcept
Converts this instance to string.
Definition enum_object.hpp:623
static int16 to_int16(enum_t value) noexcept
Converts this instance to int16.
Definition enum_object.hpp:599
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.hpp:446
static xtd::array< uint64 > get_values_as_uint64() noexcept
Retrieves an array of the values of the constants in a specified enumeration.
Definition enum_object.hpp:554
static xtd::array< sbyte > get_values_as_sbyte() noexcept
Retrieves an array of the values of the constants in a specified enumeration.
Definition enum_object.hpp:524
static xtd::enum_collection< int64 > get_entries_as_int64() noexcept
Retrieves an array of the xtd::enum_collection<int64> of the constants in a specified enumeration.
Definition enum_object.hpp:393
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.hpp:648
static xtd::array< xtd::string > get_names() noexcept
Retrieves an array of the names of the constants in a specified enumeration.
Definition enum_object.hpp:464
static sbyte to_sbyte(enum_t value) noexcept
Converts this instance to signed byte.
Definition enum_object.hpp:617
static xtd::array< int16 > get_values_as_int16() noexcept
Retrieves an array of the values of the constants in a specified enumeration.
Definition enum_object.hpp:494
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.hpp:458
static const xtd::enum_collection< enum_t > & get_entries() noexcept
Retrieves an array of the xtd::enum_collection<enum_t> of the constants in a specified enumeration.
Definition enum_object.hpp:359
static xtd::array< enum_t > get_values() noexcept
Retrieves an array of the values of the constants in a specified enumeration.
Definition enum_object.hpp:474
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.hpp:565
static xtd::byte to_byte(enum_t value) noexcept
Converts this instance to byte.
Definition enum_object.hpp:593
static xtd::enum_collection< uint16 > get_entries_as_uint16() noexcept
Retrieves an array of the xtd::enum_collection<uint16> of the constants in a specified enumeration.
Definition enum_object.hpp:411
static xtd::enum_collection< xtd::byte > get_entries_as_byte() noexcept
Retrieves an array of the xtd::enum_collection<xtd::byte> of the constants in a specified enumeration...
Definition enum_object.hpp:366
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.hpp:571
static int32 to_int32(enum_t value) noexcept
Converts this instance to int32.
Definition enum_object.hpp:605
static uint32 to_uint32(enum_t value) noexcept
Converts this instance to unsigned int32.
Definition enum_object.hpp:635
static int64 to_int64(enum_t value) noexcept
Converts this instance to int64.
Definition enum_object.hpp:611
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.hpp:585
static uint16 to_uint16(enum_t value) noexcept
Converts this instance to unsigned int16.
Definition enum_object.hpp:629
static uint64 to_uint64(enum_t value) noexcept
Converts this instance to unsigned int64.
Definition enum_object.hpp:641
static xtd::array< int64 > get_values_as_int64() noexcept
Retrieves an array of the values of the constants in a specified enumeration.
Definition enum_object.hpp:514
static xtd::enum_collection< sbyte > get_entries_as_sbyte() noexcept
Retrieves an array of the xtd::enum_collection<sbyte> of the constants in a specified enumeration.
Definition enum_object.hpp:402
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.hpp:440
static xtd::enum_collection< uint64 > get_entries_as_uint64() noexcept
Retrieves an array of the xtd::enum_collection<uint64> of the constants in a specified enumeration.
Definition enum_object.hpp:429
static xtd::enum_collection< int16 > get_entries_as_int16() noexcept
Retrieves an array of the xtd::enum_collection<int16> of the constants in a specified enumeration.
Definition enum_object.hpp:375
static xtd::array< uint32 > get_values_as_uint32() noexcept
Retrieves an array of the values of the constants in a specified enumeration.
Definition enum_object.hpp:544
Provides the base class for enumerations.
Definition enum_object.hpp:49
bool has_flag(enum_type flag) const noexcept
Retrieves an array of the values of the constants in a specified enumeration.
Definition enum_object.hpp:91
bool equals(const object &obj) const noexcept override
Determines whether the specified object is equal to the current object.
Definition enum_object.hpp:120
int64 to_int64() const noexcept
Converts this instance to int64.
Definition enum_object.hpp:153
uint32 to_uint32() const noexcept
Converts this instance to unsigned int32.
Definition enum_object.hpp:165
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.hpp:199
uint16 to_uint16() const noexcept
Converts this instance to unsigned int16.
Definition enum_object.hpp:161
sbyte to_sbyte() const noexcept
Converts this instance to signed byte.
Definition enum_object.hpp:157
enum_t value_type
Represents the enumeration type.
Definition enum_object.hpp:56
xtd::size get_hash_code() const noexcept override
Serves as a hash function for a particular type.
Definition enum_object.hpp:137
xtd::string to_string() const noexcept override
Returns a xtd::string that represents the current object.
Definition enum_object.hpp:173
bool equals(const enum_object &value) const noexcept override
Determines whether the specified object is equal to the current object.
Definition enum_object.hpp:124
static enum_type parse(const xtd::string &str)
Converts the string to its enum_type equivalent.
Definition enum_object.hpp:228
enum_t enum_type
Represents the enumeration type.
Definition enum_object.hpp:54
xtd::byte to_byte() const noexcept
Converts this instance to byte.
Definition enum_object.hpp:141
uint64 to_uint64() const noexcept
Converts this instance to unsigned int64.
Definition enum_object.hpp:169
bool equals(attribute_t value) const noexcept
Indicates whether the current object is equal to another object with defferent type.
Definition enum_object.hpp:133
int32 to_int32() const noexcept
Converts this instance to int32.
Definition enum_object.hpp:149
enum_object() noexcept=default
Initializes a new instance of the xtd::enum_object class.
bool equals(enum_type value) const noexcept
Indicates whether the current object is equal to another object of the same type.
Definition enum_object.hpp:128
enum_type value
Gets or sets the value of the enum.
Definition enum_object.hpp:95
static enum_type parse(const xtd::string &str, bool ignore_case)
Converts the string to its enum_type equivalent with a specified boolean to ignore case.
Definition enum_object.hpp:233
int16 to_int16() const noexcept
Converts this instance to int16.
Definition enum_object.hpp:145
int32 compare_to(const enum_object &value) const noexcept override
Compares the current instance with another object of the same type.
Definition enum_object.hpp:111
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...