41  template<
typename enum_t = std::
nullptr_t>
 
   47    using enum_type = enum_t;
 
   72    operator enum_type() const noexcept {
return value_;}
 
   82    bool has_flag(enum_type flag) 
const noexcept {
return (to_int(value_) & to_int(flag)) == to_int(flag);}
 
   86    enum_type 
value() const noexcept {
return value_;}
 
   99      if (to_int(value_) == to_int(
value.value_)) 
return 0;
 
  100      if (to_int(value_) < to_int(
value.value_)) 
return -1;
 
  140      auto iterator = std::find_if(entries().begin(), entries().
end(), [&](
auto value)->
bool {
return value.first == value_;});
 
  143      return iterator->second;
 
  188    template<
typename attribute_t>
 
  189    bool equals(attribute_t 
value) 
const noexcept {
return false;}
 
  193      enum_object<enum_type>().init();
 
  196      for (
auto item : 
enum_object<enum_type>().entries()) {
 
  198          return static_cast<enum_type
>(item.first);
 
  201      return to_enum(xtd::parse<int64>(str));
 
  205      std::vector<xtd::string> values = 
value.split(
',');
 
  209      if (values.size() == 1) {
 
  210        for (
auto item : 
enum_object<enum_type>().entries()) {
 
  212            return to_enum(item.first);
 
  214        return to_enum(xtd::parse<int64>(
value));
 
  220        for (
auto item : 
enum_object<enum_type>().entries()) {
 
  223            result |= to_int(item.first);
 
  231      return to_enum(result);
 
  239      auto iterator = std::find_if(entries().begin(), entries().
end(), [&](
auto value)->
bool {
return value.first == value_;});
 
  241      return iterator->second;
 
  245      auto iterator = std::find_if(entries().begin(), entries().
end(), [&](
auto value)->
bool {
return value.first == value_;});
 
  246      if (to_int(value_) == 0 && iterator == entries().
end()) 
return "0";
 
  248      iterator = std::find_if(entries().begin(), entries().
end(), [&](
auto value)->
bool {
return value.first == to_enum(0);});
 
  249      if (to_int(value_) == 0) 
return iterator == entries().end() ? 
"0" : iterator->second;
 
  252      int64 rest = to_int(value_);
 
  253      enum_collection<enum_type> reversed_entries = entries();
 
  254      std::reverse(reversed_entries.begin(), reversed_entries.end());
 
  256      for (
auto item : reversed_entries) {
 
  257        if (to_int(item.first) != 0 && (rest & to_int(item.first)) == to_int(item.first)) {
 
  258          rest -= to_int(item.first);
 
  260          str = item.second + str;
 
  269    template<
typename attribute_t>
 
  270    static enum_type to_enum(attribute_t 
value) 
noexcept {
return static_cast<enum_type
>(
value);}
 
  274      if (attribute_.has_value()) 
return attribute_.value();
 
  276      return attribute_.value();
 
  279    static enum_collection<enum_type>& entries() noexcept {
 
  280      if (entries_.has_value()) 
return entries_.value();
 
  281      entries_ = enum_collection<enum_type>(enum_register<enum_type>());
 
  282      return entries_.value();
 
  285    static void init() noexcept {
 
  290    inline static std::optional<xtd::enum_attribute> attribute_;
 
  291    inline static std::optional<enum_collection<enum_type>> entries_;
 
  313    template<
typename enum_t>
 
  320    template<
typename enum_t>
 
  329    template<
typename enum_t>
 
  338    template<
typename enum_t>
 
  347    template<
typename enum_t>
 
  356    template<
typename enum_t>
 
  365    template<
typename enum_t>
 
  374    template<
typename enum_t>
 
  383    template<
typename enum_t>
 
  394    template<
typename enum_t>
 
  400    template<
typename enum_t>
 
  406    template<
typename enum_t>
 
  412    template<
typename enum_t>
 
  418    template<
typename enum_t>
 
  420      std::vector<xtd::string> names;
 
  428    template<
typename enum_t>
 
  430      std::vector<enum_t> values;
 
  438    template<
typename enum_t>
 
  440      std::vector<xtd::byte> values;
 
  448    template<
typename enum_t>
 
  450      std::vector<int16> values;
 
  458    template<
typename enum_t>
 
  460      std::vector<int32> values;
 
  468    template<
typename enum_t>
 
  470      std::vector<int64> values;
 
  478    template<
typename enum_t>
 
  480      std::vector<sbyte> values;
 
  488    template<
typename enum_t>
 
  490      std::vector<uint16> values;
 
  498    template<
typename enum_t>
 
  500      std::vector<uint32> values;
 
  508    template<
typename enum_t>
 
  510      std::vector<uint64> values;
 
  519    template<
typename enum_t>
 
  525    template<
typename enum_t>
 
  532    template<
typename enum_t>
 
  539    template<
typename enum_t>
 
  547    template<
typename enum_t>
 
  553    template<
typename enum_t>
 
  559    template<
typename enum_t>
 
  565    template<
typename enum_t>
 
  571    template<
typename enum_t>
 
  577    template<
typename enum_t>
 
  583    template<
typename enum_t>
 
  589    template<
typename enum_t>
 
  595    template<
typename enum_t>
 
  602    template<
typename enum_t>
 
  610    template<
typename enum_t>
 
  613        result = parse<enum_t>(
value, ignore_case);
 
  624  template<
typename enum_t>
 
  628    if (fmt.empty()) fmt = 
"G";
 
  638      case 'X': 
return __numeric_formatter(fmt.chars(), 
static_cast<long long int>(value_), std::locale());
 
  644    throw format_exception(
"Invalid format"_t);
 
  650template<
typename enum_t>
 
  651inline std::string __enum_to_string(enum_t value) 
noexcept {
 
  655template<
typename value_t>
 
  656value_t __parse_enum(
const std::string& str) {
 
Represents the base class for custom attributes.
Definition attribute.hpp:25
 
Represents text as a sequence of character units.
Definition basic_string.hpp:79
 
bool is_empty() const noexcept
Indicates whether this basic_string is an empty basic_string ("").
Definition basic_string.hpp:1511
 
int32 compare(const basic_string &str) const
Compares two character sequences.
Definition basic_string.hpp:963
 
bool empty() const noexcept
Checks if the string has no characters, i.e. whether begin() == end().
Definition basic_string.hpp:904
 
static std::vector< int64 > get_values_as_int64() noexcept
Retrieves an array of the values of the constants in a specified enumeration.
Definition enum_object.hpp:469
 
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:533
 
static xtd::enum_collection< uint32 > get_entries_as_uint32() noexcept
Retrieves an array of the xtd::collections::generic::key_value_pair<uint32, xtd::string> of the const...
Definition enum_object.hpp:375
 
static xtd::enum_collection< int32 > get_entries_as_int32() noexcept
Retrieves an array of the xtd::collections::generic::key_value_pair<int32, xtd::string> of the consta...
Definition enum_object.hpp:339
 
static std::vector< uint16 > get_values_as_uint16() noexcept
Retrieves an array of the values of the constants in a specified enumeration.
Definition enum_object.hpp:489
 
static std::vector< int32 > get_values_as_int32() noexcept
Retrieves an array of the values of the constants in a specified enumeration.
Definition enum_object.hpp:459
 
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:407
 
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:611
 
static xtd::string to_string(enum_t value) noexcept
Converts this instance to string.
Definition enum_object.hpp:578
 
static int16 to_int16(enum_t value) noexcept
Converts this instance to int16.
Definition enum_object.hpp:554
 
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:401
 
static xtd::enum_collection< int64 > get_entries_as_int64() noexcept
Retrieves an array of the xtd::collections::generic::key_value_pair<int64, xtd::string> of the consta...
Definition enum_object.hpp:348
 
static std::vector< int16 > get_values_as_int16() noexcept
Retrieves an array of the values of the constants in a specified enumeration.
Definition enum_object.hpp:449
 
static std::vector< sbyte > get_values_as_sbyte() noexcept
Retrieves an array of the values of the constants in a specified enumeration.
Definition enum_object.hpp:479
 
static std::vector< xtd::string > get_names() noexcept
Retrieves an array of the names of the constants in a specified enumeration.
Definition enum_object.hpp:419
 
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:603
 
static std::vector< uint32 > get_values_as_uint32() noexcept
Retrieves an array of the values of the constants in a specified enumeration.
Definition enum_object.hpp:499
 
static std::vector< enum_t > get_values() noexcept
Retrieves an array of the values of the constants in a specified enumeration.
Definition enum_object.hpp:429
 
static sbyte to_sbyte(enum_t value) noexcept
Converts this instance to signed byte.
Definition enum_object.hpp:572
 
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:413
 
static const xtd::enum_collection< enum_t > & get_entries() noexcept
Retrieves an array of the xtd::collections::generic::key_value_pair<enum_t, xtd::string> of the const...
Definition enum_object.hpp:314
 
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:520
 
static std::vector< uint64 > get_values_as_uint64() noexcept
Retrieves an array of the values of the constants in a specified enumeration.
Definition enum_object.hpp:509
 
static xtd::byte to_byte(enum_t value) noexcept
Converts this instance to byte.
Definition enum_object.hpp:548
 
static xtd::enum_collection< uint16 > get_entries_as_uint16() noexcept
Retrieves an array of the xtd::collections::generic::key_value_pair<uint16, xtd::string> of the const...
Definition enum_object.hpp:366
 
static xtd::enum_collection< xtd::byte > get_entries_as_byte() noexcept
Retrieves an array of the xtd::collections::generic::key_value_pair<xtd::byte, xtd::string> of the co...
Definition enum_object.hpp:321
 
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:526
 
static int32 to_int32(enum_t value) noexcept
Converts this instance to int32.
Definition enum_object.hpp:560
 
static uint32 to_uint32(enum_t value) noexcept
Converts this instance to unsigned int32.
Definition enum_object.hpp:590
 
static int64 to_int64(enum_t value) noexcept
Converts this instance to int64.
Definition enum_object.hpp:566
 
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:540
 
static std::vector< xtd::byte > get_values_as_byte() noexcept
Retrieves an array of the values of the constants in a specified enumeration.
Definition enum_object.hpp:439
 
static uint16 to_uint16(enum_t value) noexcept
Converts this instance to unsigned int16.
Definition enum_object.hpp:584
 
static uint64 to_uint64(enum_t value) noexcept
Converts this instance to unsigned int64.
Definition enum_object.hpp:596
 
static xtd::enum_collection< sbyte > get_entries_as_sbyte() noexcept
Retrieves an array of the xtd::collections::generic::key_value_pair<sbyte, xtd::string> of the consta...
Definition enum_object.hpp:357
 
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:395
 
static xtd::enum_collection< uint64 > get_entries_as_uint64() noexcept
Retrieves an array of the xtd::collections::generic::key_value_pair<uint64, xtd::string> of the const...
Definition enum_object.hpp:384
 
static xtd::enum_collection< int16 > get_entries_as_int16() noexcept
Retrieves an array of the xtd::collections::generic::key_value_pair<int16, xtd::string> of the consta...
Definition enum_object.hpp:330
 
Provides the base class for enumerations.
Definition enum_object.hpp:42
 
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:82
 
int64 to_int64() const noexcept
Converts this instance to int64.
Definition enum_object.hpp:118
 
uint32 to_uint32() const noexcept
Converts this instance to unsigned int32.
Definition enum_object.hpp:130
 
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:162
 
uint16 to_uint16() const noexcept
Converts this instance to unsigned int16.
Definition enum_object.hpp:126
 
enum_type value() const noexcept
Gets the value of the enum.
Definition enum_object.hpp:86
 
sbyte to_sbyte() const noexcept
Converts this instance to signed byte.
Definition enum_object.hpp:122
 
xtd::string to_string() const noexcept override
Returns a xtd::string that represents the current object.
Definition enum_object.hpp:136
 
enum_object & value(enum_type value)
Sets the value of the enum.
Definition enum_object.hpp:89
 
xtd::byte to_byte() const noexcept
Converts this instance to byte.
Definition enum_object.hpp:106
 
uint64 to_uint64() const noexcept
Converts this instance to unsigned int64.
Definition enum_object.hpp:134
 
int32 to_int32() const noexcept
Converts this instance to int32.
Definition enum_object.hpp:114
 
enum_object() noexcept=default
Initializes a new instance of the xtd::enum_object class.
 
int16 to_int16() const noexcept
Converts this instance to int16.
Definition enum_object.hpp:110
 
xtd::string to_string(const xtd::string &format, const std::locale &loc) const override
Converts the value of this instance to its equivalent string representation using the specified forma...
 
Defines a generalized comparison method that a value type or class implements to create a type-specif...
Definition icomparable.hpp:21
 
Defines a generalized method that a value type or class implements to create a type-specific method f...
Definition iequatable.hpp:22
 
virtual bool equals(const type_t &) const noexcept=0
Indicates whether the current object is equal to another object of the same type.
 
Supports all classes in the xtd class hierarchy and provides low-level services to derived classes....
Definition object.hpp:42
 
virtual bool equals(const object &obj) const noexcept
Determines whether the specified object is equal to the current object.
 
Contains xtd::enum_attribute enum class.
 
Contains xtd::enum_collection.
 
Contains xtd::enum_register.
 
Contains xtd::enum_set_attribute strcut.
 
#define static_
This keyword is use to represent a static object. A static object can't be instantiated (constructors...
Definition static.hpp:37
 
int16_t int16
Represents a 16-bit signed integer.
Definition int16.hpp:23
 
int32_t int32
Represents a 32-bit signed integer.
Definition int32.hpp:23
 
int64_t int64
Represents a 64-bit signed integer.
Definition int64.hpp:23
 
int8_t sbyte
Represents a 8-bit signed integer.
Definition sbyte.hpp:23
 
uint32_t uint32
Represents a 32-bit unsigned integer.
Definition uint32.hpp:23
 
uint64_t uint64
Represents a 64-bit unsigned integer.
Definition uint64.hpp:23
 
uint8_t byte
Represents a 8-bit unsigned integer.
Definition byte.hpp:23
 
uint16_t uint16
Represents a 16-bit unsigned integer.
Definition uint16.hpp:23
 
enum_attribute
Specifies the enum attribute.
Definition enum_attribute.hpp:22
 
std::vector< xtd::collections::generic::key_value_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:22
 
value_t parse(const std::string &str)
Convert a string into a type.
Definition parse.hpp:34
 
@ flags
Enum flags attribute.
 
Contains xtd::icomparable interface.
 
Contains xtd::iequatable interface.
 
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition xtd_about_box.hpp:10
 
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.