DNDSR 0.1.0.dev1+gcd065ad
Distributed Numeric Data Structure for CFV
Loading...
Searching...
No Matches
DNDS::FieldMeta Struct Reference

Descriptor for a single configuration field. More...

#include <ConfigRegistry.hpp>

Collaboration diagram for DNDS::FieldMeta:
[legend]

Public Attributes

std::string name
 JSON key name (may differ from C++ member name for aliased fields).
 
std::string description
 Human-readable description, used in JSON Schema and generated docs.
 
ConfigTypeTag typeTag
 JSON Schema type category.
 
std::function< void(const nlohmann::ordered_json &j, void *obj)> readField
 Read this field from a JSON object into a struct instance.
 
std::function< void(nlohmann::ordered_json &j, const void *obj)> writeField
 Write this field from a struct instance into a JSON object.
 
std::function< nlohmann::ordered_json()> schemaEntry
 Emit the JSON Schema fragment for this field.
 
std::vector< std::string > enumValues
 Allowed string values for enum fields. Empty for non-enum fields.
 
std::optional< double > minimum
 Optional minimum constraint for numeric fields (used in schema + validation).
 
std::optional< double > maximum
 Optional maximum constraint for numeric fields (used in schema + validation).
 
std::map< std::string, std::string > auxInfo
 Auxiliary key-value info (emitted as "x-<key>": "<value>" in schema). Use for units, references, version notes, etc.
 

Detailed Description

Descriptor for a single configuration field.

Stores everything needed to serialize, deserialize, validate, and generate JSON Schema for one member of a config struct. Created by ConfigSectionBuilder::field() (typically via the DNDS_FIELD macro) and stored in the per-type ConfigRegistry<T> singleton.

All std::function members capture a pointer-to-member and description string. They live in host-side static storage and never reference instance state.

Definition at line 158 of file ConfigRegistry.hpp.

Member Data Documentation

◆ auxInfo

std::map<std::string, std::string> DNDS::FieldMeta::auxInfo

Auxiliary key-value info (emitted as "x-<key>": "<value>" in schema). Use for units, references, version notes, etc.

Definition at line 195 of file ConfigRegistry.hpp.

◆ description

std::string DNDS::FieldMeta::description

Human-readable description, used in JSON Schema and generated docs.

Definition at line 161 of file ConfigRegistry.hpp.

◆ enumValues

std::vector<std::string> DNDS::FieldMeta::enumValues

Allowed string values for enum fields. Empty for non-enum fields.

Definition at line 185 of file ConfigRegistry.hpp.

◆ maximum

std::optional<double> DNDS::FieldMeta::maximum

Optional maximum constraint for numeric fields (used in schema + validation).

Definition at line 191 of file ConfigRegistry.hpp.

◆ minimum

std::optional<double> DNDS::FieldMeta::minimum

Optional minimum constraint for numeric fields (used in schema + validation).

Definition at line 188 of file ConfigRegistry.hpp.

◆ name

std::string DNDS::FieldMeta::name

JSON key name (may differ from C++ member name for aliased fields).

Definition at line 160 of file ConfigRegistry.hpp.

◆ readField

std::function<void(const nlohmann::ordered_json &j, void *obj)> DNDS::FieldMeta::readField

Read this field from a JSON object into a struct instance.

Parameters
jThe JSON object to read from (must contain name as a key).
objPointer to the struct instance (type-erased as void*).
Exceptions
nlohmann::json::out_of_rangeif the key is missing.
nlohmann::json::type_errorif the JSON value type doesn't match.

Definition at line 169 of file ConfigRegistry.hpp.

◆ schemaEntry

std::function<nlohmann::ordered_json()> DNDS::FieldMeta::schemaEntry

Emit the JSON Schema fragment for this field.

Returns
An ordered_json object like {"type":"number","default":1e100,"description":"..."}.

For enum fields, also includes "enum": [...]. For object fields, delegates to the nested section's ConfigRegistry::emitSchema(). For array fields, includes "items": {...}.

Definition at line 182 of file ConfigRegistry.hpp.

◆ typeTag

ConfigTypeTag DNDS::FieldMeta::typeTag

JSON Schema type category.

Definition at line 162 of file ConfigRegistry.hpp.

◆ writeField

std::function<void(nlohmann::ordered_json &j, const void *obj)> DNDS::FieldMeta::writeField

Write this field from a struct instance into a JSON object.

Parameters
jThe JSON object to write into.
objPointer to the struct instance (type-erased as const void*).

Definition at line 174 of file ConfigRegistry.hpp.


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