8#ifndef HPP_ALIB_ENUMS_SERIALIZATION
9#define HPP_ALIB_ENUMS_SERIALIZATION 1
23namespace alib {
namespace enums {
67template<
typename TEnum,
69 Case TSensitivity = Case::Ignore,
75#pragma warning( push )
76#pragma warning( disable : 4127 )
79template<
typename TEnum,
84Parse( strings::TSubstring<TChar>& input, TEnum& result )
89 if constexpr ( TTrimBeforeConsume == lang::Whitespaces::Trim )
93 recordIt !=
EnumRecords<TEnum>().end() ; ++recordIt )
94 if ( input.template ConsumePartOf<TSensitivity>( recordIt->EnumElementName,
95 recordIt->MinimumRecognitionLength ) > 0 )
97 result= recordIt.Enum();
143template<
typename TEnum,
145 Case TSensitivity = Case::Ignore,
146 Whitespaces TTrimBeforeConsume = Whitespaces::Trim,
147 TChar delimiter =
',',
148 bool keepLastDelim =
true >
152template<
typename TEnum,
156 TChar delimiter =
',',
157 bool keepLastDelim =
true >
165 if constexpr ( keepLastDelim )
166 restoreBeforeDelim= input;
174 if constexpr ( keepLastDelim )
175 input= restoreBeforeDelim;
182 if constexpr ( keepLastDelim )
183 restoreBeforeDelim= input;
185 if( !input.template ConsumeChar<TSensitivity, TTrimBeforeConsume>( delimiter ) )
191#pragma warning( pop )
230template<
typename TEnum,
232 Case TSensitivity = Case::Ignore,
233 Whitespaces TTrimBeforeConsume = Whitespaces::Trim >
240template<
typename TEnum,
275namespace alib {
namespace strings {
279 namespace APPENDABLES {
317template<
typename TEnum,
typename TChar,
typename TAllocator>
320template<typename TEnum, typename TChar, typename TAllocator>
321struct
T_Append<TEnum, TChar,TAllocator,
348 auto* record= enums::TryRecord( element );
349 if( record !=
nullptr )
350 target << record->EnumElementName;
352 target << UnderlyingIntegral( element );
424template<
typename TEnumBitwise,
typename TChar>
427template<typename TEnum, typename TChar, typename TAllocator>
428struct
T_Append<TEnum, TChar,TAllocator,
459 TEnum covered= TEnum(0);
468 if( recordIt.Integral() == 0 )
470 if( elements == TEnum(0) )
472 target << recordIt->EnumElementName;
477 else if( HasBits( elements, recordIt.Enum() )
478 && !HasBits( covered , recordIt.Enum() ) )
480 covered|= recordIt.Enum();
481 target << recordIt->EnumElementName <<
',';
484 len= target.
Length() - len;
491 NString128() <<
"Not all bits have been covered while writing bitset '"
492 <<
NFormat::Bin( elements ) <<
"' of enumeration type <"
TAString & DeleteEnd(integer regionLength)
constexpr integer Length() const
TSubstring & TrimStart(const TCString< TChar > &whiteSpaces=TT_CStringConstants< TChar >::DefaultWhitespaces())
#define ALIB_ASSERT_MODULE(modulename)
#define ATMP_VOID_IF(Cond)
#define ATMP_ISOF( T, TBase)
#define ALIB_ASSERT_ERROR(cond,...)
#define IF_ALIB_CAMP(...)
#define ATMP_T_IF(T, Cond)
bool ParseBitwise(strings::TSubstring< TChar > &input, TEnum &result)
bool Parse(strings::TSubstring< TChar > &input, TEnum &result)
bool ParseEnumOrTypeBool(strings::TSubstring< TChar > &input, TEnum &result, TEnum falseValue, TEnum trueValue)
Whitespaces
Denotes whether a string is trimmed or not.
@ Trim
Trim whitespaces away.
Case
Denotes upper and lower case character treatment.
NLocalString< 128 > NString128
Type alias name for TLocalString<nchar,128>.
lang::integer integer
Type alias in namespace alib.
static constexpr ForwardIterator end()
void operator()(TAString< TChar, TAllocator > &target, TEnum elements)
void operator()(TAString< TChar, TAllocator > &target, TEnum element)