#include <enum.h>
template<typename enum_t = std::nullptr_t>
class xtd::enum_object< enum_t >
Provides the base class for enumerations.
- Namespace
- xtd
- Library
- xtd.core
- Examples:
- enum.cpp, enum_class.cpp, enum_class_flags.cpp, enum_class_flags_introspection.cpp, enum_class_flags_without_helpers.cpp, enum_class_parse.cpp, enum_class_ut.cpp, enum_class_without_helper.cpp, enum_struct.cpp, enum_struct_ut.cpp, enum_ut.cpp, parse_enum.cpp, parse_enum_class.cpp, and parse_enum_struct.cpp.
|
bool | has_flag (enum_type flag) const noexcept |
| Retrieves an array of the values of the constants in a specified enumeration. More...
|
|
enum_type | value () const noexcept |
| Gets the value of the enum. More...
|
|
enum_object & | value (enum_type value) |
| Sets the value of the enum. More...
|
|
|
| object ()=default |
| Create a new instance of the ultimate base class object. More...
|
|
bool | equals (const object &obj) const noexcept |
| Determines whether the specified object is equal to the current object. More...
|
|
virtual size_t | get_hash_code () const noexcept |
| Serves as a hash function for a particular type. More...
|
|
template<typename object_t > |
std::unique_ptr< object_t > | memberwise_clone () const noexcept |
| Gets the type of the current instance. More...
|
|
virtual bool | equals (const enum_object< enum_t > &) const noexcept=0 |
| Indicates whether the current object is equal to another object of the same type. More...
|
|
static bool | equals (const object &object_a, const object &object_b) noexcept |
| Determines whether the specified object instances are considered equal. More...
|
|
static bool | reference_equals (const object &object_a, const object &object_b) noexcept |
| Determines whether the specified object instances are the same instance. More...
|
|
◆ enum_object() [1/2]
template<typename enum_t = std::nullptr_t>
◆ enum_object() [2/2]
template<typename enum_t = std::nullptr_t>
Initializes a new instance of the xtd::enum_object class with specified value.
- Parameters
-
value | Value to set to this instance. |
◆ compare_to()
template<typename enum_t = std::nullptr_t>
|
inlineoverridevirtualnoexcept |
Compares the current instance with another object of the same type.
- Parameters
-
obj | An object to compare with this instance. |
- Returns
- A 32-bit signed integer that indicates the relative order of the objects being compared. The return value has these meanings:
Value | Condition |
Less than zero | This instance is less than obj. |
Zero | This instance is equal to obj. |
Greater than zero | This instance is greater than obj. |
Implements xtd::icomparable< enum_object< enum_t > >.
◆ has_flag()
template<typename enum_t = std::nullptr_t>
Retrieves an array of the values of the constants in a specified enumeration.
- Parameters
-
flag | An enumeration value. |
- Returns
- true if the bit field or bit fields that are set in flag are also set in the current instance; otherwise, false.
◆ to_byte()
template<typename enum_t = std::nullptr_t>
Converts this instance to byte.
- Returns
- A new xtd::byte object converted from this instance.
◆ to_int16()
template<typename enum_t = std::nullptr_t>
Converts this instance to int16.
- Returns
- A new to_int16 object converted from this instance.
◆ to_int32()
template<typename enum_t = std::nullptr_t>
Converts this instance to int32.
- Returns
- A new to_int32 object converted from this instance.
◆ to_int64()
template<typename enum_t = std::nullptr_t>
Converts this instance to int64.
- Returns
- A new to_int64 object converted from this instance.
◆ to_sbyte()
template<typename enum_t = std::nullptr_t>
Converts this instance to signed byte.
- Returns
- A new sbyte object converted from this instance.
◆ to_string() [1/2]
template<typename enum_t = std::nullptr_t>
|
inlineoverridevirtualnoexcept |
Returns a sxd::ustring that represents the current object.
- Returns
- A string that represents the current object.
- Examples
- The following code example demonstrates what to_string returns.
Reimplemented from xtd::object.
◆ to_string() [2/2]
template<typename enum_t = std::nullptr_t>
Converts the value of this instance to its equivalent string representation using the specified format.
- Parameters
-
- Returns
- The string representation of the value of this instance as specified by format.
- Exceptions
-
- Notes to caller
- If multiple enumeration members have the same underlying value and you attempt to retrieve the string representation of an enumeration member's name based on its underlying value, your code should not make any assumptions about which name the method will return. For example, the following enumeration defines two members, shade::gray and shade::grey, that have the same underlying value. The following method call attempts to retrieve the name of a member of the shade enumeration whose underlying value is 1. The method can return either "gray" or "grey", and your code should not make any assumptions about which string will be returned.
ustring shade_name = enum_object<shade>(as<shade>(1)).to_string("F");
◆ to_uint16()
template<typename enum_t = std::nullptr_t>
Converts this instance to unsigned int16.
- Returns
- A new to_uint16 object converted from this instance.
◆ to_uint32()
template<typename enum_t = std::nullptr_t>
Converts this instance to unsigned int32.
- Returns
- A new to_uint32 object converted from this instance.
◆ to_uint64()
template<typename enum_t = std::nullptr_t>
Converts this instance to unsigned int64.
- Returns
- A new to_uint64 object converted from this instance.
◆ value() [1/2]
template<typename enum_t = std::nullptr_t>
Gets the value of the enum.
- Returns
- The value of the enum.
◆ value() [2/2]
template<typename enum_t = std::nullptr_t>
Sets the value of the enum.
- Parameters
-
value | The value of the enum. |
The documentation for this class was generated from the following file: