DNDSR 0.1.0.dev1+gcd065ad
Distributed Numeric Data Structure for CFV
Loading...
Searching...
No Matches
DNDS::ConfigSectionBuilder< T > Class Template Reference

Builder object passed to the user's registration function. More...

#include <ConfigParam.hpp>

Public Member Functions

template<typename V , typename... Tags>
void field (V T::*member, const char *jsonKey, const char *desc, Tags &&...tags)
 Register a field with pointer-to-member.
 
template<typename V , typename... Tags>
void field_alias (V T::*member, const char *jsonKey, const char *desc, Tags &&...tags)
 Register a field whose JSON key differs from the C++ member name.
 
template<typename S , typename... Tags>
void field_section (S T::*member, const char *jsonKey, const char *desc, Tags &&...tags)
 Register a nested sub-section. The sub-section type must itself use DNDS_DECLARE_CONFIG.
 
template<typename S , typename... Tags>
void field_array_of (std::vector< S > T::*member, const char *jsonKey, const char *desc, Tags &&...tags)
 Register a std::vector<S> field (array of sub-objects).
 
template<typename S , typename... Tags>
void field_map_of (std::map< std::string, S > T::*member, const char *jsonKey, const char *desc, Tags &&...tags)
 Register a std::map<std::string, S> field.
 
template<typename... Tags>
void field_json (nlohmann::ordered_json T::*member, const char *jsonKey, const char *desc, Tags &&...tags)
 Register an opaque nlohmann::ordered_json field.
 
template<typename FSchema , typename... Tags>
void field_json_schema (nlohmann::ordered_json T::*member, const char *jsonKey, const char *desc, FSchema &&schemaFn, Tags &&...tags)
 Register an opaque nlohmann::ordered_json field with a user-supplied schema generator.
 
template<typename F >
auto check (F &&f) -> decltype(f(std::declval< const T & >()), void())
 Register a context-free cross-field check.
 
template<typename F >
void check (const char *msg, F &&pred)
 Register a context-free cross-field check with a message string.
 
template<typename F >
auto check_ctx (F &&f) -> decltype(f(std::declval< const T & >(), std::declval< const ConfigContext & >()), void())
 Register a context-aware cross-field check.
 
template<typename F >
void post_read (F &&f)
 Register a post-read hook for recomputing derived quantities.
 

Detailed Description

template<typename T>
class DNDS::ConfigSectionBuilder< T >

Builder object passed to the user's registration function.

Named config in the DNDS_DECLARE_CONFIG expansion for readability. Provides field() (called via DNDS_FIELD macro), check(), check_ctx(), and specialized field registrars for sections, arrays, maps, and JSON blobs.

Definition at line 350 of file ConfigParam.hpp.

Member Function Documentation

◆ check() [1/2]

template<typename T >
template<typename F >
void DNDS::ConfigSectionBuilder< T >::check ( const char *  msg,
F &&  pred 
)
inline

Register a context-free cross-field check with a message string.

Parameters
msgError message shown when the check fails.
predLambda (const T&) -> bool, returns true if the check passes.

Definition at line 581 of file ConfigParam.hpp.

Here is the call graph for this function:

◆ check() [2/2]

template<typename T >
template<typename F >
auto DNDS::ConfigSectionBuilder< T >::check ( F &&  f) -> decltype(f(std::declval<const T &>()), void())
inline

Register a context-free cross-field check.

Parameters
fLambda (const T&) -> CheckResult.

Definition at line 568 of file ConfigParam.hpp.

Here is the call graph for this function:

◆ check_ctx()

template<typename T >
template<typename F >
auto DNDS::ConfigSectionBuilder< T >::check_ctx ( F &&  f) -> decltype(f(std::declval<const T &>(), std::declval<const ConfigContext &>()), void())
inline

Register a context-aware cross-field check.

Parameters
fLambda (const T&, const ConfigContext&) -> CheckResult.

Definition at line 596 of file ConfigParam.hpp.

Here is the call graph for this function:

◆ field()

template<typename T >
template<typename V , typename... Tags>
void DNDS::ConfigSectionBuilder< T >::field ( V T::*  member,
const char *  jsonKey,
const char *  desc,
Tags &&...  tags 
)
inline

Register a field with pointer-to-member.

Typically called via the DNDS_FIELD macro (which auto-stringifies the member name). Can also be called directly for aliased keys.

Parameters
memberPointer-to-member (e.g. &T::CFL).
jsonKeyThe JSON key string.
descHuman-readable description.
tagsZero or more DNDS::Config tag objects.

Definition at line 365 of file ConfigParam.hpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ field_alias()

template<typename T >
template<typename V , typename... Tags>
void DNDS::ConfigSectionBuilder< T >::field_alias ( V T::*  member,
const char *  jsonKey,
const char *  desc,
Tags &&...  tags 
)
inline

Register a field whose JSON key differs from the C++ member name.

Definition at line 398 of file ConfigParam.hpp.

Here is the call graph for this function:

◆ field_array_of()

template<typename T >
template<typename S , typename... Tags>
void DNDS::ConfigSectionBuilder< T >::field_array_of ( std::vector< S > T::*  member,
const char *  jsonKey,
const char *  desc,
Tags &&...  tags 
)
inline

Register a std::vector<S> field (array of sub-objects).

Definition at line 437 of file ConfigParam.hpp.

Here is the call graph for this function:

◆ field_json()

template<typename T >
template<typename... Tags>
void DNDS::ConfigSectionBuilder< T >::field_json ( nlohmann::ordered_json T::*  member,
const char *  jsonKey,
const char *  desc,
Tags &&...  tags 
)
inline

Register an opaque nlohmann::ordered_json field.

Definition at line 500 of file ConfigParam.hpp.

Here is the call graph for this function:

◆ field_json_schema()

template<typename T >
template<typename FSchema , typename... Tags>
void DNDS::ConfigSectionBuilder< T >::field_json_schema ( nlohmann::ordered_json T::*  member,
const char *  jsonKey,
const char *  desc,
FSchema &&  schemaFn,
Tags &&...  tags 
)
inline

Register an opaque nlohmann::ordered_json field with a user-supplied schema generator.

Use this for heterogeneous structures (e.g. arrays of discriminated union objects) where automatic schema inference is not possible.

Parameters
memberPointer-to-member.
jsonKeyJSON key name.
descHuman-readable description.
schemaFnCallable () -> ordered_json returning the full JSON Schema for this field.
tagsOptional tag objects.

Definition at line 539 of file ConfigParam.hpp.

Here is the call graph for this function:

◆ field_map_of()

template<typename T >
template<typename S , typename... Tags>
void DNDS::ConfigSectionBuilder< T >::field_map_of ( std::map< std::string, S > T::*  member,
const char *  jsonKey,
const char *  desc,
Tags &&...  tags 
)
inline

Register a std::map<std::string, S> field.

Definition at line 468 of file ConfigParam.hpp.

Here is the call graph for this function:

◆ field_section()

template<typename T >
template<typename S , typename... Tags>
void DNDS::ConfigSectionBuilder< T >::field_section ( S T::*  member,
const char *  jsonKey,
const char *  desc,
Tags &&...  tags 
)
inline

Register a nested sub-section. The sub-section type must itself use DNDS_DECLARE_CONFIG.

Definition at line 408 of file ConfigParam.hpp.

Here is the call graph for this function:

◆ post_read()

template<typename T >
template<typename F >
void DNDS::ConfigSectionBuilder< T >::post_read ( F &&  f)
inline

Register a post-read hook for recomputing derived quantities.

Parameters
fLambda (T&) -> void, called after readFromJson completes.

Definition at line 610 of file ConfigParam.hpp.

Here is the call graph for this function:

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