Porytiles
Loading...
Searching...
No Matches
porytiles2::LayerValue< T > Struct Template Reference

A small container that holds an optional-wrapped value, validation state, and metadata about the value source. More...

#include <layer_value.hpp>

Collaboration diagram for porytiles2::LayerValue< T >:
[legend]

Static Public Member Functions

static LayerValue valid (T val, std::string source_info)
 Creates a LayerValue representing a valid configuration value.
 
static LayerValue valid (T val, std::string source_info, std::vector< std::string > source_details)
 Creates a LayerValue representing a valid configuration value with detailed source context.
 
static LayerValue invalid (std::string error, std::string source_info)
 Creates a LayerValue representing an invalid configuration value.
 
static LayerValue invalid (std::string error, std::string source_info, std::vector< std::string > source_details)
 Creates a LayerValue representing an invalid configuration value with detailed source context.
 
static LayerValue not_provided ()
 Creates a LayerValue representing that the provider does not supply this configuration.
 

Public Attributes

std::optional< T > value
 
std::string source_info
 
std::vector< std::string > source_details
 
ValidationState state = ValidationState::not_provided
 
std::string error_message
 

Detailed Description

template<typename T>
struct porytiles2::LayerValue< T >

A small container that holds an optional-wrapped value, validation state, and metadata about the value source.

LayerValue supports three states:

  • not_provided: Provider doesn't handle this config (empty optional, no error) - continue to next provider
  • valid: Provider supplies valid config (has value, no error) - use this value
  • invalid: Provider attempted to supply config but it's invalid (no value, has error message) - fail immediately
Template Parameters
TThe type of the underlying value

Definition at line 37 of file layer_value.hpp.

Member Function Documentation

◆ invalid() [1/2]

template<typename T >
static LayerValue porytiles2::LayerValue< T >::invalid ( std::string  error,
std::string  source_info 
)
inlinestatic

Creates a LayerValue representing an invalid configuration value.

Parameters
errorError message describing why the value is invalid
source_infoString describing the source that attempted to provide this value
Returns
A LayerValue in the invalid state

Definition at line 78 of file layer_value.hpp.

◆ invalid() [2/2]

template<typename T >
static LayerValue porytiles2::LayerValue< T >::invalid ( std::string  error,
std::string  source_info,
std::vector< std::string >  source_details 
)
inlinestatic

Creates a LayerValue representing an invalid configuration value with detailed source context.

Parameters
errorError message describing why the value is invalid
source_infoString describing the source that attempted to provide this value
source_detailsVector of strings showing contextual lines around the source
Returns
A LayerValue in the invalid state

Definition at line 91 of file layer_value.hpp.

◆ not_provided()

template<typename T >
static LayerValue porytiles2::LayerValue< T >::not_provided ( )
inlinestatic

Creates a LayerValue representing that the provider does not supply this configuration.

Returns
A LayerValue in the not_provided state

Definition at line 106 of file layer_value.hpp.

◆ valid() [1/2]

template<typename T >
static LayerValue porytiles2::LayerValue< T >::valid ( val,
std::string  source_info 
)
inlinestatic

Creates a LayerValue representing a valid configuration value.

Parameters
valThe valid configuration value
source_infoString describing the source of this value
Returns
A LayerValue in the valid state

Definition at line 52 of file layer_value.hpp.

◆ valid() [2/2]

template<typename T >
static LayerValue porytiles2::LayerValue< T >::valid ( val,
std::string  source_info,
std::vector< std::string >  source_details 
)
inlinestatic

Creates a LayerValue representing a valid configuration value with detailed source context.

Parameters
valThe valid configuration value
source_infoString describing the source of this value
source_detailsVector of strings showing contextual lines around the source
Returns
A LayerValue in the valid state

Definition at line 65 of file layer_value.hpp.

Member Data Documentation

◆ error_message

template<typename T >
std::string porytiles2::LayerValue< T >::error_message

Definition at line 43 of file layer_value.hpp.

◆ source_details

template<typename T >
std::vector<std::string> porytiles2::LayerValue< T >::source_details

Definition at line 41 of file layer_value.hpp.

◆ source_info

template<typename T >
std::string porytiles2::LayerValue< T >::source_info

Definition at line 40 of file layer_value.hpp.

◆ state

Definition at line 42 of file layer_value.hpp.

◆ value

template<typename T >
std::optional<T> porytiles2::LayerValue< T >::value

Definition at line 39 of file layer_value.hpp.


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