cppfig 0.1.0
Modern C++20 compile-time type-safe configuration library
Loading...
Searching...
No Matches
cppfig::ConfigTraits< T > Struct Template Reference

Primary template for configuration type traits. More...

#include <traits.h>

Static Public Member Functions

static auto Serialize (const T &value) -> Value=delete
 Serializes a value to a Value node.
 
static auto Deserialize (const Value &value) -> std::optional< T >=delete
 Deserializes a value from a Value node.
 
static auto ToString (const T &value) -> std::string=delete
 Converts a value to a human-readable string.
 
static auto FromString (std::string_view str) -> std::optional< T >=delete
 Parses a value from a string (e.g., from environment variables).
 

Detailed Description

template<typename T>
struct cppfig::ConfigTraits< T >

Primary template for configuration type traits.

Users must specialize this template for custom types to enable serialization, deserialization, and validation. Default specializations are provided for primitive types (int, double, bool, std::string).

Template Parameters
TThe configuration value type.

Member Function Documentation

◆ Deserialize()

template<typename T >
static auto cppfig::ConfigTraits< T >::Deserialize ( const Value value) -> std::optional< T >=delete
staticdelete

Deserializes a value from a Value node.

Parameters
valueThe Value node to deserialize.
Returns
The deserialized value, or std::nullopt on failure.

◆ FromString()

template<typename T >
static auto cppfig::ConfigTraits< T >::FromString ( std::string_view  str) -> std::optional< T >=delete
staticdelete

Parses a value from a string (e.g., from environment variables).

Parameters
strThe string to parse.
Returns
The parsed value, or std::nullopt on failure.

◆ Serialize()

template<typename T >
static auto cppfig::ConfigTraits< T >::Serialize ( const T &  value) -> Value=delete
staticdelete

Serializes a value to a Value node.

Parameters
valueThe value to serialize.
Returns
The Value representation of the value.

◆ ToString()

template<typename T >
static auto cppfig::ConfigTraits< T >::ToString ( const T &  value) -> std::string=delete
staticdelete

Converts a value to a human-readable string.

Parameters
valueThe value to convert.
Returns
String representation of the value.

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