ALib C++ Library
Library Version: 2510 R0
Documentation generated by doxygen
Loading...
Searching...
No Matches
alib::enumrecords::bootstrap Namespace Reference

Description:

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
 

Function Details:

◆ Bootstrap() [1/6]

template<typename TEnum>
requires enumrecords::HasRecords<TEnum>
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.

Note
This is the preferred overload taken with ALib to load built-in enum records. The only exception is the use of overload Bootstrap(character, character) for enum record types that require a specialization of ResourcedTraits to perform "recursive" acquisition of other resources defined by fields of the records.
Availability
This namespace function is available only if the module ALib Camp is included in the ALib Build.
See also
Chapters 4.4.3 Using the Type Trait ResourcedTraits and 4.4.4 Using Resources In ALib Modules for more information.
Template Parameters
TEnumThe enumeration type to load resourced records for.
Parameters
campThe module to use the resource pool and category name from.
nameThe 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.
innerDelimThe delimiter used for separating the fields of a record. Defaults to ','.
outerDelimThe character delimiting enum records. Defaults to ','.

Definition at line 329 of file camp.inl.

Here is the call graph for this function:

◆ Bootstrap() [2/6]

template<typename TEnum>
requires alib::enumrecords::HasRecords<TEnum>
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)

Availability
This method is available only if ALib Resources is included in the ALib Build.
See also
Chapter 4.4.3 Using the Type Trait ResourcedTraits of the Programmer's Manual of this module.
Template Parameters
TEnumThe enumeration type to load resourced records for.
Parameters
innerDelimThe delimiter used for separating the fields of a record. Defaults to ','.
outerDelimThe character delimiting enum records. Defaults to ','.

Definition at line 650 of file resources.inl.

Here is the call graph for this function:

◆ Bootstrap() [3/6]

template<typename TEnum>
requires alib::enumrecords::HasRecords<TEnum>
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.

Availability
This method is available only if ALib Strings is included in the ALib Build.
See also
Chapter 4.4.1 Parsing Enum Records From Strings for a sample of how this method can be invoked.
Parameters
inputThe string used for parsing the enum records to store.
innerDelimThe delimiter used for separating the fields of a record. Defaults to ','.
outerDelimThe character delimiting enum records. Defaults to ','.

Definition at line 140 of file recordbootstrap.inl.

Here is the call graph for this function:

◆ Bootstrap() [4/6]

template<typename TEnum>
requires alib::enumrecords::HasRecords<TEnum>
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:

  • In one resource string: In this case, parameter outerDelim has to specify the delimiter that separates the records.
  • In an array of resource strings: If the resource string as given is not defined, this method appends an integral index starting with 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.

Availability
This namespace function is available only if ALib EnumRecords is included in the ALib Build.
See also
Chapter 4.4 Resourced/Externalized Enum Records for a sample of how this method can be invoked.
Template Parameters
TEnumThe enumeration type to load resourced records for.
Parameters
poolThe resource pool to receive the string to parse the records from.
categoryThe resource category of the externalized string.
nameThe 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.
innerDelimThe delimiter used for separating the fields of a record. Defaults to ','.
outerDelimThe character delimiting enum records. Defaults to ','.

Definition at line 573 of file resources.inl.

Here is the call graph for this function:

◆ Bootstrap() [5/6]

template<typename TEnum>
requires alib::enumrecords::HasRecords<TEnum>
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).

Note
It is preferred to use overloaded versions that parse definitions from static string data. This is more efficient in respect to the footprint of an application, and - if strings are resourced - far more flexible.
See also
Chapter 4.1.3 Step 3/3: Initializing The Data for a sample of how this method can be invoked.
Parameters
definitionsList of static enum records to store.

Definition at line 96 of file recordbootstrap.inl.

Here is the call graph for this function:

◆ Bootstrap() [6/6]

template<typename TEnum, typename... TArgs>
requires alib::enumrecords::HasRecords<TEnum>
void alib::enumrecords::bootstrap::Bootstrap ( TEnum element,
TArgs &&... args )
noexcept

Defines a record for a single element of TEnum.

Note
This method is rather provided for completeness, than for actual use, because it is preferred to bootstrap enum records as "bulk" data. Furthermore, it is preferred to use overloaded versions that accept static string data used to parse the data from. This is more efficient in respect to the footprint of an application, and - if strings are resourced - far more flexible.
See also
Chapter 4.1.3 Step 3/3: Initializing The Data for a sample of how this method can be invoked.
Template Parameters
TArgsTypes of the variadic arguments args.
TEnumThe enum type to define records for.
Parameters
elementThe enum element.
argsVariadic arguments forwarded to constructor of the custom record to create and store.

Definition at line 59 of file recordbootstrap.inl.

Here is the call graph for this function: