Porytiles
Loading...
Searching...
No Matches
porytiles::ConfigPODField< T > Struct Template Reference

A lightweight wrapper for per-field configuration values with source metadata. More...

#include <config_pod_field.hpp>

Collaboration diagram for porytiles::ConfigPODField< T >:
[legend]

Public Member Functions

 ConfigPODField ()=default
 
 ConfigPODField (T val)
 Constructs a ConfigPODField with a value and no source metadata.
 
 ConfigPODField (std::nullopt_t)
 Constructs an empty ConfigPODField from std::nullopt.
 
 ConfigPODField (T val, std::string source_key, std::string canonical_name)
 Constructs a ConfigPODField with a value and full source metadata.
 
 ConfigPODField (T val, std::string source_key, std::string canonical_name, std::string source_info, std::vector< std::string > source_details)
 Constructs a ConfigPODField with a value, full source metadata, and per-entry source location.
 
bool has_value () const
 Checks whether this field has a value set.
 
const T & operator* () const
 Accesses the stored value.
 

Public Attributes

std::optional< T > value {std::nullopt}
 
std::string source_key
 
std::string canonical_name
 
std::string source_info
 
std::vector< std::string > source_details
 

Detailed Description

template<typename T>
struct porytiles::ConfigPODField< T >

A lightweight wrapper for per-field configuration values with source metadata.

ConfigPODField replaces std::optional<T> in configuration POD structs where individual fields need to carry provider-specific source metadata (source_key, canonical_name). This metadata is set at parse time by the provider (e.g., YAML parser, CLI parser) and later used by ConfigValue::derive() to construct a child ConfigValue<T> with proper provenance.

Implicit constructors from T and std::nullopt_t preserve ergonomic usage in tests and initializer lists.

Template Parameters
TThe type of the field value

Definition at line 24 of file config_pod_field.hpp.

Constructor & Destructor Documentation

◆ ConfigPODField() [1/5]

template<typename T >
porytiles::ConfigPODField< T >::ConfigPODField ( )
default

◆ ConfigPODField() [2/5]

template<typename T >
porytiles::ConfigPODField< T >::ConfigPODField ( val)
inline

Constructs a ConfigPODField with a value and no source metadata.

Implicit conversion for test ergonomics, allowing direct assignment of a value without specifying metadata.

Parameters
valThe field value

Definition at line 42 of file config_pod_field.hpp.

◆ ConfigPODField() [3/5]

template<typename T >
porytiles::ConfigPODField< T >::ConfigPODField ( std::nullopt_t  )
inline

Constructs an empty ConfigPODField from std::nullopt.

Implicit conversion for initializer list ergonomics, allowing std::nullopt in vector initializer lists.

Definition at line 51 of file config_pod_field.hpp.

◆ ConfigPODField() [4/5]

template<typename T >
porytiles::ConfigPODField< T >::ConfigPODField ( val,
std::string  source_key,
std::string  canonical_name 
)
inline

Constructs a ConfigPODField with a value and full source metadata.

Used by config providers to set provider-specific source metadata during parsing.

Parameters
valThe field value
source_keyThe provider-specific identifier (e.g., YAML path, CLI flag)
canonical_nameHuman-readable description of this field

Definition at line 63 of file config_pod_field.hpp.

◆ ConfigPODField() [5/5]

template<typename T >
porytiles::ConfigPODField< T >::ConfigPODField ( val,
std::string  source_key,
std::string  canonical_name,
std::string  source_info,
std::vector< std::string >  source_details 
)
inline

Constructs a ConfigPODField with a value, full source metadata, and per-entry source location.

Used by config providers to set provider-specific source metadata during parsing of map-type config values. The source_info and source_details fields allow each entry within a map to carry its own source location, so that ConfigValue::derive() can produce accurately located child values instead of inheriting the parent map's location.

Parameters
valThe field value
source_keyThe provider-specific identifier (e.g., YAML path, CLI flag)
canonical_nameHuman-readable description of this field
source_infoSource location string (e.g., "./porytiles.yaml:42")
source_detailsContextual highlight lines from the source file

Definition at line 83 of file config_pod_field.hpp.

Member Function Documentation

◆ has_value()

template<typename T >
bool porytiles::ConfigPODField< T >::has_value ( ) const
inline

Checks whether this field has a value set.

Returns
true if a value is present

Definition at line 99 of file config_pod_field.hpp.

◆ operator*()

template<typename T >
const T & porytiles::ConfigPODField< T >::operator* ( ) const
inline

Accesses the stored value.

Precondition
has_value() must be true.
Returns
A const reference to the stored value

Definition at line 110 of file config_pod_field.hpp.

Member Data Documentation

◆ canonical_name

template<typename T >
std::string porytiles::ConfigPODField< T >::canonical_name

Definition at line 27 of file config_pod_field.hpp.

◆ source_details

template<typename T >
std::vector<std::string> porytiles::ConfigPODField< T >::source_details

Definition at line 29 of file config_pod_field.hpp.

◆ source_info

template<typename T >
std::string porytiles::ConfigPODField< T >::source_info

Definition at line 28 of file config_pod_field.hpp.

◆ source_key

template<typename T >
std::string porytiles::ConfigPODField< T >::source_key

Definition at line 26 of file config_pod_field.hpp.

◆ value

template<typename T >
std::optional<T> porytiles::ConfigPODField< T >::value {std::nullopt}

Definition at line 25 of file config_pod_field.hpp.


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