47 template<
typename enum_t = std::
nullptr_t>
90 [[nodiscard]]
auto has_flag(
enum_type flag)
const noexcept ->
bool {
return (to_int(
value) & to_int(flag)) == to_int(flag);}
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<
typename attribute_t>
132 [[nodiscard]]
auto equals(attribute_t
value)
const noexcept ->
bool {
return false;}
172 [[nodiscard]]
auto to_string() const noexcept ->
xtd::
string override {
241 friend auto operator << (std::ostream& os,
const enum_object&
value) -> std::ostream& {
return os <<
value.to_string();}
247 [[nodiscard]] auto get_name() const noexcept ->
xtd::string {
254 auto values =
value.split(
',');
255 for (
auto& str : values)
258 if (values.length() == 1) {
265 for (
const auto& str : values) {
270 result |= to_int(item.first);
276 return to_enum(result);
279 [[nodiscard]]
auto to_string_flags() const noexcept -> xtd::
string {
287 auto rest = to_int(
value);
288 auto reversed_entries = entries();
289 std::reverse(reversed_entries.begin(), reversed_entries.end());
291 for (
auto item : reversed_entries) {
292 if (to_int(item.first) != 0 && (rest & to_int(item.first)) == to_int(item.first)) {
293 rest -= to_int(item.first);
295 str = item.second + str;
303 template<
typename attribute_t>
308 [[nodiscard]]
static auto attribute() noexcept -> xtd::
enum_attribute {
309 if (attribute_.has_value())
return attribute_.value();
311 return attribute_.value();
315 if (entries_.has_value())
return entries_.value();
317 return entries_.value();
320 static auto init() noexcept ->
void {
321 [[maybe_unused]]
auto a = attribute();
322 [[maybe_unused]]
auto e = entries();
325 inline static std::optional<xtd::enum_attribute> attribute_;
326 inline static std::optional<enum_collection<enum_type>> entries_;
352 template<
class enum_t>
359 template<
class enum_t>
368 template<
class enum_t>
377 template<
class enum_t>
386 template<
class enum_t>
395 template<
class enum_t>
404 template<
class enum_t>
413 template<
class enum_t>
422 template<
class enum_t>
433 template<
class enum_t>
439 template<
class enum_t>
445 template<
class enum_t>
451 template<
class enum_t>
457 template<
class enum_t>
467 template<
class enum_t>
477 template<
class enum_t>
487 template<
class enum_t>
497 template<
class enum_t>
507 template<
class enum_t>
517 template<
class enum_t>
527 template<
class enum_t>
537 template<
class enum_t>
547 template<
class enum_t>
558 template<
class enum_t>
564 template<
class enum_t>
571 template<
class enum_t>
578 template<
class enum_t>
586 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>
641 template<
class enum_t>
649 template<
class enum_t>
664template<
class enum_t>
665[[nodiscard]]
inline auto __enum_to_string__(enum_t value)
noexcept -> std::string {
669template<
class value_t>
670[[nodiscard]]
inline auto __parse_enum(
const std::string& str) -> value_t {
Contains xtd::array class.
Provides methods for creating, manipulating, searching, and sorting arrays, thereby serving as the ba...
Definition array.hpp:64
Represents the base class for custom attributes.
Definition attribute.hpp:25
static const basic_string empty_string
Definition basic_string.hpp:111
static auto compare(const basic_string &str_a, const basic_string &str_b) noexcept -> xtd::int32
Definition basic_string.hpp:1018
static auto is_empty(const xtd::basic_string< value_type, traits_type, allocator_type > &string) noexcept -> bool
Definition basic_string.hpp:1246
Provides information about a specific culture (called a locale for unmanaged code development)....
Definition culture_info.hpp:43
static xtd::usize 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:38
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
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:25
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::size_t usize
Represents an unsigned size of any object in bytes.
Definition usize.hpp:22
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
@ a
The A key.
Definition console_key.hpp:88
@ e
The E key.
Definition console_key.hpp:96
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 auto get_name(enum_t value) noexcept -> xtd::string
Retrieves the name of the constant in the specified enumeration that has the specified value.
Definition enum_object.hpp:434
static auto parse(const xtd::string &value) -> enum_t
Converts the xtd::string representation of the name or numeric value of one or more enumerated consta...
Definition enum_object.hpp:572
static auto get_values_as_int16() noexcept -> xtd::array< xtd::int16 >
Retrieves an array of the values of the constants in a specified enumeration.
Definition enum_object.hpp:488
static auto parse(const xtd::string &str, bool ignore_case) -> enum_t
Converts the xtd::string representation of the name or numeric value of one or more enumerated consta...
Definition enum_object.hpp:579
static auto to_int16(enum_t value) noexcept -> xtd::int16
Converts this instance to int16.
Definition enum_object.hpp:593
static auto try_parse(const xtd::string &value, enum_t &result) noexcept -> bool
Converts the xtd::string representation of the name or numeric value of one or more enumerated consta...
Definition enum_object.hpp:642
static auto get_name(enum_object< enum_t > value) noexcept -> xtd::string
Retrieves the name of the constant in the specified enumeration that has the specified value.
Definition enum_object.hpp:440
static auto get_entries_as_uint16() noexcept -> xtd::enum_collection< xtd::uint16 >
Retrieves an array of the xtd::enum_collection<uint16> of the constants in a specified enumeration.
Definition enum_object.hpp:405
static auto get_entries_as_uint64() noexcept -> xtd::enum_collection< xtd::uint64 >
Retrieves an array of the xtd::enum_collection<uint64> of the constants in a specified enumeration.
Definition enum_object.hpp:423
static auto get_name(int64 value) noexcept -> xtd::string
Retrieves the name of the constant in the specified enumeration that has the specified value.
Definition enum_object.hpp:452
static auto get_values_as_byte() noexcept -> xtd::array< xtd::byte >
Retrieves an array of the values of the constants in a specified enumeration.
Definition enum_object.hpp:478
static auto get_entries_as_int16() noexcept -> xtd::enum_collection< xtd::int16 >
Retrieves an array of the xtd::enum_collection<int16> of the constants in a specified enumeration.
Definition enum_object.hpp:369
static auto get_values_as_int64() noexcept -> xtd::array< xtd::int64 >
Retrieves an array of the values of the constants in a specified enumeration.
Definition enum_object.hpp:508
static auto get_values() noexcept -> xtd::array< enum_t >
Retrieves an array of the values of the constants in a specified enumeration.
Definition enum_object.hpp:468
static auto get_values_as_int32() noexcept -> xtd::array< xtd::int32 >
Retrieves an array of the values of the constants in a specified enumeration.
Definition enum_object.hpp:498
static auto is_defined(enum_object< enum_t >value) noexcept -> bool
Returns an indication whether a constant with a specified value exists in a specified enumeration.
Definition enum_object.hpp:565
static auto get_entries_as_int64() noexcept -> xtd::enum_collection< xtd::int64 >
Retrieves an array of the xtd::enum_collection<int64> of the constants in a specified enumeration.
Definition enum_object.hpp:387
static auto get_entries_as_sbyte() noexcept -> xtd::enum_collection< xtd::sbyte >
Retrieves an array of the xtd::enum_collection<sbyte> of the constants in a specified enumeration.
Definition enum_object.hpp:396
static auto get_values_as_uint32() noexcept -> xtd::array< xtd::uint32 >
Retrieves an array of the values of the constants in a specified enumeration.
Definition enum_object.hpp:538
static auto try_parse(const xtd::string &value, bool ignore_case, enum_t &result) noexcept -> bool
Converts the xtd::string representation of the name or numeric value of one or more enumerated consta...
Definition enum_object.hpp:650
static auto get_entries_as_int32() noexcept -> xtd::enum_collection< xtd::int32 >
Retrieves an array of the xtd::enum_collection<int32> of the constants in a specified enumeration.
Definition enum_object.hpp:378
static auto get_name(int32 value) noexcept -> xtd::string
Retrieves the name of the constant in the specified enumeration that has the specified value.
Definition enum_object.hpp:446
static auto get_entries() noexcept -> const xtd::enum_collection< enum_t > &
Retrieves an array of the xtd::enum_collection<enum_t> of the constants in a specified enumeration.
Definition enum_object.hpp:353
static auto get_values_as_uint64() noexcept -> xtd::array< xtd::uint64 >
Retrieves an array of the values of the constants in a specified enumeration.
Definition enum_object.hpp:548
static auto to_uint32(enum_t value) noexcept -> xtd::uint32
Converts this instance to unsigned int32.
Definition enum_object.hpp:629
static auto get_names() noexcept -> xtd::array< xtd::string >
Retrieves an array of the names of the constants in a specified enumeration.
Definition enum_object.hpp:458
static auto to_string(enum_t value) noexcept -> xtd::string
Converts this instance to string.
Definition enum_object.hpp:617
static auto to_uint16(enum_t value) noexcept -> xtd::uint16
Converts this instance to unsigned int16.
Definition enum_object.hpp:623
static auto get_entries_as_byte() noexcept -> xtd::enum_collection< xtd::byte >
Retrieves an array of the xtd::enum_collection<xtd::byte> of the constants in a specified enumeration...
Definition enum_object.hpp:360
static auto to_sbyte(enum_t value) noexcept -> xtd::sbyte
Converts this instance to signed byte.
Definition enum_object.hpp:611
static auto get_entries_as_uint32() noexcept -> xtd::enum_collection< xtd::uint32 >
Retrieves an array of the xtd::enum_collection<uint32> of the constants in a specified enumeration.
Definition enum_object.hpp:414
static auto to_int32(enum_t value) noexcept -> xtd::int32
Converts this instance to int32.
Definition enum_object.hpp:599
static auto is_defined(enum_t value) noexcept -> bool
Returns an indication whether a constant with a specified value exists in a specified enumeration.
Definition enum_object.hpp:559
static auto get_values_as_uint16() noexcept -> xtd::array< xtd::uint16 >
Retrieves an array of the values of the constants in a specified enumeration.
Definition enum_object.hpp:528
static auto get_values_as_sbyte() noexcept -> xtd::array< xtd::sbyte >
Retrieves an array of the values of the constants in a specified enumeration.
Definition enum_object.hpp:518
static auto to_byte(enum_t value) noexcept -> xtd::byte
Converts this instance to byte.
Definition enum_object.hpp:587
static auto to_uint64(enum_t value) noexcept -> xtd::uint64
Converts this instance to unsigned int64.
Definition enum_object.hpp:635
static auto to_int64(enum_t value) noexcept -> xtd::int64
Converts this instance to int64.
Definition enum_object.hpp:605
Provides the base class for enumerations.
Definition enum_object.hpp:48
auto equals(const object &obj) const noexcept -> bool override
Determines whether the specified object is equal to the current object.
Definition enum_object.hpp:119
auto to_int16() const noexcept -> xtd::int16
Converts this instance to int16.
Definition enum_object.hpp:144
auto to_sbyte() const noexcept -> xtd::sbyte
Converts this instance to signed byte.
Definition enum_object.hpp:156
auto to_byte() const noexcept -> xtd::byte
Converts this instance to byte.
Definition enum_object.hpp:140
auto equals(attribute_t value) const noexcept -> bool
Indicates whether the current object is equal to another object with defferent type.
Definition enum_object.hpp:132
auto equals(enum_type value) const noexcept -> bool
Indicates whether the current object is equal to another object of the same type.
Definition enum_object.hpp:127
auto to_uint16() const noexcept -> xtd::uint16
Converts this instance to unsigned int16.
Definition enum_object.hpp:160
auto get_hash_code() const noexcept -> xtd::usize override
Serves as a hash function for a particular type.
Definition enum_object.hpp:136
auto to_int32() const noexcept -> xtd::int32
Converts this instance to int32.
Definition enum_object.hpp:148
auto to_uint64() const noexcept -> xtd::uint64
Converts this instance to unsigned int64.
Definition enum_object.hpp:168
enum_t value_type
Represents the enumeration type.
Definition enum_object.hpp:55
auto to_string(const xtd::string &format) const -> xtd::string
Converts the value of this instance to its equivalent string representation using the specified forma...
Definition enum_object.hpp:196
auto to_int64() const noexcept -> xtd::int64
Converts this instance to int64.
Definition enum_object.hpp:152
auto to_uint32() const noexcept -> xtd::uint32
Converts this instance to unsigned int32.
Definition enum_object.hpp:164
auto to_string(const xtd::string &format, const globalization::culture_info &culture) const -> xtd::string override
Converts the value of this instance to its equivalent string representation using the specified forma...
auto has_flag(enum_type flag) const noexcept -> bool
Retrieves an array of the values of the constants in a specified enumeration.
Definition enum_object.hpp:90
enum_t enum_type
Represents the enumeration type.
Definition enum_object.hpp:53
auto compare_to(const enum_object &value) const noexcept -> xtd::int32 override
Compares the current instance with another object of the same type.
Definition enum_object.hpp:110
auto equals(const enum_object &value) const noexcept -> bool override
Determines whether the specified object is equal to the current object.
Definition enum_object.hpp:123
static auto parse(const xtd::string &str) -> enum_type
Converts the string to its enum_type equivalent.
Definition enum_object.hpp:225
enum_object() noexcept=default
Initializes a new instance of the xtd::enum_object class.
enum_type value
Gets or sets the value of the enum.
Definition enum_object.hpp:94
auto to_string() const noexcept -> xtd::string override
Returns a xtd::string that represents the current object.
Definition enum_object.hpp:172