template<typename enum_t = std::nullptr_t>
class xtd::enum_object< enum_t >
Provides the base class for enumerations.
- Header
#include <xtd/enum_object>
- Namespace
- xtd
- Library
- xtd.core
- Examples
- colored_forms.cpp, 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, form_background_image2.cpp, parse_enum.cpp, parse_enum_class.cpp, parse_enum_struct.cpp, sprintf_enum.cpp, and sprintf_enum_class.cpp.
|
bool | has_flag (enum_type flag) const noexcept |
| Retrieves an array of the values of the constants in a specified enumeration.
|
|
enum_type | value () const noexcept |
| Gets the value of the enum.
|
|
enum_object & | value (enum_type value) |
| Sets the value of the enum.
|
|
|
| object ()=default |
| Create a new instance of the ultimate base class object.
|
|
virtual bool | equals (const object &obj) const noexcept |
| Determines whether the specified object is equal to the current object.
|
|
virtual size_t | get_hash_code () const noexcept |
| Serves as a hash function for a particular type.
|
|
virtual type_object | get_type () const noexcept |
| Gets the type of the current instance.
|
|
template<typename object_t > |
xtd::uptr< object_t > | memberwise_clone () const |
| Creates a shallow copy of the current object.
|
|
virtual int32 | compare_to (const type_t &obj) const noexcept=0 |
| Compares the current instance with another object of the same type.
|
|
virtual bool | equals (const type_t &) const noexcept=0 |
| Indicates whether the current object is equal to another object of the same type.
|
|
template<typename object_a_t , typename object_b_t > |
static bool | equals (const object_a_t &object_a, const object_b_t &object_b) noexcept |
| Determines whether the specified object instances are considered equal.
|
|
template<typename object_a_t , typename object_b_t > |
static bool | reference_equals (const object_a_t &object_a, const object_b_t &object_b) noexcept |
| Determines whether the specified object instances are the same instance.
|
|
◆ 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. |
◆ 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.
◆ 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. |
◆ 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_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.
◆ to_string() [1/3]
template<typename enum_t = std::nullptr_t>
|
inlineoverridevirtualnoexcept |
Returns a xtd::string that represents the current object.
- Returns
- A string that represents the current object.
- Examples
- The following code example demonstrates what to_string returns.
#include <xtd/xtd>
namespace examples {
namespace object_test {
class object1 :
public object {
};
}
}
auto main() -> int {
ptr<object> obj1 = new_ptr<examples::object_test::object1>();
ptr<object> obj2 = new_ptr<date_time>(1971, 1, 5, 23, 5, 0);
}
Supports all classes in the xtd class hierarchy and provides low-level services to derived classes....
Definition object.h:42
xtd::sptr< type_t > ptr
The xtd::ptr object is a shared pointer.
Definition ptr.h:27
Reimplemented from xtd::object.
- Examples
- sprintf_enum.cpp, and sprintf_enum_class.cpp.
◆ to_string() [2/3]
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.
xtd::string to_string() const noexcept override
Returns a xtd::string that represents the current object.
Definition enum_object.h:136
◆ to_string() [3/3]
template<typename enum_t = std::nullptr_t>
Converts the value of this instance to its equivalent string representation using the specified format, and locale.
- Parameters
-
format | A format string. |
loc | An std::locale object that contains locale information (see std::locale). |
- 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.
Implements xtd::iformatable.
The documentation for this class was generated from the following file: