46 template<
typename enum_t = std::
nullptr_t>
89 [[nodiscard]]
auto has_flag(
enum_type flag)
const noexcept ->
bool {
return (to_int(
value) & to_int(flag)) == to_int(flag);}
110 if (to_int(this->value) == to_int(
value.value))
return 0;
111 if (to_int(this->value) < to_int(
value.value))
return -1;
130 template<
typename attribute_t>
131 [[nodiscard]]
auto equals(attribute_t
value)
const noexcept ->
bool {
return false;}
171 [[nodiscard]]
auto to_string() const noexcept ->
xtd::
string override {
240 friend auto operator << (std::ostream& os,
const enum_object&
value) -> std::ostream& {
return os <<
value.to_string();}
246 [[nodiscard]] auto get_name() const noexcept ->
xtd::string {
253 auto values =
value.split(
',');
254 for (
auto& str : values)
257 if (values.length() == 1) {
264 for (
const auto& str : values) {
269 result |= to_int(item.first);
275 return to_enum(result);
278 [[nodiscard]]
auto to_string_flags() const noexcept -> xtd::
string {
286 auto rest = to_int(
value);
287 auto reversed_entries = entries();
288 std::reverse(reversed_entries.begin(), reversed_entries.end());
290 for (
auto item : reversed_entries) {
291 if (to_int(item.first) != 0 && (rest & to_int(item.first)) == to_int(item.first)) {
292 rest -= to_int(item.first);
294 str = item.second + str;
302 template<
typename attribute_t>
307 [[nodiscard]]
static auto attribute() noexcept -> xtd::
enum_attribute {
308 if (attribute_.has_value())
return attribute_.value();
310 return attribute_.value();
314 if (entries_.has_value())
return entries_.value();
316 return entries_.value();
319 static auto init() noexcept ->
void {
320 [[maybe_unused]]
auto a = attribute();
321 [[maybe_unused]]
auto e = entries();
324 inline static std::optional<xtd::enum_attribute> attribute_;
325 inline static std::optional<enum_collection<enum_type>> entries_;
351 template<
class enum_t>
358 template<
class enum_t>
367 template<
class enum_t>
376 template<
class enum_t>
385 template<
class enum_t>
394 template<
class enum_t>
403 template<
class enum_t>
412 template<
class enum_t>
421 template<
class enum_t>
432 template<
class enum_t>
438 template<
class enum_t>
444 template<
class enum_t>
450 template<
class enum_t>
456 template<
class enum_t>
466 template<
class enum_t>
476 template<
class enum_t>
486 template<
class enum_t>
496 template<
class enum_t>
506 template<
class enum_t>
516 template<
class enum_t>
526 template<
class enum_t>
536 template<
class enum_t>
546 template<
class enum_t>
557 template<
class enum_t>
563 template<
class enum_t>
570 template<
class enum_t>
577 template<
class enum_t>
585 template<
class enum_t>
591 template<
class enum_t>
597 template<
class enum_t>
603 template<
class enum_t>
609 template<
class enum_t>
615 template<
class enum_t>
621 template<
class enum_t>
627 template<
class enum_t>
633 template<
class enum_t>
640 template<
class enum_t>
648 template<
class enum_t>
663template<
class enum_t>
664[[nodiscard]]
inline auto __enum_to_string__(enum_t value)
noexcept -> std::string {
668template<
class value_t>
669[[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:1021
static auto is_empty(const xtd::basic_string< value_type, traits_type, allocator_type > &string) noexcept -> bool
Definition basic_string.hpp:1249
Provides information about a specific culture (called a locale for unmanaged code development)....
Definition culture_info.hpp:42
static auto combine(args_t... values) noexcept -> xtd::usize
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
auto try_parse(const std::basic_string< char > &str, value_t &value) noexcept -> bool
Convert a string into a type.
Definition parse.hpp:416
auto parse(const std::string &str) -> value_t
Convert a string into a type.
Definition parse.hpp:34
@ 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:71
auto begin() const -> const_iterator
Returns an iterator to the beginning.
Definition read_only_span.hpp:186
auto end() const -> const_iterator
Returns an iterator to the end.
Definition read_only_span.hpp:205
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:433
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:571
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:487
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:578
static auto to_int16(enum_t value) noexcept -> xtd::int16
Converts this instance to int16.
Definition enum_object.hpp:592
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:641
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:439
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:404
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:422
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:451
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:477
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:368
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:507
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:467
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:497
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:564
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:386
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:395
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:537
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:649
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:377
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:445
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:352
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:547
static auto to_uint32(enum_t value) noexcept -> xtd::uint32
Converts this instance to unsigned int32.
Definition enum_object.hpp:628
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:457
static auto to_string(enum_t value) noexcept -> xtd::string
Converts this instance to string.
Definition enum_object.hpp:616
static auto to_uint16(enum_t value) noexcept -> xtd::uint16
Converts this instance to unsigned int16.
Definition enum_object.hpp:622
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:359
static auto to_sbyte(enum_t value) noexcept -> xtd::sbyte
Converts this instance to signed byte.
Definition enum_object.hpp:610
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:413
static auto to_int32(enum_t value) noexcept -> xtd::int32
Converts this instance to int32.
Definition enum_object.hpp:598
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:558
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:527
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:517
static auto to_byte(enum_t value) noexcept -> xtd::byte
Converts this instance to byte.
Definition enum_object.hpp:586
static auto to_uint64(enum_t value) noexcept -> xtd::uint64
Converts this instance to unsigned int64.
Definition enum_object.hpp:634
static auto to_int64(enum_t value) noexcept -> xtd::int64
Converts this instance to int64.
Definition enum_object.hpp:604
Provides the base class for enumerations.
Definition enum_object.hpp:47
auto equals(const object &obj) const noexcept -> bool override
Determines whether the specified object is equal to the current object.
Definition enum_object.hpp:118
auto to_int16() const noexcept -> xtd::int16
Converts this instance to int16.
Definition enum_object.hpp:143
auto to_sbyte() const noexcept -> xtd::sbyte
Converts this instance to signed byte.
Definition enum_object.hpp:155
auto to_byte() const noexcept -> xtd::byte
Converts this instance to byte.
Definition enum_object.hpp:139
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:131
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:126
auto to_uint16() const noexcept -> xtd::uint16
Converts this instance to unsigned int16.
Definition enum_object.hpp:159
auto get_hash_code() const noexcept -> xtd::usize override
Serves as a hash function for a particular type.
Definition enum_object.hpp:135
auto to_int32() const noexcept -> xtd::int32
Converts this instance to int32.
Definition enum_object.hpp:147
auto to_uint64() const noexcept -> xtd::uint64
Converts this instance to unsigned int64.
Definition enum_object.hpp:167
enum_t value_type
Represents the enumeration type.
Definition enum_object.hpp:54
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:195
auto to_int64() const noexcept -> xtd::int64
Converts this instance to int64.
Definition enum_object.hpp:151
auto to_uint32() const noexcept -> xtd::uint32
Converts this instance to unsigned int32.
Definition enum_object.hpp:163
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:89
enum_t enum_type
Represents the enumeration type.
Definition enum_object.hpp:52
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:109
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:122
static auto parse(const xtd::string &str) -> enum_type
Converts the string to its enum_type equivalent.
Definition enum_object.hpp:224
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:93
auto to_string() const noexcept -> xtd::string override
Returns a xtd::string that represents the current object.
Definition enum_object.hpp:171
static auto values() noexcept
Definition enum_register.hpp:55
static auto attribute() noexcept
Definition enum_set_attribute.hpp:55