47 template<
class enum_t = std::
nullptr_t>
111 if (to_int(this->value) == to_int(
value.value))
return 0;
112 if (to_int(this->value) < to_int(
value.value))
return -1;
131 template<
class attribute_t>
238 return static_cast<enum_type>(item.first);
247 friend auto operator << (std::ostream& os,
const enum_object&
value) -> std::ostream& {
return os <<
value.to_string();}
260 xtd::array<xtd::string> values =
value.split(
',');
264 if (values.length() == 1) {
267 return to_enum(item.first);
278 result |= to_int(item.first);
286 return to_enum(result);
299 std::reverse(reversed_entries.begin(), reversed_entries.end());
301 for (
auto item : reversed_entries) {
302 if (to_int(item.first) != 0 && (rest & to_int(item.first)) == to_int(item.first)) {
303 rest -= to_int(item.first);
305 str = item.second + str;
314 template<
class attribute_t>
319 if (attribute_.has_value())
return attribute_.value();
321 return attribute_.value();
325 if (entries_.has_value())
return entries_.value();
327 return entries_.value();
330 static void init() noexcept {
335 inline static std::optional<xtd::enum_attribute> attribute_;
336 inline static std::optional<enum_collection<enum_type>> entries_;
362 template <
class enum_t >
369 template <
class enum_t >
378 template <
class enum_t >
387 template <
class enum_t >
396 template <
class enum_t >
405 template <
class enum_t >
414 template <
class enum_t >
423 template <
class enum_t >
432 template <
class enum_t >
443 template <
class enum_t >
449 template <
class enum_t >
455 template <
class enum_t >
461 template <
class enum_t >
467 template <
class enum_t >
468 static xtd::array < xtd::string >
get_names() noexcept {
469 auto names = xtd::array < xtd::string > {};
477 template <
class enum_t >
479 auto values = xtd::array < enum_t > {};
487 template <
class enum_t >
489 auto values = xtd::array < xtd::byte > {};
497 template <
class enum_t >
499 auto values = xtd::array < xtd::int16 > {};
507 template <
class enum_t >
509 auto values = xtd::array < xtd::int32 > {};
517 template <
class enum_t >
519 auto values = xtd::array < xtd::int64 > {};
527 template <
class enum_t >
529 auto values = xtd::array < xtd::sbyte > {};
537 template <
class enum_t >
539 auto values = xtd::array < xtd::uint16 > {};
547 template <
class enum_t >
549 auto values = xtd::array < xtd::uint32 > {};
557 template <
class enum_t >
559 auto values = xtd::array < xtd::uint64 > {};
568 template <
class enum_t >
574 template <
class enum_t >
581 template <
class enum_t >
588 template <
class enum_t >
596 template <
class enum_t >
602 template <
class enum_t >
608 template <
class enum_t >
614 template <
class enum_t >
620 template <
class enum_t >
626 template <
class enum_t >
632 template <
class enum_t >
638 template <
class enum_t >
644 template <
class enum_t >
651 template <
class enum_t >
659 template <
class enum_t >
674template <
class enum_t >
675inline std::string __enum_to_string__(enum_t value)
noexcept {
676 return xtd::enum_object < >::get_name(value);
679template <
class value_t >
680inline value_t __parse_enum(
const std::string& str) {
Contains xtd::array class.
Represents the base class for custom attributes.
Definition attribute.hpp:25
basic_string trim() const noexcept
Removes all leading and trailing occurrences of white-space characters from the specified xtd::basic_...
Definition basic_string.hpp:1407
bool is_empty() const noexcept
Definition basic_string.hpp:3034
int32 compare(const basic_string &str) const
Definition basic_string.hpp:409
Provides information about a specific culture (called a locale for unmanaged code development)....
Definition culture_info.hpp:43
static xtd::size combine(args_t... values) noexcept
Combines values into a hash code.
Definition hash_code.hpp:70
static auto throws(xtd::helpers::exception_case exception_case, const source_location &location=source_location::current()) -> void
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:22
Defines a generalized method that a value type or class implements to create a type-specific method f...
Definition iequatable.hpp:23
Supports all classes in the xtd class hierarchy and provides low-level services to derived classes....
Definition object.hpp:45
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.
Definition exception_case.hpp:51
#define static_
This keyword is use to represent a static object. A static object can't be instantiated (constructors...
Definition static.hpp:37
xtd::basic_string< char > string
Represents text as a sequence of UTF-8 code units.
Definition __string_definitions.hpp:43
std::int64_t int64
Represents a 64-bit signed integer.
Definition int64.hpp:23
std::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
std::int8_t sbyte
Represents a 8-bit signed integer.
Definition sbyte.hpp:23
std::uint16_t uint16
Represents a 16-bit unsigned integer.
Definition uint16.hpp:23
std::int32_t int32
Represents a 32-bit signed integer.
Definition int32.hpp:23
std::int16_t int16
Represents a 16-bit signed integer.
Definition int16.hpp:23
std::uint64_t uint64
Represents a 64-bit unsigned integer.
Definition uint64.hpp:23
std::uint8_t byte
Represents a 8-bit unsigned integer.
Definition byte.hpp:23
enum_attribute
Specifies the enum attribute.
Definition enum_attribute.hpp:22
std::vector< std::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:24
value_t parse(const std::string &str)
Convert a string into a type.
Definition parse.hpp:34
bool try_parse(const std::basic_string< char > &str, value_t &value) noexcept
Convert a string into a type.
Definition parse.hpp:416
@ flags
Enum flags attribute.
Definition enum_attribute.hpp:26
Contains xtd::icomparable interface.
Contains xtd::iequatable interface.
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition abstract_object.hpp:8
const xtd::collections::generic::helpers::wrap_pointer_iterator< pointer > iterator
Represents the iterator of read_only_span value type.
Definition read_only_span.hpp:74
const_iterator begin() const
Returns an iterator to the beginning.
Definition read_only_span.hpp:183
const_iterator end() const
Returns an iterator to the end.
Definition read_only_span.hpp:213
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:582
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:488
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:424
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:538
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:388
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:508
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:456
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:660
static xtd::string to_string(enum_t value) noexcept
Converts this instance to string.
Definition enum_object.hpp:627
static int16 to_int16(enum_t value) noexcept
Converts this instance to int16.
Definition enum_object.hpp:603
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:450
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:558
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:528
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:397
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:652
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:468
static sbyte to_sbyte(enum_t value) noexcept
Converts this instance to signed byte.
Definition enum_object.hpp:621
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:498
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:462
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:363
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:478
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:569
static xtd::byte to_byte(enum_t value) noexcept
Converts this instance to byte.
Definition enum_object.hpp:597
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:415
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:370
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:575
static int32 to_int32(enum_t value) noexcept
Converts this instance to int32.
Definition enum_object.hpp:609
static uint32 to_uint32(enum_t value) noexcept
Converts this instance to unsigned int32.
Definition enum_object.hpp:639
static int64 to_int64(enum_t value) noexcept
Converts this instance to int64.
Definition enum_object.hpp:615
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:589
static uint16 to_uint16(enum_t value) noexcept
Converts this instance to unsigned int16.
Definition enum_object.hpp:633
static uint64 to_uint64(enum_t value) noexcept
Converts this instance to unsigned int64.
Definition enum_object.hpp:645
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:518
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:406
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:444
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:433
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:379
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:548
Provides the base class for enumerations.
Definition enum_object.hpp:48
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:90
bool equals(const object &obj) const noexcept override
Determines whether the specified object is equal to the current object.
Definition enum_object.hpp:119
int64 to_int64() const noexcept
Converts this instance to int64.
Definition enum_object.hpp:152
uint32 to_uint32() const noexcept
Converts this instance to unsigned int32.
Definition enum_object.hpp:164
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:198
uint16 to_uint16() const noexcept
Converts this instance to unsigned int16.
Definition enum_object.hpp:160
xtd::string to_string(const xtd::string &format, const globalization::culture_info &culture) const override
Converts the value of this instance to its equivalent string representation using the specified forma...
sbyte to_sbyte() const noexcept
Converts this instance to signed byte.
Definition enum_object.hpp:156
enum_t value_type
Represents the enumeration type.
Definition enum_object.hpp:55
xtd::size get_hash_code() const noexcept override
Serves as a hash function for a particular type.
Definition enum_object.hpp:136
xtd::string to_string() const noexcept override
Returns a xtd::string that represents the current object.
Definition enum_object.hpp:172
bool equals(const enum_object &value) const noexcept override
Determines whether the specified object is equal to the current object.
Definition enum_object.hpp:123
static enum_type parse(const xtd::string &str)
Converts the string to its enum_type equivalent.
Definition enum_object.hpp:227
enum_t enum_type
Represents the enumeration type.
Definition enum_object.hpp:53
xtd::byte to_byte() const noexcept
Converts this instance to byte.
Definition enum_object.hpp:140
uint64 to_uint64() const noexcept
Converts this instance to unsigned int64.
Definition enum_object.hpp:168
bool equals(attribute_t value) const noexcept
Indicates whether the current object is equal to another object with defferent type.
Definition enum_object.hpp:132
int32 to_int32() const noexcept
Converts this instance to int32.
Definition enum_object.hpp:148
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:127
enum_type value
Gets or sets the value of the enum.
Definition enum_object.hpp:94
int16 to_int16() const noexcept
Converts this instance to int16.
Definition enum_object.hpp:144
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:110