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;
137 bool IsArray()
const;
138 bool IsDocument()
const;
142 bool IsInt32()
const;
143 bool IsInt64()
const;
144 bool IsUInt64()
const;
145 bool IsDouble()
const;
146 bool IsString()
const;
147 bool IsDateTime()
const;
149 bool IsBinary()
const;
150 bool IsDecimal128()
const;
151 bool IsMinKey()
const;
152 bool IsMaxKey()
const;
153 bool IsTimestamp()
const;
155 bool IsObject()
const {
return IsDocument(); }
170 template <
typename T>
174 "There is no `Parse(const Value&, formats::parse::To<T>)` in namespace "
175 "of `T` or `formats::parse`. "
176 "Probably you have not provided a `Parse` function overload."
179 return Parse(*
this, formats::
parse::To<T>{});
184 template <
typename T,
typename First,
typename... Rest>
185 auto As(First&& default_arg, Rest&&... more_default_args)
const {
189 return decltype(As<T>())(std::forward<First>(default_arg), std::forward<Rest>(more_default_args)...);
197 template <
typename T>
199 return (
IsMissing() || IsNull()) ?
decltype(As<T>())() : As<T>();
204 template <
typename T>
206 if constexpr (formats::
common::impl::HasConvert<
Value, T>) {
207 return Convert(*
this, formats::
parse::To<T>{});
208 }
else if constexpr (formats::
common::impl::HasParse<
Value, T>) {
209 return Parse(*
this, formats::
parse::To<T>{});
213 "There is no `Convert(const Value&, formats::parse::To<T>)` or "
214 "`Parse(const Value&, formats::parse::To<T>)` 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;
267 friend bool Parse(
const Value& value,
parse::To<
bool>);
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_;