8#include <userver/formats/common/items.hpp>
9#include <userver/formats/common/meta.hpp>
10#include <userver/formats/parse/common.hpp>
11#include <userver/formats/yaml/exception.hpp>
12#include <userver/formats/yaml/iterator.hpp>
13#include <userver/formats/yaml/types.hpp>
14#include <userver/utils/fast_pimpl.hpp>
16USERVER_NAMESPACE_BEGIN
37 using native_iter = YAML::const_iterator;
48 using Builder = ValueBuilder;
57 Value& operator=(Value&&);
58 Value& operator=(
const Value&);
61 Value& operator=(T&&) && {
64 "You're assigning to a temporary formats::yaml::Value! Use "
65 "formats::yaml::ValueBuilder for data modifications."
76 Value(Value&& other, std::string path_prefix);
94 const_iterator
end()
const;
107 bool operator!=(
const Value& other)
const;
155 template <
typename T>
161 template <
typename T,
typename First,
typename... Rest>
162 auto As(First&& default_arg, Rest&&... more_default_args)
const;
167 template <
typename T>
247 class EmplaceEnabler {};
251 Value(EmplaceEnabler,
const YAML::Node& value,
const formats::
yaml::
Path& path, std::string_view key);
253 Value(EmplaceEnabler,
const YAML::Node& value,
const formats::
yaml::
Path& path, size_t index);
255 Value CloneWithReplacedPath(std::string&& new_path)
const;
259 Value(
const YAML::Node& root)
noexcept;
261 static Value MakeNonRoot(
const YAML::Node& value,
const formats::
yaml::
Path& path, std::string_view key);
262 static Value MakeNonRoot(
const YAML::Node& val,
const formats::
yaml::
Path& path, size_t index);
264 const YAML::Node& GetNative()
const;
265 YAML::Node& GetNative();
266 int GetExtendedType()
const;
269 bool IsConvertibleToArithmetic()
const;
272 T ValueAsArithmetic()
const;
274 static constexpr std::size_t kNativeNodeSize = 64;
275 static constexpr std::size_t kNativeAlignment =
alignof(
void*);
277 utils::FastPimpl<YAML::Node, kNativeNodeSize, kNativeAlignment> value_pimpl_;
281 friend class ValueBuilder;
283 friend bool Parse(
const Value& value,
parse::
To<
bool>);
284 friend int64_t Parse(
const Value& value,
parse::
To<int64_t>);
285 friend uint64_t Parse(
const Value& value,
parse::
To<uint64_t>);
286 friend double Parse(
const Value& value,
parse::
To<
double>);
287 friend std::string Parse(
const Value& value,
parse::
To<std::string>);
295auto Value::
As()
const {
298 "There is no `Parse(const Value&, formats::parse::To<T>)` in "
299 "namespace of `T` or `formats::parse`. "
300 "Probably you forgot to include the "
301 "<userver/formats/parse/common_containers.hpp> or you "
302 "have not provided a `Parse` function overload."
308bool Parse(
const Value& value,
parse::
To<
bool>);
310int64_t Parse(
const Value& value,
parse::
To<int64_t>);
312uint64_t Parse(
const Value& value,
parse::
To<uint64_t>);
314double Parse(
const Value& value,
parse::
To<
double>);
316std::string Parse(
const Value& value,
parse::
To<std::string>);
318template <
typename T,
typename First,
typename... Rest>
319auto Value::
As(First&& default_arg, Rest&&... more_default_args)
const {
323 return decltype(As<T>())(std::forward<First>(default_arg), std::forward<Rest>(more_default_args)...);
346yaml::Value operator
"" _yaml(
const char* str, std::size_t len);