19namespace alib {
namespace enums {
53 ENUM_RECORD_MAP.EmplaceIfNotExistent(
EnumRecordKey(rtti, elementValue ), record );
55 ENUM_RECORD_MAP.try_emplace(
EnumRecordKey(rtti, elementValue ), record );
63 auto it= ENUM_RECORD_MAP.Find(
EnumRecordKey( rtti, elementValue ) );
65 auto it= ENUM_RECORD_MAP.find(
EnumRecordKey( rtti, elementValue ) );
67 if ( it != ENUM_RECORD_MAP.end() )
73#if ALIB_MONOMEM && ALIB_CONTAINERS
75 EnumRecordKey,
const void*,
84 return ENUM_RECORD_MAP;
97 void assembleMsgAndThrow [[noreturn]] (
const NString& error )
103 msg <<
"ERROR WHILE PARSING ENUMERATION RECORD STRING" <<
NEW_LINE
109 msg <<
"(Not resourced)";
111 <<
" Column: " << column + 1 <<
NEW_LINE
114 for(
integer i= column ; i >= 0 ; --i )
115 msg << (i != 0 ?
'-' :
'>');
118 throw std::runtime_error( msg.
Terminate() );
131 assembleMsgAndThrow(
NString256() << what <<
'.' );
138 assembleMsgAndThrow(
NString256() <<
"Found whitespaces "
145 assembleMsgAndThrow(
NString256() <<
"Found trailing whitespaces in string value \""
152 assembleMsgAndThrow(
NString256() <<
"Unnecessary character \""
154 <<
"\" found " << where );
160 assembleMsgAndThrow(
NString256() << where <<
'\"' << specificChar <<
'\"');
169 assembleMsgAndThrow(
NString256() <<
"Expected outer delimiter or end of input" );
175 assembleMsgAndThrow(
NString256() <<
"Expected end of parsable input string" );
185 bigInt= (std::numeric_limits<integer>::max)();
191 error(
"Power of 2 symbol '^' is not followed by a number" );
192 bigInt=
static_cast<integer>(1LL << exp);
201 error(
"Not an integral value" );
229 || ( isLastField && ( result ==
OuterDelimChar || result ==
'\0' ) ) )
234 error(
"End of input when parsing a character." );
252 error(
"Not a floating point value" );
292#if ALIB_DEBUG && !DOXYGEN
293namespace{
unsigned int initFlag= 0; }
299 ALIB_ASSERT_ERROR( initFlag == 0x92A3EF61,
"ENUMS",
"Not initialized when calling shutdown." )
301 #if ALIB_MONOMEM && ALIB_CONTAINERS
308 ALIB_ASSERT_ERROR( initFlag == 0,
"ENUMS",
"This method must not be invoked twice." )
312DOX_MARKER([DOX_ENUMS_MULTIPLE_RECORDS])
326DOX_MARKER([DOX_ENUMS_MULTIPLE_RECORDS])
334DOX_MARKER([DOX_ENUMS_MULTIPLE_RECORDS_2])
343DOX_MARKER([DOX_ENUMS_MULTIPLE_RECORDS_2])
constexpr const TChar * Terminate() const
constexpr bool IsEmpty() const
constexpr bool IsNotEmpty() const
constexpr integer Length() const
TChar CharAtStart() const
integer IndexOfAny(const TString &needles, integer startIdx=0) const
integer IndexOfOrLength(TChar needle) const
bool ConsumeString(const TString< TChar > &consumable)
ALIB_API bool ConsumeFloat(double &result, TNumberFormat< TChar > *numberFormat=nullptr)
integer ConsumeChars(integer regionLength, TSubstring *target=nullptr)
bool ConsumeDec(TIntegral &result, TNumberFormat< TChar > *numberFormat=nullptr)
bool ConsumeInt(TIntegral &result, TNumberFormat< TChar > *numberFormat=nullptr)
TString< TChar > ConsumeToken(TChar separator=',', lang::Inclusion includeSeparator=lang::Inclusion::Include)
#define ALIB_ASSERT_ERROR(cond,...)
HashMap< MonoAllocator, EnumRecordKey, const void *, EnumRecordKey::Hash, EnumRecordKey::EqualTo > ENUM_RECORD_MAP
Global directory to find enum records.
ALIB_API void setEnumRecord(const std::type_info &rtti, integer integral, const void *record)
ALIB_API const void * getEnumRecord(const std::type_info &rtti, integer integral)
HashMap< MonoAllocator, EnumRecordKey, const void *, EnumRecordKey::Hash, EnumRecordKey::EqualTo > & getInternalRecordMap()
@ Exclude
Chooses exclusion.
@ Include
Chooses inclusion.
@ Keep
Keep whitespaces in string.
@ Trim
Trim whitespaces away.
@ Enabled
Caching is enabled.
@ Disabled
Caching is disabled.
@ Right
Denotes the right side of something.
@ Left
Denotes the left side of something.
@ Omit
Do not propagate changes.
@ ToDescendants
Propagate changes to descendants/children/subcomponents.
@ On
Switch it on, switched on, etc.
@ Off
Switch it off, switched off, etc.
@ Safe
Do it or treat it with safety.
@ Unsafe
Omit checks or perform unsafe operations.
@ Ascending
Chooses ascending sort oder.
@ Descending
Chooses descending sort oder.
@ Global
Denotes global reach.
@ Local
Denotes local reach.
@ Copy
Chooses not to clear existing data.
@ Move
Chooses to clear existing data.
@ Local
Denotes local time.
@ UTC
Denotes UTC (coordinated universal time).
@ Keep
Chooses not no clear existing data.
@ Clear
Chooses to clear existing data.
@ KeepWithSender
Keeps responsibility, e.g., when passing an object.
@ Transfer
Transfers responsibility to the receiving party.
@ Center
Chooses centered alignment.
@ Right
Chooses right alignment.
@ Left
Chooses left alignment.
@ Begin
The start of a transaction.
@ End
The end of a transaction.
@ Remove
Denotes removals.
@ GetCreate
Denotes to create data if not found.
@ Create
Denotes to create data.
@ Insert
Denotes insertions.
@ Get
Denotes to search data.
ALIB_API MonoAllocator GLOBAL_ALLOCATOR
constexpr CString DEFAULT_WHITESPACES
A zero-terminated string of default whitespace characters.
strings::TString< nchar > NString
Type alias in namespace alib.
strings::TSubstring< character > Substring
Type alias in namespace alib.
NLocalString< 256 > NString256
Type alias name for TLocalString<nchar,256>.
constexpr CString NEW_LINE
A zero-terminated string containing the new-line character sequence.
monomem::TMonoAllocator< lang::HeapAllocator > MonoAllocator
strings::TCString< nchar > NCString
Type alias in namespace alib.
characters::character character
Type alias in namespace alib.
strings::TString< character > String
Type alias in namespace alib.
lang::integer integer
Type alias in namespace alib.
int MinimumRecognitionLength
String EnumElementName
The name of the enum element.
static ALIB_API void Get(String &result, bool isLastField=false)
static ALIB_API void assertNoUnnecessary(character specificChar, const NCString &where)
static ALIB_API NString ResourceCategory
The resource category (if a resourced string was parsed).
static ALIB_API integer getInteger(bool isLastField)
static ALIB_API void Delim()
static ALIB_API void assertEndOfInput()
Asserts that the Input is empty.
static ALIB_API void OuterDelim()
static ALIB_API void assertChar(character specificChar, const NCString &where)
static ALIB_API void assertNoWhitespaces(const NCString &where)
static ALIB_API Substring Input
The remaining input string.
static ALIB_API String OriginalInput
A backup of the originally given string to parse.
static ALIB_API void assertEndOfRecord()
Asserts that either Input is empty, or an OuterDelimChar follows.
static ALIB_API character InnerDelimChar
The delimiter of fields of a record.
static ALIB_API NString ResourceName
The resource name (if a resourced string was parsed).
static ALIB_API void assertNoTrailingWhitespaces(String &token)
static ALIB_API character OuterDelimChar
The delimiter of records.
static ALIB_API void error(const NCString &what)
EnumRecordPrototype() noexcept=default
ALIB_API void Parse() noexcept
static void Bootstrap(TEnum element, TArgs &&... args) noexcept
Compare functor for this key type.
Hash functor for this key type.