cppfig 0.1.0
Modern C++20 compile-time type-safe configuration library
Loading...
Searching...
No Matches
cppfig::ConfigSchema< Settings > Class Template Reference

Configuration schema holding all setting types. More...

#include <schema.h>

Static Public Member Functions

static constexpr auto GetPaths () -> std::array< std::string_view, size >
 Returns all paths as a compile-time array.
 
static constexpr auto Size () -> std::size_t
 Returns the number of settings in the schema.
 
template<typename Fn >
static void ForEachSetting (Fn &&fn)
 Iterates over all setting types with a callable.
 

Static Public Attributes

static constexpr std::size_t size = sizeof...(Settings)
 
template<typename S >
static constexpr bool has_setting = detail::IsOneOf<S, Settings...>::value
 Checks if a setting type is in this schema.
 

Detailed Description

template<IsSetting... Settings>
class cppfig::ConfigSchema< Settings >

Configuration schema holding all setting types.

This class acts as a compile-time registry for all configuration settings. It ensures path uniqueness at compile time and provides type-safe access to setting information.

Usage:

struct AppName {
static constexpr std::string_view path = "app.name";
using value_type = std::string;
static auto default_value() -> std::string { return "MyApp"; }
};
struct AppPort {
static constexpr std::string_view path = "app.port";
using value_type = int;
static auto default_value() -> int { return 8080; }
};
using MySchema = ConfigSchema<AppName, AppPort>;
Template Parameters
SettingsThe setting types to include in the schema.

Member Function Documentation

◆ ForEachSetting()

template<IsSetting... Settings>
template<typename Fn >
static void cppfig::ConfigSchema< Settings >::ForEachSetting ( Fn &&  fn)
inlinestatic

Iterates over all setting types with a callable.

The callable receives a type wrapper that can be used to access the setting type information.

◆ GetPaths()

template<IsSetting... Settings>
static constexpr auto cppfig::ConfigSchema< Settings >::GetPaths ( ) -> std::array<std::string_view, size>
inlinestaticconstexpr

Returns all paths as a compile-time array.

◆ Size()

template<IsSetting... Settings>
static constexpr auto cppfig::ConfigSchema< Settings >::Size ( ) -> std::size_t
inlinestaticconstexpr

Returns the number of settings in the schema.

Member Data Documentation

◆ has_setting

template<IsSetting... Settings>
template<typename S >
constexpr bool cppfig::ConfigSchema< Settings >::has_setting = detail::IsOneOf<S, Settings...>::value
staticconstexpr

Checks if a setting type is in this schema.

◆ size

template<IsSetting... Settings>
constexpr std::size_t cppfig::ConfigSchema< Settings >::size = sizeof...(Settings)
staticconstexpr

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