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
23formats::
yaml::Value FromStringAllowRepeatedKeys(
const std::string& doc);
43 using native_iter = YAML::const_iterator;
54 using Builder = ValueBuilder;
63 Value& operator=(Value&&);
64 Value& operator=(
const Value&);
67 Value& operator=(T&&) && {
70 "You're assigning to a temporary formats::yaml::Value! Use "
71 "formats::yaml::ValueBuilder for data modifications."
82 Value(Value&& other, std::string path_prefix);
100 const_iterator
end()
const;
113 bool operator!=(
const Value& other)
const;
161 template <
typename T>
167 template <
typename T,
typename First,
typename... Rest>
168 auto As(First&& default_arg, Rest&&... more_default_args)
const;
173 template <
typename T>
253 class EmplaceEnabler {};
257 Value(EmplaceEnabler,
const YAML::Node& value,
const formats::
yaml::
Path& path, std::string_view key);
259 Value(EmplaceEnabler,
const YAML::Node& value,
const formats::
yaml::
Path& path, size_t index);
261 Value CloneWithReplacedPath(std::string&& new_path)
const;
265 Value(
const YAML::Node& root)
noexcept;
267 static Value MakeNonRoot(
const YAML::Node& value,
const formats::
yaml::
Path& path, std::string_view key);
268 static Value MakeNonRoot(
const YAML::Node& val,
const formats::
yaml::
Path& path, size_t index);
270 const YAML::Node& GetNative()
const;
271 YAML::Node& GetNative();
272 int GetExtendedType()
const;
275 bool IsConvertibleToArithmetic()
const;
278 T ValueAsArithmetic()
const;
280 static constexpr std::size_t kNativeNodeSize = 64;
281 static constexpr std::size_t kNativeAlignment =
alignof(
void*);
283 utils::FastPimpl<YAML::Node, kNativeNodeSize, kNativeAlignment> value_pimpl_;
287 friend class ValueBuilder;
289 friend bool Parse(
const Value& value,
parse::
To<
bool>);
290 friend int64_t Parse(
const Value& value,
parse::
To<int64_t>);
291 friend uint64_t Parse(
const Value& value,
parse::
To<uint64_t>);
292 friend double Parse(
const Value& value,
parse::
To<
double>);
293 friend std::string Parse(
const Value& value,
parse::
To<std::string>);
298 friend formats::
yaml::Value impl::FromStringAllowRepeatedKeys(
const std::string& doc);
302auto Value::
As()
const {
305 "There is no `Parse(const Value&, formats::parse::To<T>)` in "
306 "namespace of `T` or `formats::parse`. "
307 "Probably you forgot to include the "
308 "<userver/formats/parse/common_containers.hpp> or you "
309 "have not provided a `Parse` function overload."
315bool Parse(
const Value& value,
parse::
To<
bool>);
317int64_t Parse(
const Value& value,
parse::
To<int64_t>);
319uint64_t Parse(
const Value& value,
parse::
To<uint64_t>);
321double Parse(
const Value& value,
parse::
To<
double>);
323std::string Parse(
const Value& value,
parse::
To<std::string>);
325template <
typename T,
typename First,
typename... Rest>
326auto Value::
As(First&& default_arg, Rest&&... more_default_args)
const {
330 return decltype(As<T>())(std::forward<First>(default_arg), std::forward<Rest>(more_default_args)...);
353yaml::Value operator
""_yaml(
const char* str, std::size_t len);