A container that wraps a configuration value with its name and source information.
More...
template<typename T>
class porytiles::ConfigValue< T >
A container that wraps a configuration value with its name and source information.
ConfigValue provides transparent access to configuration values while also tracking the config value's canonical name, provider-specific name, and where each value originated (e.g., which ConfigProvider supplied it). It supports implicit conversion to the underlying type for ergonomic usage.
- Template Parameters
-
| T | The type of the configuration value |
Definition at line 24 of file config_value.hpp.
template<typename T >
template<typename U >
Creates a child ConfigValue from a ConfigPODField, inheriting this value's source provenance.
Used to resolve per-field overrides within aggregate config values. The derived ConfigValue inherits source() and source_details() from this (parent) ConfigValue, while taking the value, canonical_name, and source_key from the override. This allows provider-specific source metadata set at parse time to flow through to the consumer without hardcoding provider formats.
- Template Parameters
-
| U | The type of the override value (may differ from T) |
- Parameters
-
| override | The config override containing the value and per-field source metadata |
- Precondition
override must have a value (override.has_value() is true).
- Returns
- A new ConfigValue wrapping the override's value with combined provenance
Definition at line 122 of file config_value.hpp.
Generates formatted text data for displaying this configuration value.
Creates a structured representation of the configuration value suitable for formatted output or error messages. The output includes the value's canonical name, its actual value, the source information, and any additional source details if available. The format follows the pattern:
Source: source_string
[optional
source details lines]
const std::string & source() const
const std::string & canonical_name() const
const T & value() const &
Each format string in the returned pair contains placeholders ({}) that correspond to the FormatParam objects in the parallel vector, which provide both the text to insert and styling information.
- Returns
- A pair containing:
- first: Vector of format strings with placeholders
- second: Vector of FormatParam vectors, where each inner vector contains the parameters for the corresponding format string at the same index
- Postcondition
- The returned vectors in the pair have matching sizes (excluding source_details entries which have no parameters)
-
The first format string is always "{} = {}" for name and value
-
The second format string is always "Source: {}" for source information
Definition at line 158 of file config_value.hpp.
Generates a prettified, styled readout of this configuration value.
Convenience method that combines format_data() with a TextFormatter to produce styled text output ready for display. This method internally calls format_data() and applies the formatter to each format string with its corresponding parameters, returning a vector of fully formatted lines.
The output includes the value name, its actual value, the source information, and any additional source details if available, all with appropriate styling applied (or not, depending on the formatter implementation).
Example output (when displayed):
num_tiles_primary = 512
1: foo:
2: bar: baz
3: fieldmap:
-> 4: num_tiles_primary: 512
- Parameters
-
| formatter | The TextFormatter to use for applying styles to the text |
- Returns
- A vector of formatted strings, each representing a line of the prettified output
- Postcondition
- The returned vector has at least 2 elements (name/value line and source line)
-
Additional lines may be present if source details are available
Definition at line 215 of file config_value.hpp.