JayBeams  0.1
Another project to have fun coding.
Static Public Member Functions | List of all members
jb::config_recurse Struct Reference

Recursively apply functions to config_object, attributes, and sequences of config objects. More...

#include <config_recurse.hpp>

Static Public Member Functions

template<typename T , typename... Args>
static void apply_overrides (T &lhs, YAML::Node const &by_name, class_overrides const &by_class, Args...)
 Override a value with the configuration contained in a YAML::Node. More...
 
template<typename T >
static std::enable_if< std::is_base_of< config_object, T >::value, void >::type apply_overrides (T &lhs, YAML::Node const &by_name, class_overrides const &by_class)
 Partial specialization for classes derived from jb::config_object. More...
 
template<typename C , typename T >
static void apply_overrides (config_attribute< C, T > &lhs, YAML::Node const &by_name, class_overrides const &by_class)
 Partial specialization for jb::config_attribute. More...
 
template<typename Sequence >
static std::enable_if< std::is_base_of< config_object, typename Sequence::value_type >::value, void >::type apply_overrides (Sequence &lhs, YAML::Node const &by_name, class_overrides const &by_class)
 Partial specialization for anything looking like a sequence of jb::config_object. More...
 
template<typename T , typename... Args>
static void add_options (boost::program_options::options_description &options, T const &object, std::string const &prefix, config_object::attribute_descriptor const &d, Args...)
 Implement the basic construct to create command-line options ased on a config_object. More...
 
template<typename T >
static std::enable_if< std::is_base_of< config_object, T >::value, void >::type add_options (boost::program_options::options_description &options, T const &object, std::string const &prefix, config_object::attribute_descriptor const &d)
 Partial specialization for classes derived from jb::config_object. More...
 
template<typename C , typename T >
static void add_options (boost::program_options::options_description &options, config_attribute< C, T > const &object, std::string const &prefix, config_object::attribute_descriptor const &d)
 Partial specialization for configuration attribute. More...
 
template<typename Sequence >
static std::enable_if< std::is_base_of< config_object, typename Sequence::value_type >::value, void >::type add_options (boost::program_options::options_description &options, Sequence const &object, std::string const &prefix, config_object::attribute_descriptor const &d)
 Partial specialization for anything looking like a sequence of jb::config_object. More...
 
template<typename U , typename V >
static void add_options (boost::program_options::options_description &options, std::pair< U, V > const &object, std::string const &prefix, config_object::attribute_descriptor const &d)
 Partial specialization for things that look like pairs. More...
 
template<typename T , typename... Args>
static void apply_cmdline_values (T &rhs, boost::program_options::variables_map const &vm, std::string const &name, Args...)
 Get a value from the cmdline values and apply it to the object. More...
 
template<typename T >
static std::enable_if< std::is_base_of< config_object, T >::value, void >::type apply_cmdline_values (T &rhs, boost::program_options::variables_map const &vm, std::string const &name)
 Partial specialization for jb::config_object and derived classes. More...
 
template<typename C , typename T >
static void apply_cmdline_values (config_attribute< C, T > &rhs, boost::program_options::variables_map const &vm, std::string const &name)
 Partial specialization for configuration attribute. More...
 
template<typename Sequence >
static std::enable_if< std::is_base_of< config_object, typename Sequence::value_type >::value, void >::type apply_cmdline_values (Sequence &rhs, boost::program_options::variables_map const &vm, std::string const &name)
 Partial specialization for anything looking like a sequence of jb::config_object. More...
 
template<typename U , typename V >
static void apply_cmdline_values (std::pair< U, V > &rhs, boost::program_options::variables_map const &vm, std::string const &name)
 Partial specialization for std::pair<>. More...
 
template<typename T , typename... Args>
static void validate (T const &, Args...)
 Validate an arbitrary object. More...
 
template<typename T >
static std::enable_if< std::is_base_of< config_object, T >::value, void >::type validate (T const &object)
 Partial specialization of validate() for jb::config_object and derived classes. More...
 
template<typename C , typename T >
static void validate (config_attribute< C, T > const &object)
 Partial of validate() for specialization for jb::config_attribute<>. More...
 
template<typename Sequence >
static std::enable_if< std::is_base_of< config_object, typename Sequence::value_type >::value, void >::type validate (Sequence const &seq)
 Partial specialization of validate() for anything looking like a sequence of jb::config_object. More...
 
template<typename U , typename V >
static void validate (std::pair< U, V > const &object)
 Partial specialization of validate() for std::pair<>. More...
 
template<typename T , typename... Args>
static YAML::Node to_yaml (T const &x, Args...)
 Convert an arbitrary type to a YAML representation. More...
 
template<typename T >
static std::enable_if< std::is_base_of< config_object, T >::value, YAML::Node >::type to_yaml (T const &object)
 Partial specialization of to_yaml() for jb::config_object and derived classes. More...
 
template<typename C , typename T >
static YAML::Node to_yaml (config_attribute< C, T > const &object)
 Partial of to_yaml() for specialization for jb::config_attribute<>. More...
 
template<typename Sequence >
static std::enable_if< std::is_base_of< config_object, typename Sequence::value_type >::value, YAML::Node >::type to_yaml (Sequence const &seq)
 Partial specialization of to_yaml() for anything looking like a sequence of jb::config_object. More...
 
template<typename U , typename V >
static YAML::Node to_yaml (std::pair< U, V > const &object)
 Partial specialization of to_yaml() for std::pair<>. More...
 

Detailed Description

Recursively apply functions to config_object, attributes, and sequences of config objects.

This is implemented as a struct with static functions (instead of standalone functions), so jb::config_object can forward declare the struct and grant 'friend' access to functions that should not be exposed otherwise.

Definition at line 41 of file config_recurse.hpp.

Member Function Documentation

◆ add_options() [1/5]

template<typename T , typename... Args>
static void jb::config_recurse::add_options ( boost::program_options::options_description &  options,
T const &  object,
std::string const &  prefix,
config_object::attribute_descriptor const &  d,
Args...   
)
inlinestatic

◆ add_options() [2/5]

template<typename T >
static std::enable_if< std::is_base_of<config_object, T>::value, void>::type jb::config_recurse::add_options ( boost::program_options::options_description &  options,
T const &  object,
std::string const &  prefix,
config_object::attribute_descriptor const &  d 
)
inlinestatic

Partial specialization for classes derived from jb::config_object.

Definition at line 130 of file config_recurse.hpp.

References add_options(), jb::config_object::cmdline_arg_name(), and jb::config_object::attribute_descriptor::name.

◆ add_options() [3/5]

template<typename C , typename T>
void jb::config_recurse::add_options ( boost::program_options::options_description &  options,
config_attribute< C, T > const &  object,
std::string const &  prefix,
config_object::attribute_descriptor const &  d 
)
static

Partial specialization for configuration attribute.

Definition at line 227 of file config_attribute.hpp.

◆ add_options() [4/5]

template<typename Sequence >
static std::enable_if< std::is_base_of<config_object, typename Sequence::value_type>::value, void>::type jb::config_recurse::add_options ( boost::program_options::options_description &  options,
Sequence const &  object,
std::string const &  prefix,
config_object::attribute_descriptor const &  d 
)
inlinestatic

◆ add_options() [5/5]

template<typename U , typename V >
static void jb::config_recurse::add_options ( boost::program_options::options_description &  options,
std::pair< U, V > const &  object,
std::string const &  prefix,
config_object::attribute_descriptor const &  d 
)
inlinestatic

◆ apply_cmdline_values() [1/5]

template<typename T , typename... Args>
static void jb::config_recurse::apply_cmdline_values ( T &  rhs,
boost::program_options::variables_map const &  vm,
std::string const &  name,
Args...   
)
inlinestatic

Get a value from the cmdline values and apply it to the object.

Definition at line 200 of file config_recurse.hpp.

Referenced by jb::config_attribute< jb::testing::microbenchmark_config, bool >::apply_cmdline_values(), and apply_cmdline_values().

◆ apply_cmdline_values() [2/5]

template<typename T >
static std::enable_if< std::is_base_of<config_object, T>::value, void>::type jb::config_recurse::apply_cmdline_values ( T &  rhs,
boost::program_options::variables_map const &  vm,
std::string const &  name 
)
inlinestatic

Partial specialization for jb::config_object and derived classes.

Definition at line 214 of file config_recurse.hpp.

References apply_cmdline_values().

◆ apply_cmdline_values() [3/5]

template<typename C , typename T>
void jb::config_recurse::apply_cmdline_values ( config_attribute< C, T > &  rhs,
boost::program_options::variables_map const &  vm,
std::string const &  name 
)
static

Partial specialization for configuration attribute.

Definition at line 235 of file config_attribute.hpp.

References jb::config_attribute< C, T >::apply_cmdline_values().

◆ apply_cmdline_values() [4/5]

template<typename Sequence >
static std::enable_if< std::is_base_of<config_object, typename Sequence::value_type>::value, void>::type jb::config_recurse::apply_cmdline_values ( Sequence &  rhs,
boost::program_options::variables_map const &  vm,
std::string const &  name 
)
inlinestatic

Partial specialization for anything looking like a sequence of jb::config_object.

Definition at line 236 of file config_recurse.hpp.

References apply_cmdline_values(), and jb::config_object::cmdline_arg_name().

◆ apply_cmdline_values() [5/5]

template<typename U , typename V >
static void jb::config_recurse::apply_cmdline_values ( std::pair< U, V > &  rhs,
boost::program_options::variables_map const &  vm,
std::string const &  name 
)
inlinestatic

Partial specialization for std::pair<>.

Definition at line 257 of file config_recurse.hpp.

References apply_cmdline_values(), and jb::config_object::cmdline_arg_name().

◆ apply_overrides() [1/4]

template<typename T , typename... Args>
static void jb::config_recurse::apply_overrides ( T &  lhs,
YAML::Node const &  by_name,
class_overrides const &  by_class,
Args...   
)
inlinestatic

Override a value with the configuration contained in a YAML::Node.

This generic implementation is used by basic types (int, string, vector, etc). We provide partial specializations for all the interesting types (jb::config_attribute, jb::config_objects).

The variadic template makes this the weakest match for resolution when compared to the other partial specializations.

Definition at line 53 of file config_recurse.hpp.

Referenced by apply_overrides(), and jb::config_attribute< jb::testing::microbenchmark_config, bool >::apply_overrides().

◆ apply_overrides() [2/4]

template<typename T >
static std::enable_if< std::is_base_of<config_object, T>::value, void>::type jb::config_recurse::apply_overrides ( T &  lhs,
YAML::Node const &  by_name,
class_overrides const &  by_class 
)
inlinestatic

Partial specialization for classes derived from jb::config_object.

Definition at line 69 of file config_recurse.hpp.

References apply_overrides().

◆ apply_overrides() [3/4]

template<typename C , typename T>
void jb::config_recurse::apply_overrides ( config_attribute< C, T > &  lhs,
YAML::Node const &  by_name,
class_overrides const &  by_class 
)
static

Partial specialization for jb::config_attribute.

Definition at line 220 of file config_attribute.hpp.

References jb::config_attribute< C, T >::apply_overrides().

◆ apply_overrides() [4/4]

template<typename Sequence >
static std::enable_if< std::is_base_of<config_object, typename Sequence::value_type>::value, void>::type jb::config_recurse::apply_overrides ( Sequence &  lhs,
YAML::Node const &  by_name,
class_overrides const &  by_class 
)
inlinestatic

Partial specialization for anything looking like a sequence of jb::config_object.

Definition at line 90 of file config_recurse.hpp.

References apply_overrides().

◆ to_yaml() [1/5]

template<typename T , typename... Args>
static YAML::Node jb::config_recurse::to_yaml ( T const &  x,
Args...   
)
inlinestatic

Convert an arbitrary type to a YAML representation.

Definition at line 316 of file config_recurse.hpp.

Referenced by jb::config_attribute< jb::testing::microbenchmark_config, bool >::to_yaml(), and to_yaml().

◆ to_yaml() [2/5]

template<typename T >
static std::enable_if< std::is_base_of<config_object, T>::value, YAML::Node>::type jb::config_recurse::to_yaml ( T const &  object)
inlinestatic

Partial specialization of to_yaml() for jb::config_object and derived classes.

Definition at line 329 of file config_recurse.hpp.

References to_yaml().

◆ to_yaml() [3/5]

template<typename C , typename T>
YAML::Node jb::config_recurse::to_yaml ( config_attribute< C, T > const &  object)
static

Partial of to_yaml() for specialization for jb::config_attribute<>.

Definition at line 247 of file config_attribute.hpp.

References jb::config_attribute< C, T >::to_yaml().

◆ to_yaml() [4/5]

template<typename Sequence >
static std::enable_if< std::is_base_of<config_object, typename Sequence::value_type>::value, YAML::Node>::type jb::config_recurse::to_yaml ( Sequence const &  seq)
inlinestatic

Partial specialization of to_yaml() for anything looking like a sequence of jb::config_object.

Definition at line 348 of file config_recurse.hpp.

References to_yaml().

◆ to_yaml() [5/5]

template<typename U , typename V >
static YAML::Node jb::config_recurse::to_yaml ( std::pair< U, V > const &  object)
inlinestatic

Partial specialization of to_yaml() for std::pair<>.

Definition at line 360 of file config_recurse.hpp.

◆ validate() [1/5]

template<typename T , typename... Args>
static void jb::config_recurse::validate ( T const &  ,
Args...   
)
inlinestatic

Validate an arbitrary object.

Definition at line 268 of file config_recurse.hpp.

Referenced by jb::config_attribute< jb::testing::microbenchmark_config, bool >::validate(), and validate().

◆ validate() [2/5]

template<typename T >
static std::enable_if< std::is_base_of<config_object, T>::value, void>::type jb::config_recurse::validate ( T const &  object)
inlinestatic

Partial specialization of validate() for jb::config_object and derived classes.

Definition at line 280 of file config_recurse.hpp.

References validate().

◆ validate() [3/5]

template<typename C , typename T>
void jb::config_recurse::validate ( config_attribute< C, T > const &  object)
static

Partial of validate() for specialization for jb::config_attribute<>.

Definition at line 242 of file config_attribute.hpp.

References jb::config_attribute< C, T >::validate().

◆ validate() [4/5]

template<typename Sequence >
static std::enable_if< std::is_base_of<config_object, typename Sequence::value_type>::value, void>::type jb::config_recurse::validate ( Sequence const &  seq)
inlinestatic

Partial specialization of validate() for anything looking like a sequence of jb::config_object.

Definition at line 299 of file config_recurse.hpp.

References validate().

◆ validate() [5/5]

template<typename U , typename V >
static void jb::config_recurse::validate ( std::pair< U, V > const &  object)
inlinestatic

Partial specialization of validate() for std::pair<>.

Definition at line 309 of file config_recurse.hpp.

References validate().


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