Datatype that represents YAML with substituted variables. More...
#include <userver/yaml_config/yaml_config.hpp>
Classes | |
struct | DefaultConstructed |
struct | IterTraits |
Public Types | |
using | const_iterator = Iterator< IterTraits > |
using | Exception = yaml_config::Exception |
using | ParseException = yaml_config::ParseException |
Public Member Functions | |
YamlConfig (formats::yaml::Value yaml, formats::yaml::Value config_vars) | |
YamlConfig = config + config_vars. | |
const formats::yaml::Value & | Yaml () const |
Get the plain Yaml without substitutions. It may contain raw references. | |
YamlConfig | operator[] (std::string_view key) const |
Access member by key for read. More... | |
YamlConfig | operator[] (size_t index) const |
Access member by index for read. More... | |
std::size_t | GetSize () const |
Returns array size or object members count. More... | |
bool | IsMissing () const noexcept |
Returns true if *this holds nothing. When IsMissing() returns true any attempt to get the actual value or iterate over *this will throw MemberMissingException. | |
bool | IsNull () const noexcept |
Returns true if *this holds 'null'. | |
bool | IsBool () const noexcept |
Returns true if *this is convertible to bool. | |
bool | IsInt () const noexcept |
Returns true if *this is convertible to int. | |
bool | IsInt64 () const noexcept |
Returns true if *this is convertible to int64_t. | |
bool | IsUInt64 () const noexcept |
Returns true if *this is convertible to uint64_t. | |
bool | IsDouble () const noexcept |
Returns true if *this is convertible to double. | |
bool | IsString () const noexcept |
Returns true if *this is convertible to std::string. | |
bool | IsArray () const noexcept |
Returns true if *this is an array (Type::kArray). | |
bool | IsObject () const noexcept |
Returns true if *this is a map (Type::kObject). | |
void | CheckNotMissing () const |
void | CheckArray () const |
void | CheckArrayOrNull () const |
void | CheckObjectOrNull () const |
void | CheckObject () const |
void | CheckString () const |
void | CheckObjectOrArrayOrNull () const |
template<typename T > | |
T | As () const |
Returns value of *this converted to T. More... | |
template<typename T , typename First , typename... Rest> | |
T | As (First &&default_arg, Rest &&... more_default_args) const |
Returns value of *this converted to T or T(args) if this->IsMissing(). More... | |
template<typename T > | |
T | As (DefaultConstructed) const |
Returns value of *this converted to T or T() if this->IsMissing(). More... | |
bool | HasMember (std::string_view key) const |
Returns true if *this holds a key . More... | |
std::string | GetPath () const |
Returns full path to this value. | |
const_iterator | begin () const |
Returns an iterator to the beginning of the held array or map. More... | |
const_iterator | end () const |
Returns an iterator to the end of the held array or map. More... | |
template<> | |
bool | As () const |
template<> | |
int64_t | As () const |
template<> | |
uint64_t | As () const |
template<> | |
double | As () const |
Datatype that represents YAML with substituted variables.
Definition at line 29 of file yaml_config.hpp.
Definition at line 38 of file yaml_config.hpp.
Definition at line 39 of file yaml_config.hpp.
Definition at line 40 of file yaml_config.hpp.
T yaml_config::YamlConfig::As |
Returns value of *this converted to T.
Anything | derived from std::exception. |
Definition at line 155 of file yaml_config.hpp.
T yaml_config::YamlConfig::As | ( | YamlConfig::DefaultConstructed | ) | const |
Returns value of *this converted to T or T() if this->IsMissing().
Anything | derived from std::exception. |
value.As<T>({})
Definition at line 193 of file yaml_config.hpp.
T yaml_config::YamlConfig::As | ( | First && | default_arg, |
Rest &&... | more_default_args | ||
) | const |
Returns value of *this converted to T or T(args) if this->IsMissing().
Anything | derived from std::exception. |
Definition at line 182 of file yaml_config.hpp.
const_iterator yaml_config::YamlConfig::begin | ( | ) | const |
Returns an iterator to the beginning of the held array or map.
TypeMismatchException | is the value of *this is not a map, array or Null. |
void yaml_config::YamlConfig::CheckArray | ( | ) | const |
MemberMissingException | if *this is not an array. |
void yaml_config::YamlConfig::CheckArrayOrNull | ( | ) | const |
MemberMissingException | if *this is not an array or Null. |
void yaml_config::YamlConfig::CheckNotMissing | ( | ) | const |
MemberMissingException | if this->IsMissing() . |
void yaml_config::YamlConfig::CheckObject | ( | ) | const |
TypeMismatchException | if *this is not a map. |
void yaml_config::YamlConfig::CheckObjectOrArrayOrNull | ( | ) | const |
TypeMismatchException | if *this is not a map, array or Null. |
void yaml_config::YamlConfig::CheckObjectOrNull | ( | ) | const |
TypeMismatchException | if *this is not a map or Null. |
void yaml_config::YamlConfig::CheckString | ( | ) | const |
TypeMismatchException | if *this is not convertible to std::string. |
const_iterator yaml_config::YamlConfig::end | ( | ) | const |
Returns an iterator to the end of the held array or map.
TypeMismatchException | is the value of *this is not a map, array or Null. |
std::size_t yaml_config::YamlConfig::GetSize | ( | ) | const |
Returns array size or object members count.
TypeMismatchException | if not array or object value. |
bool yaml_config::YamlConfig::HasMember | ( | std::string_view | key | ) | const |
Returns true if *this holds a key
.
Nothing. |
YamlConfig yaml_config::YamlConfig::operator[] | ( | size_t | index | ) | const |
Access member by index for read.
TypeMismatchException | if value is not missing and is not array. |
YamlConfig yaml_config::YamlConfig::operator[] | ( | std::string_view | key | ) | const |
Access member by key for read.
TypeMismatchException | if value is not missing and is not object. |