ALib C++ Library
Library Version: 2402 R1
Documentation generated by doxygen
Loading...
Searching...
No Matches
EnumRecordPrototype Struct Reference

Description:


This struct is not part of the library but only provided with the documentation of this ALib Module .

The struct prototypes what module ALib Enums expects from custom types that are associated to enumerations as the type of ALib Enum Records.

Usually, enum records are rather simple structs with fields of scalar or POD types like, int, double or String and this way remain POD types themselves.

When parsed or otherwise otherwise initialized, String members do not need to copy data to an own buffer, because the input string for parsing an instance, as well as the parameters of alternative constructors, are deemed to be static data.

The life-cycle of instances of enumeration record is from bootstrapping an application to its termination. After creation, the data can not be modified.

Definition at line 472 of file records.cpp.

Public Method Index:

 EnumRecordPrototype () noexcept=default
 
 EnumRecordPrototype (const MyType1 &myArg1, MyType2 myArg2,...) noexcept
 
ALIB_API void Parse () noexcept
 

Constructor(s) / Destructor Details::

◆ EnumRecordPrototype() [1/2]

EnumRecordPrototype ( )
defaultnoexcept

Default constructor leaving the record undefined. For efficiency, this usually does not initialize fields, as those will be overwritten by a subsequent invocation to Parse.

This constructor is only needed when method Parse is given. Note that it is advised to provide the parsing option and this way also this constructor.

◆ EnumRecordPrototype() [2/2]

EnumRecordPrototype ( const MyType1 & myArg1,
MyType2 myArg2,
... )
noexcept

Constructor accepting all necessary arguments to completely define the record. This constructor is needed only in the case that records should be defined in a statical way which is an alternative to implementing the definition by parsing an (externalized) initialization strings. Static definition can be performed with method alib::enums::EnumRecords<TEnum "TEnableIf>::Bootstrap(std::initializer_list<Initializer> definitions)" but is not recommended and the definition from parsable stings is preferred.

Note that the parameter's passed when this constructor is invoked, have to be of "static nature". For example, the buffers and contents of passed string values are deemed to survive the life-cycle of an application. Usually, C++ string literals are passed.

Parameters
myArg1Assigned to the first custom field.
myArg2Assigned to the second custom field.
...Further parameters, assigned to further fields.

Method Details:

◆ Parse()

ALIB_API void Parse ( )
noexcept

Implementation has to parse the fields of this record from static interface struct EnumRecordParser .

For - usually simple - enum records, the process of parsing is limited to reading values separated by delimiters. Convenient methods to do so are given by static type EnumRecordParser . More complex parsing logic may be implemented by using the "parser" substring found with EnumRecordParser::Input and further of its entities.
Please refer to the documentation of EnumRecordParser for all details. A source code sample is given in chapter 4.4.1 Parsing Enum Records From Strings of the Programmer's Manual of module ALib Enums .

The contents (buffer) of the string parsed is by contract of static nature. This means that no copies of portions need to be allocated when used as a field value of string type. This is in alignment with 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.

On the same token, in case of an error, an implementation should raise an exception in debug-compilations, as parsing is deemed to succeed on static data, even if externalized.


The documentation for this struct was generated from the following file: