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;
143 bool IsInt32()
const;
144 bool IsInt64()
const;
145 bool IsUInt64()
const;
146 bool IsDouble()
const;
147 bool IsString()
const;
148 bool IsDateTime()
const;
150 bool IsBinary()
const;
151 bool IsDecimal128()
const;
152 bool IsMinKey()
const;
153 bool IsMaxKey()
const;
154 bool IsTimestamp()
const;
156 bool IsObject()
const {
return IsDocument(); }
171 template <
typename T>
175 "There is no `Parse(const Value&, formats::parse::To<T>)` in namespace "
176 "of `T` or `formats::parse`. "
177 "Probably you have not provided a `Parse` function overload."
180 return Parse(*
this, formats::
parse::To<T>{});
185 template <
typename T,
typename First,
typename... Rest>
186 auto As(First&& default_arg, Rest&&... more_default_args)
const {
190 return decltype(As<T>())(std::forward<First>(default_arg), std::forward<Rest>(more_default_args)...);
198 template <
typename T>
200 return (
IsMissing() || IsNull()) ?
decltype(As<T>())() : As<T>();
205 template <
typename T>
207 if constexpr (formats::
common::impl::kHasConvert<
Value, T>) {
208 return Convert(*
this, formats::
parse::To<T>{});
209 }
else if constexpr (formats::
common::impl::kHasParse<
Value, T>) {
210 return Parse(*
this, formats::
parse::To<T>{});
214 "There is no `Convert(const Value&, formats::parse::To<T>)` or"
215 "`Parse(const Value&, formats::parse::To<T>)`"
216 "in namespace of `T` or `formats::parse`. "
217 "Probably you have not provided a `Convert` function overload."
224 template <
typename T,
typename First,
typename... Rest>
225 T
ConvertTo(First&& default_arg, Rest&&... more_default_args)
const {
228 return T(std::forward<First>(default_arg), std::forward<Rest>(more_default_args)...);
230 return ConvertTo<T>();
259 Document GetInternalArrayDocument()
const;
263 const impl::BsonHolder& GetBson()
const;
267 friend class impl::BsonBuilder;
269 friend bool Parse(
const Value& value,
parse::To<
bool>);
270 friend int64_t Parse(
const Value& value,
parse::To<int64_t>);
271 friend uint64_t Parse(
const Value& value,
parse::To<uint64_t>);
272 friend double Parse(
const Value& value,
parse::To<
double>);
273 friend std::string Parse(
const Value& value,
parse::To<std::string>);
274 friend std::chrono::system_clock::time_point
275 Parse(
const Value& value,
parse::To<std::chrono::system_clock::time_point>);
282 impl::ValueImplPtr impl_;