11#include <userver/formats/bson/exception.hpp>
12#include <userver/formats/bson/iterator.hpp>
13#include <userver/formats/bson/types.hpp>
14#include <userver/formats/common/items.hpp>
15#include <userver/formats/common/meta.hpp>
16#include <userver/formats/parse/common.hpp>
17#include <userver/formats/parse/common_containers.hpp>
19USERVER_NAMESPACE_BEGIN
60 Value(
const Value&) =
default;
61 Value(
Value&&)
noexcept =
default;
63 Value& operator=(
Value&&) &
noexcept =
default;
66 Value& operator=(T&&) && {
69 "You're assigning to a temporary formats::bson::Value! Use "
70 "formats::bson::ValueBuilder for data modifications."
77 explicit Value(impl::ValueImplPtr);
105 const_iterator
end()
const;
113 const_reverse_iterator
rend()
const;
129 bool operator==(
const Value&)
const;
130 bool operator!=(
const Value&)
const;
138 bool IsArray()
const;
139 bool IsDocument()
const;
142 bool IsInt32()
const;
143 bool IsInt64()
const;
144 bool IsDouble()
const;
145 bool IsString()
const;
146 bool IsDateTime()
const;
148 bool IsBinary()
const;
149 bool IsDecimal128()
const;
150 bool IsMinKey()
const;
151 bool IsMaxKey()
const;
152 bool IsTimestamp()
const;
154 bool IsObject()
const {
return IsDocument(); }
169 template <
typename T>
173 "There is no `Parse(const Value&, formats::parse::To<T>)` in namespace "
174 "of `T` or `formats::parse`. "
175 "Probably you have not provided a `Parse` function overload."
183 template <
typename T,
typename First,
typename... Rest>
184 auto As(First&& default_arg, Rest&&... more_default_args)
const {
188 return decltype(As<T>())(std::forward<First>(default_arg), std::forward<Rest>(more_default_args)...);
196 template <
typename T>
198 return (
IsMissing() || IsNull()) ?
decltype(As<T>())() : As<T>();
203 template <
typename T>
212 "There is no `Convert(const Value&, formats::parse::To<T>)` or"
213 "`Parse(const Value&, formats::parse::To<T>)`"
214 "in namespace of `T` or `formats::parse`. "
215 "Probably you have not provided a `Convert` function overload."
222 template <
typename T,
typename First,
typename... Rest>
223 T
ConvertTo(First&& default_arg, Rest&&... more_default_args)
const {
226 return T(std::forward<First>(default_arg), std::forward<Rest>(more_default_args)...);
228 return ConvertTo<T>();
257 Document GetInternalArrayDocument()
const;
261 const impl::BsonHolder& GetBson()
const;
265 friend class impl::BsonBuilder;
268 friend int64_t Parse(
const Value& value,
parse::
To<int64_t>);
269 friend uint64_t Parse(
const Value& value,
parse::
To<uint64_t>);
270 friend double Parse(
const Value& value,
parse::
To<
double>);
271 friend std::string Parse(
const Value& value,
parse::
To<std::string>);
272 friend std::chrono::system_clock::time_point
273 Parse(
const Value& value,
parse::
To<std::chrono::system_clock::time_point>);
280 impl::ValueImplPtr impl_;
292std::string Parse(
const Value& value,
parse::
To<std::string>);
294std::chrono::system_clock::time_point Parse(
const Value& value,
parse::
To<std::chrono::system_clock::time_point>);
307bool Value::ConvertTo<
bool>()
const;
310int64_t
Value::ConvertTo<int64_t>()
const;
313uint64_t
Value::ConvertTo<uint64_t>()
const;
316double Value::ConvertTo<
double>()
const;
319std::string
Value::ConvertTo<std::string>()
const;
335bson::
Value operator
"" _bson(
const char* str, std::size_t len);