Datatype that represents YAML with substituted variables.
More...
#include <userver/yaml_config/yaml_config.hpp>
|
| 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 |
| 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 |
| Returns true if *this holds 'null'.
|
|
bool | IsInt64 () const |
| Returns true if *this is convertible to int64_t. More...
|
|
bool | IsUInt64 () const |
| Returns true if *this is convertible to uint64_t. More...
|
|
void | CheckArrayOrNull () const |
|
void | CheckObjectOrNull () 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.
◆ const_iterator
◆ Exception
◆ ParseException
◆ As() [1/3]
template<typename T >
T yaml_config::YamlConfig::As |
◆ As() [2/3]
Returns value of *this converted to T or T() if this->IsMissing().
- Exceptions
-
Anything | derived from std::exception. |
- Note
- Use as
value.As<T>({})
Definition at line 162 of file yaml_config.hpp.
◆ As() [3/3]
template<typename T , typename First , typename... Rest>
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().
- Exceptions
-
Anything | derived from std::exception. |
Definition at line 151 of file yaml_config.hpp.
◆ begin()
Returns an iterator to the beginning of the held array or map.
- Exceptions
-
TypeMismatchException | is the value of *this is not a map, array or Null. |
◆ CheckArrayOrNull()
void yaml_config::YamlConfig::CheckArrayOrNull |
( |
| ) |
const |
- Exceptions
-
MemberMissingException | if *this is not an array or Null. |
◆ CheckObjectOrNull()
void yaml_config::YamlConfig::CheckObjectOrNull |
( |
| ) |
const |
- Exceptions
-
TypeMismatchException | if *this is not a map or Null. |
◆ end()
Returns an iterator to the end of the held array or map.
- Exceptions
-
TypeMismatchException | is the value of *this is not a map, array or Null. |
◆ GetSize()
std::size_t yaml_config::YamlConfig::GetSize |
( |
| ) |
const |
Returns array size or object members count.
- Exceptions
-
TypeMismatchException | if not array or object value. |
◆ HasMember()
bool yaml_config::YamlConfig::HasMember |
( |
std::string_view |
key | ) |
const |
Returns true if *this holds a key
.
- Exceptions
-
◆ IsInt64()
bool yaml_config::YamlConfig::IsInt64 |
( |
| ) |
const |
Returns true if *this is convertible to int64_t.
- Exceptions
-
◆ IsUInt64()
bool yaml_config::YamlConfig::IsUInt64 |
( |
| ) |
const |
Returns true if *this is convertible to uint64_t.
- Exceptions
-
◆ operator[]() [1/2]
YamlConfig yaml_config::YamlConfig::operator[] |
( |
size_t |
index | ) |
const |
Access member by index for read.
- Exceptions
-
TypeMismatchException | if value is not missing and is not array. |
◆ operator[]() [2/2]
YamlConfig yaml_config::YamlConfig::operator[] |
( |
std::string_view |
key | ) |
const |
Access member by key for read.
- Exceptions
-
TypeMismatchException | if value is not missing and is not object. |
The documentation for this class was generated from the following file: