userver: yaml_config Namespace Reference
⚠️ This is the documentation for an old userver version. Click here to switch to the latest version.
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages Concepts
yaml_config Namespace Reference

Utilities to work with static YAML config. More...

Classes

class  Iterator
 
struct  Schema
 JSON Schema-like type definition. More...
 
class  SchemaPtr
 
class  YamlConfig
 Datatype that represents YAML with substituted variables. More...
 

Typedefs

using Exception = formats::yaml::Exception
 
using ParseException = formats::yaml::ParseException
 

Enumerations

enum class  FieldType {
  kBool ,
  kInteger ,
  kNumber ,
  kString ,
  kArray ,
  kObject
}
 

Functions

template<typename T , typename Value >
std::vector< T > ParseMapToArray (const Value &value)
 
template<typename ParentComponent >
Schema MergeSchemas (const std::string &yaml_string)
 Merge parent and child components schemas of static configs.
 
std::string ToString (FieldType type)
 
formats::yaml::Value Serialize (const SchemaPtr &schema, formats::serialize::To< formats::yaml::Value >)
 
Schema Parse (const formats::yaml::Value &schema, formats::parse::To< Schema >)
 
formats::yaml::Value Serialize (const Schema &schema, formats::serialize::To< formats::yaml::Value >)
 
template<>
std::string YamlConfig::As< std::string > () const
 
std::chrono::seconds Parse (const YamlConfig &value, formats::parse::To< std::chrono::seconds >)
 Parses duration from string, understands suffixes: ms, s, m, h, d.
 
std::chrono::milliseconds Parse (const YamlConfig &value, formats::parse::To< std::chrono::milliseconds >)
 Parses duration from string, understands suffixes: ms, s, m, h, d.
 

Detailed Description

Utilities to work with static YAML config.

Typedef Documentation

◆ Exception

Definition at line 23 of file yaml_config.hpp.

◆ ParseException

Definition at line 24 of file yaml_config.hpp.

Enumeration Type Documentation

◆ FieldType

enum class yaml_config::FieldType
strong

Definition at line 23 of file schema.hpp.

Function Documentation

◆ MergeSchemas()

template<typename ParentComponent >
Schema yaml_config::MergeSchemas ( const std::string &  yaml_string)

Merge parent and child components schemas of static configs.

See also
Static configs validation
Examples
samples/http_caching/http_caching.cpp.

Definition at line 23 of file merge_schemas.hpp.

◆ Parse() [1/2]

std::chrono::milliseconds yaml_config::Parse ( const YamlConfig value,
formats::parse::To< std::chrono::milliseconds >   
)

Parses duration from string, understands suffixes: ms, s, m, h, d.

Exceptions
Oninvalid type and invalid string format

◆ Parse() [2/2]

std::chrono::seconds yaml_config::Parse ( const YamlConfig value,
formats::parse::To< std::chrono::seconds >   
)

Parses duration from string, understands suffixes: ms, s, m, h, d.

Exceptions
Oninvalid type, invalid string format, and if the duration is not a whole amount of seconds

◆ ParseMapToArray()

template<typename T , typename Value >
std::vector< T > yaml_config::ParseMapToArray ( const Value &  value)

Definition at line 11 of file map_to_array.hpp.