5#if !defined(__XTD_CORE_INTERNAL__)
6#error "Do not include this file: Internal use only"
10#include "../format_exception.h"
13#include "../enum_collection.h"
16template<
typename enum_t>
19 #if !defined(__XTD_DO_NOT_USE_ENUMERATION_INTROSPECTION__)
20 for (
size_t num_state = 0; num_state < __enumeration_introspection::num_states<enum_t>; ++num_state)
21 entries.emplace_back(
static_cast<enum_t
>(__enumeration_introspection::enum_values<enum_t>[num_state]), __enumeration_introspection::enum_names<enum_t>[num_state]);
24 if (enum_definition.
empty())
return entries;
26 for (
auto entry : enum_definition.split({
','})) {
27 auto key_value = entry.trim().split({
'='});
28 if (key_value.size() < 1 || key_value.size() > 2 || (key_value.size() == 2 &&
xtd::string::is_empty(key_value[1])))
31 if (key_value.size() == 2) {
33 auto iterator = std::find_if(entries.begin(), entries.end(), [&](
auto item)->bool {return item.second == key_value[1].trim();});
34 if (iterator != entries.end()) value =
static_cast<xtd::int64>(iterator->first);
40 current_value = value;
41 entries.emplace_back(
static_cast<enum_t
>(value), key_value[0].trim());
Represents text as a sequence of character units.
Definition basic_string.h:79
bool is_empty() const noexcept
Indicates whether this basic_string is an empty basic_string ("").
Definition basic_string.h:1511
bool empty() const noexcept
Checks if the string has no characters, i.e. whether begin() == end().
Definition basic_string.h:904
int64_t int64
Represents a 64-bit signed integer.
Definition int64.h:23
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.h:22
@ binary_number
Indicates that the allow_leading_white, allow_trailing_white, and allow_binary_specifier styles are u...
@ octal_number
Indicates that the allow_leading_white, allow_trailing_white, and allow_octal_specifier styles are us...
@ number
Indicates that the allow_leading_white, allow_trailing_white, allow_leading_sign, allow_trailing_sign...
@ hex_number
Indicates that the allow_leading_white, allow_trailing_white, and allow_hex_specifier styles are used...
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition xtd_about_box.h:10