8#ifndef HPP_ALIB_ENUMS_RECORDS
9#define HPP_ALIB_ENUMS_RECORDS 1
15#include "alib/enums/underlyingintegral.hpp"
29 namespace lang {
class Camp; }
101 template<
typename TEnum,
typename TEnableIf>
108 template<
typename TEnum,
109 typename TEnableIf=
ATMP_VOID_IF( std::is_enum<TEnum>::value )>
123namespace alib {
namespace enums {
149template<
typename TEnum>
153template<
typename TEnum>
159 static_assert( std::is_trivially_destructible<typename T_EnumRecords<TEnum>::Type>::value,
160 "Error: Enum Record types must be a trivially destructible." );
168 return *reinterpret_cast<const typename
T_EnumRecords<TEnum>::Type*>( result );
190template<
typename TEnum>
194template<
typename TEnum>
199 static_assert( std::is_trivially_destructible<typename T_EnumRecords<TEnum>::Type>::value,
200 "Error: Enum Record types must be a trivially destructible." );
254template<
typename TEnum,
typename TEnableIf>
257template<typename TEnum, typename TEnableIf=
262 static_assert( std::is_trivially_destructible<typename T_EnumRecords<TEnum>::Type>::value,
263 "Error: Enum Record types must be a trivially destructible." );
269 using
TIntegral= typename std::underlying_type<TEnum>::type;
283 template<
typename TRecord,
typename TAssociated>
287 template<typename TRecord, typename TAssociated= typename T_EnumRecords<TEnum>::Type>
363 return !(*
this == other);
372 return TEnum(
node->integral );
381 return node->integral;
395 return &
node->record;
448 template <
typename... TArgs>
451 ,
record ( std::forward<TArgs>(args)... )
472 template <
typename... TArgs>
474 void Bootstrap( TEnum element, TArgs&&... args )
noexcept;
496 void Bootstrap( std::initializer_list<Initializer> definitions );
700template<
typename TEnum>
704template<
typename TEnum>
712#define ALIB_ENUMS_ASSIGN_RECORD( TEnum, TRecord ) \
713namespace alib::enums { \
714template<> struct T_EnumRecords<TEnum> : public std::true_type \
716 using Type= TRecord; \
#define ALIB_ASSERT_MODULE(modulename)
#define ATMP_VOID_IF(Cond)
#define ATMP_ISOF( T, TBase)
#define ATMP_EQ( T, TEqual)
#define ALIB_ASSERT_ERROR(cond,...)
#define ATMP_T_IF(T, Cond)
ALIB_API const void * getEnumRecord(const std::type_info &rtti, integer integral)
constexpr std::underlying_type< TEnum >::type UnderlyingIntegral(TEnum element) noexcept
const T_EnumRecords< TEnum >::Type * TryRecord(TEnum element)
const T_EnumRecords< TEnum >::Type & GetRecord(TEnum element)
NLocalString< 128 > NString128
Type alias name for TLocalString<nchar,128>.
characters::character character
Type alias in namespace alib.
lang::integer integer
Type alias in namespace alib.
int MinimumRecognitionLength
String EnumElementName
The name of the enum element.
ERSerializable() noexcept=default
Defaulted constructor leaving the record undefined.
TIntegral Integral() const
ForwardIterator operator++(int)
typename detail::EnumRecordHook< TEnum >::Node Node
Shortcut to the record hook's inner node type (linked list).
ForwardIterator(Node *start) noexcept
const TRecord & operator*() const
std::forward_iterator_tag iterator_category
Implementation of std::iterator_traits.
bool operator==(ForwardIterator other) const
bool operator!=(ForwardIterator other) const
const TRecord & value_type
Implementation of std::iterator_traits.
Node * node
The current node this iterator refers to.
integer difference_type
Implementation of std::iterator_traits.
TRecord const * operator->() const
ForwardIterator & operator++()
TRecord const * pointer
Implementation of std::iterator_traits.
const TRecord & reference
Implementation of std::iterator_traits.
Helper-struct used with bulk-initialization method Bootstrap(std::initializer_list<Initializer>).
TEnum element
The enumeration element.
Initializer(TEnum elem, TArgs &&... args) noexcept
TRecord record
The static data record.
static void Bootstrap(const String &input, character innerDelim=',', character outerDelim=',')
typename std::underlying_type< TEnum >::type TIntegral
The enum's underlying integer type.
static void Bootstrap(lang::Camp &module, const NString &name, character innerDelim=',', character outerDelim=',')
static void Bootstrap(TEnum element, TArgs &&... args) noexcept
static void Bootstrap(character innerDelim=',', character outerDelim=',')
static constexpr ForwardIterator end()
static void Bootstrap(std::initializer_list< Initializer > definitions)
static ForwardIterator begin()
static void Bootstrap(lang::resources::ResourcePool &pool, const NString &category, const NString &name, character innerDelim=',', character outerDelim=',')
EnumRecords() noexcept=default
Defaulted constructor.
typename T_EnumRecords< TEnum >::Type TRecord
The enum's associated record type.
static constexpr bool AreOfType()
void Type
The data type associated with elements of TEnum.
A node of the forward list that contains the custom record data.