Non-mutable YAML value representation. More...
#include <userver/formats/yaml/value.hpp>
Classes | |
| struct | DefaultConstructed |
| struct | IterTraits |
Public Types | |
| using | const_iterator = Iterator< IterTraits > |
| using | Exception = formats::yaml::Exception |
| using | ParseException = formats::yaml::ParseException |
| using | Builder = ValueBuilder |
Public Member Functions | |
| Value () noexcept | |
| Constructs a Value that holds a Null. | |
| Value (Value &&) | |
| Value (const Value &) | |
| Value & | operator= (Value &&) |
| Value & | operator= (const Value &) |
| template<class T > | |
| Value & | operator= (T &&) && |
| Value (Value &&other, std::string path_prefix) | |
Copies other, appending path_prefix to the stored path | |
| Value | operator[] (std::string_view key) const |
| Access member by key for read. | |
| Value | operator[] (std::size_t index) const |
| Access array member by index for read. | |
| const_iterator | begin () const |
| Returns an iterator to the beginning of the held array or map. | |
| const_iterator | end () const |
| Returns an iterator to the end of the held array or map. | |
| bool | IsEmpty () const |
| Returns whether the array or object is empty. | |
| std::size_t | GetSize () const |
| Returns array size or object members count. | |
| bool | operator== (const Value &other) const |
| Compares values. | |
| bool | operator!= (const Value &other) const |
| 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 noexcept |
| Returns true if *this holds a Null (Type::kNull). | |
| 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). | |
| template<typename T > | |
| T | As () const |
| Returns value of *this converted to T. | |
| 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(). | |
| template<typename T > | |
| T | As (DefaultConstructed) const |
| Returns value of *this converted to T or T() if this->IsMissing(). | |
| bool | HasMember (std::string_view key) const |
Returns true if *this holds a key. | |
| std::string | GetPath () const |
| Returns full path to this value. | |
| int | GetColumn () const |
Returns 0-based column number of this Value in the original document. Returns -1 if this->IsMissing(). If Value was created using formats::yaml::ValueBuilder, returns 0. | |
| int | GetLine () const |
Returns 0-based line number of this Value in the original document. Returns -1 if this->IsMissing(). If Value was created using formats::yaml::ValueBuilder, returns 0. | |
| Value | Clone () const |
| Returns new value that is an exact copy if the existing one but references different memory (a deep copy of a *this). The returned value is a root value with path '/'. | |
| void | CheckNotMissing () const |
| void | CheckArray () const |
| void | CheckArrayOrNull () const |
| void | CheckObjectOrNull () const |
| void | CheckObject () const |
| void | CheckString () const |
| void | CheckObjectOrArrayOrNull () const |
| void | CheckInBounds (std::size_t index) const |
| bool | IsRoot () const noexcept |
| Returns true if *this is a first (root) value. | |
| bool | DebugIsReferencingSameMemory (const Value &other) const |
Returns true if *this and other reference the value by the same pointer. | |
| template<> | |
| bool | As () const |
| template<> | |
| int64_t | As () const |
| template<> | |
| uint64_t | As () const |
| template<> | |
| double | As () const |
Friends | |
| class | Iterator< IterTraits > |
| class | ValueBuilder |
| formats::yaml::Value | FromString (const std::string &) |
| Parse YAML from string. | |
| formats::yaml::Value | FromStream (std::istream &) |
| Parse JSON from stream. | |
| void | Serialize (const formats::yaml::Value &, std::ostream &) |
| Serialize YAML to stream. | |
Non-mutable YAML value representation.
Class provides non mutable access YAML value. For modification and construction of new YAML values use formats::yaml::ValueBuilder.
| formats::yaml::Value::Value | ( | Value && | other, |
| std::string | path_prefix | ||
| ) |
Copies other, appending path_prefix to the stored path
other must have an empty (root) path | `std::logic_error` | if other has path other than the root path |
| T formats::yaml::Value::As | ( | ) | const |
Returns value of *this converted to T.
| Anything | derived from std::exception. |
| T formats::yaml::Value::As | ( | Value::DefaultConstructed | ) | const |
Returns value of *this converted to T or T() if this->IsMissing().
| Anything | derived from std::exception. |
value.As<T>({}) | T formats::yaml::Value::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. |
| const_iterator formats::yaml::Value::begin | ( | ) | const |
Returns an iterator to the beginning of the held array or map.
| TypeMismatchException | if not an array or an object. |
| void formats::yaml::Value::CheckArray | ( | ) | const |
| MemberMissingException | if *this is not an array. |
| void formats::yaml::Value::CheckArrayOrNull | ( | ) | const |
| MemberMissingException | if *this is not an array or Null. |
| void formats::yaml::Value::CheckInBounds | ( | std::size_t | index | ) | const |
| TypeMismatchException | if *this is not a map, array or Null; OutOfBoundsException if index >= this->GetSize(). |
| void formats::yaml::Value::CheckNotMissing | ( | ) | const |
| MemberMissingException | if this->IsMissing(). |
| void formats::yaml::Value::CheckObject | ( | ) | const |
| TypeMismatchException | if *this is not a map. |
| void formats::yaml::Value::CheckObjectOrArrayOrNull | ( | ) | const |
| TypeMismatchException | if *this is not a map, array or Null. |
| void formats::yaml::Value::CheckObjectOrNull | ( | ) | const |
| TypeMismatchException | if *this is not a map or Null. |
| void formats::yaml::Value::CheckString | ( | ) | const |
| TypeMismatchException | if *this is not convertible to std::string. |
| Value formats::yaml::Value::Clone | ( | ) | const |
Returns new value that is an exact copy if the existing one but references different memory (a deep copy of a *this). The returned value is a root value with path '/'.
| MemberMissingException | id this->IsMissing(). |
| const_iterator formats::yaml::Value::end | ( | ) | const |
Returns an iterator to the end of the held array or map.
| TypeMismatchException | if not an array or an object. |
| int formats::yaml::Value::GetColumn | ( | ) | const |
Returns 0-based column number of this Value in the original document. Returns -1 if this->IsMissing(). If Value was created using formats::yaml::ValueBuilder, returns 0.
| int formats::yaml::Value::GetLine | ( | ) | const |
Returns 0-based line number of this Value in the original document. Returns -1 if this->IsMissing(). If Value was created using formats::yaml::ValueBuilder, returns 0.
| std::size_t formats::yaml::Value::GetSize | ( | ) | const |
Returns array size or object members count.
| TypeMismatchException | if not an array or an object. |
| bool formats::yaml::Value::IsEmpty | ( | ) | const |
Returns whether the array or object is empty.
| TypeMismatchException | if not an array or an object. |
|
inline |
| bool formats::yaml::Value::operator== | ( | const Value & | other | ) | const |
Compares values.
| MemberMissingException | if *this or other is missing. |
| Value formats::yaml::Value::operator[] | ( | std::size_t | index | ) | const |
Access array member by index for read.
| TypeMismatchException | if not an array value. |
| `OutOfBoundsException` | if index is greater or equal than size. |
| Value formats::yaml::Value::operator[] | ( | std::string_view | key | ) | const |
Access member by key for read.
| TypeMismatchException | if not a missing value, an object, or Null. |
|
friend |
Parse JSON from stream.
Parse JSON from stream.
|
friend |
Parse YAML from string.
Definition at line 81 of file from_string.hpp.
|
friend |