This sub-namespace holds entities of the module ALib EnumRecords, which are accessed by including ALib.EnumRecords.Bootstrap.H.
Type Index: | |
struct | EnumRecordParser |
struct | Initializer |
Function Index: | |
template<typename TEnum> requires enumrecords::HasRecords<TEnum> | |
void | Bootstrap (camp::Camp &camp, const NString &name, character innerDelim=',', character outerDelim=',') |
template<typename TEnum> requires alib::enumrecords::HasRecords<TEnum> | |
void | Bootstrap (character innerDelim=',', character outerDelim=',') |
template<typename TEnum> requires alib::enumrecords::HasRecords<TEnum> | |
void | Bootstrap (const String &input, character innerDelim=',', character outerDelim=',') |
template<typename TEnum> requires alib::enumrecords::HasRecords<TEnum> | |
void | Bootstrap (resources::ResourcePool &pool, const NString &category, const NString &name, character innerDelim=',', character outerDelim=',') |
template<typename TEnum> requires alib::enumrecords::HasRecords<TEnum> | |
void | Bootstrap (std::initializer_list< Initializer< TEnum > > definitions) |
template<typename TEnum, typename... TArgs> requires alib::enumrecords::HasRecords<TEnum> | |
void | Bootstrap (TEnum element, TArgs &&... args) noexcept |
void alib::enumrecords::bootstrap::Bootstrap | ( | camp::Camp & | camp, |
const NString & | name, | ||
character | innerDelim = ',', | ||
character | outerDelim = ',' ) |
This method can be used if a set of enum records is resourced using an ALib Camp's resource instance.
Invokes Bootstrap(ResourcePool&, const NString&, const NString&, character, character) accepting a Camp and using its ResourcePool and field Camp::ResourceCategory.
TEnum | The enumeration type to load resourced records for. |
camp | The module to use the resource pool and category name from. |
name | The resource name of the externalized name. In the case that a resource with that name does not exist, it is tried to load a resource with index number 0 appended to this name, aiming to parse a single record. On success, the index is incremented until no consecutive resource is found. |
innerDelim | The delimiter used for separating the fields of a record. Defaults to ',' . |
outerDelim | The character delimiting enum records. Defaults to ',' . |
Definition at line 329 of file camp.inl.
void alib::enumrecords::bootstrap::Bootstrap | ( | character | innerDelim = ',', |
character | outerDelim = ',' ) |
This namespace function is available if the type trait ResourcedTraits is specialized for the enum type TEnum.
Invokes Bootstrap(ResourcePool&, const NString&, const NString&, character, character)
TEnum | The enumeration type to load resourced records for. |
innerDelim | The delimiter used for separating the fields of a record. Defaults to ',' . |
outerDelim | The character delimiting enum records. Defaults to ',' . |
Definition at line 650 of file resources.inl.
void alib::enumrecords::bootstrap::Bootstrap | ( | const String & | input, |
character | innerDelim = ',', | ||
character | outerDelim = ',' ) |
Reads a list of enum data records from given string input.
The contents (buffer) of the given substring have to be of a static nature (by contract). This means that parsing will not create copies of portions of the string but still use them later. Consequently, the given string's buffer has to survive the life-cycle of an application.
This is due to the static nature of ALib Enum Records and their creation during bootstrap, either from C++ string literals or ALib Externalized Resources, which comply to the same contract.
input | The string used for parsing the enum records to store. |
innerDelim | The delimiter used for separating the fields of a record. Defaults to ',' . |
outerDelim | The character delimiting enum records. Defaults to ',' . |
Definition at line 140 of file recordbootstrap.inl.
void alib::enumrecords::bootstrap::Bootstrap | ( | resources::ResourcePool & | pool, |
const NString & | category, | ||
const NString & | name, | ||
character | innerDelim = ',', | ||
character | outerDelim = ',' ) |
Reads a list of enum data records from an (externalized) resource string.
It is possible to provide the record data in two ways:
0
to the resource name, parses a single record and increments the index. Parsing ends when a resource with a next higher index is not found.The second option is recommended for larger enum sets. While the separation causes some overhead in a resource backend, the external (!) management (translation, manipulation, etc.) is most probably simplified with this approach.
TEnum | The enumeration type to load resourced records for. |
pool | The resource pool to receive the string to parse the records from. |
category | The resource category of the externalized string. |
name | The resource name of the externalized name. In the case that a resource with that name does not exist, it is tried to load a resource with index number 0 appended to this name, aiming to parse a single record. On success, the index is incremented until no consecutive resource is found. |
innerDelim | The delimiter used for separating the fields of a record. Defaults to ',' . |
outerDelim | The character delimiting enum records. Defaults to ',' . |
Definition at line 573 of file resources.inl.
void alib::enumrecords::bootstrap::Bootstrap | ( | std::initializer_list< Initializer< TEnum > > | definitions | ) |
Associates elements of TEnum with records, as specified by the given list of definitions.
The use of struct bootstrap::Initializer allows placing the enumeration element together with the construction parameters of the custom record type into one comma-separated argument list, without the need to place extra curly braces around the arguments of the record. (Such would have been necessary if, for example, std::pair
had been used).
definitions | List of static enum records to store. |
Definition at line 96 of file recordbootstrap.inl.
|
noexcept |
Defines a record for a single element of TEnum.
TArgs | Types of the variadic arguments args. |
TEnum | The enum type to define records for. |
element | The enum element. |
args | Variadic arguments forwarded to constructor of the custom record to create and store. |
Definition at line 59 of file recordbootstrap.inl.