36#include <system_error>
74 operator double()
const {
82 BSONCXX_PRIVATE_WARNINGS_PUSH();
83 BSONCXX_PRIVATE_WARNINGS_DISABLE(GNU(
"-Wfloat-equal"));
85 BSONCXX_PRIVATE_WARNINGS_POP();
140 return !(lhs == rhs);
192 return !(lhs == rhs);
240 return !(lhs == rhs);
305 return !(lhs == rhs);
335 return !(lhs == rhs);
383 return !(lhs == rhs);
416 operator bool()
const {
431 return !(lhs == rhs);
449 std::chrono::milliseconds
value = {};
464 explicit b_date(std::chrono::system_clock::time_point tp)
465 :
value{std::chrono::duration_cast<std::chrono::milliseconds>(tp.time_since_epoch())} {}
470 operator std::chrono::milliseconds()
const {
474 explicit operator std::chrono::system_clock::time_point()
const {
475 return std::chrono::system_clock::time_point(
476 std::chrono::duration_cast<std::chrono::system_clock::duration>(
value));
490 return !(lhs == rhs);
516 return !(lhs == rhs);
567 return !(lhs == rhs);
615 return !(lhs == rhs);
663 return !(lhs == rhs);
713 return !(lhs == rhs);
761 return !(lhs == rhs);
794 operator std::int32_t()
const {
809 return !(lhs == rhs);
855 return !(lhs == rhs);
888 operator std::int64_t()
const {
903 return !(lhs == rhs);
951 return !(lhs == rhs);
977 return !(lhs == rhs);
1003 return !(lhs == rhs);
1009#pragma push_macro("X")
1011#define X(_name, _val) BSONCXX_PRIVATE_INLINE_CXX17 constexpr id b_##_name::type_id;
1013#pragma pop_macro("X")
1027#pragma push_macro("X")
1029#define X(_name, _value) b_##_name _b_##_name;
1034#pragma pop_macro("X")
1036 template <
typename T>
1037 using is_view = detail::is_alike<T, view>;
1039 template <
typename T>
1040 struct is_equality_comparable_with
1041 : detail::conjunction<detail::negation<is_view<T>>, std::is_constructible<view, T>> {};
1047#pragma push_macro("X")
1049#define X(_name, _value) \
1050 view(b_##_name v) : _id{v.type_id}, _b_##_name{v} {}
1059#pragma pop_macro("X")
1068#pragma push_macro("X")
1070#define X(_name, _value) BSONCXX_ABI_EXPORT_CDECL(b_##_name) get_##_name() const;
1082#pragma pop_macro("X")
1102#pragma push_macro("X")
1104#define X(_name, _value) \
1105 case v1::types::id::k_##_name: \
1106 return lhs.get_##_name() == rhs.get_##_name();
1114#pragma pop_macro("X")
1121 return !(lhs == rhs);
1160 template <typename T, detail::enable_if_t<is_equality_comparable_with<T>::value>* =
nullptr>
1165 template <typename T, detail::enable_if_t<is_equality_comparable_with<T>::value>* =
nullptr>
1176 template <typename T, detail::enable_if_t<is_equality_comparable_with<T>::value>* =
nullptr>
1178 return !(v ==
value);
1181 template <typename T, detail::enable_if_t<is_equality_comparable_with<T>::value>* =
nullptr>
1183 return !(v ==
value);
1222struct std::is_error_code_enum<
bsoncxx::v1::types::view::errc> : true_type {};
Provides macros to control the set of symbols exported in the ABI.
#define BSONCXX_ABI_EXPORT_CDECL(...)
Equivalent to BSONCXX_ABI_EXPORT with BSONCXX_ABI_CDECL.
Definition export.hpp:52
The bsoncxx v1 macro guard postlude header.
The bsoncxx v1 macro guard prelude header.
A non-owning, read-only BSON array.
Definition view.hpp:49
A BSON Decimal128.
Definition decimal128.hpp:39
A non-owning, read-only BSON document.
Definition view.hpp:54
A non-owning, read-only BSON element.
Definition view.hpp:84
v1::types::view type_view() const
Return a view of the underlying BSON type value.
A BSON ObjectID.
Definition oid.hpp:43
A polyfill for std::string_view.
Definition string_view.hpp:412
A union of BSON type values.
Definition value.hpp:54
id type_id() const
Return the type of the underlying BSON type value.
Definition view.hpp:1064
friend bool operator!=(v1::element::view const &e, view const &v)
Equivalent to !(v == e).
Definition view.hpp:1146
friend bool operator==(view const &v, v1::element::view const &e)
Equivalent to v == e.type_view().
Definition view.hpp:1128
friend bool operator==(view const &v, T const &value)
Equivalent to v == bsoncxx::v1::types::view{value}.
Definition view.hpp:1161
friend bool operator!=(view const &v, T const &value)
Equivalent to !(v == value).
Definition view.hpp:1177
friend bool operator!=(T const &value, view const &v)
Equivalent to !(v == value).
Definition view.hpp:1182
friend bool operator==(view const &lhs, view const &rhs)
Compare equal when the underlying BSON type values have the same type and compare equal.
Definition view.hpp:1097
friend std::error_code make_error_code(errc v)
Support implicit conversion to std::error_code.
Definition view.hpp:1210
view()
Initialize with bsoncxx::v1::types::b_null.
Definition view.hpp:1045
static std::error_category const & error_category()
The error category for bsoncxx::v1::types::view::errc.
friend bool operator!=(view const &lhs, view const &rhs)
Equivalent to !(lhs == rhs).
Definition view.hpp:1120
friend bool operator==(T const &value, view const &v)
Equivalent to v == bsoncxx::v1::types::view{value}.
Definition view.hpp:1166
errc
Errors codes which may be returned by bsoncxx::v1::types::view.
Definition view.hpp:1193
@ type_mismatch
Requested type does not match the underlying type.
Definition view.hpp:1195
@ zero
Zero.
Definition view.hpp:1194
friend bool operator!=(view const &v, v1::element::view const &e)
Equivalent to !(v == e).
Definition view.hpp:1142
friend bool operator==(v1::element::view const &e, view const &v)
Equivalent to v == e.type_view().
Definition view.hpp:1132
Declares entities representing a BSON type value.
binary_subtype
Enumeration identifying a BSON binary subtype.
Definition id.hpp:77
id
Enumeration identifying a BSON type.
Definition id.hpp:39
@ k_decimal128
128-bit decimal floating point.
Definition id.hpp:59
@ k_minkey
Min key.
Definition id.hpp:40
@ k_double
64-bit binary floating point.
Definition id.hpp:41
@ k_dbpointer
DBPointer.
Definition id.hpp:52
@ k_int64
64-bit integer.
Definition id.hpp:58
@ k_codewscope
JavaScript code with scope.
Definition id.hpp:55
@ k_regex
Regular expression.
Definition id.hpp:51
@ k_string
UTF-8 string.
Definition id.hpp:42
@ k_array
Array.
Definition id.hpp:44
@ k_bool
Boolean.
Definition id.hpp:48
@ k_symbol
Symbol.
Definition id.hpp:54
@ k_oid
ObjectId.
Definition id.hpp:47
@ k_date
UTC datetime.
Definition id.hpp:49
@ k_int32
32-bit integer.
Definition id.hpp:56
@ k_timestamp
Timestamp.
Definition id.hpp:57
@ k_undefined
Undefined value.
Definition id.hpp:46
@ k_code
JavaScript code.
Definition id.hpp:53
@ k_document
Embedded document.
Definition id.hpp:43
@ k_maxkey
Max key.
Definition id.hpp:60
@ k_binary
Binary data.
Definition id.hpp:45
@ k_null
Null value.
Definition id.hpp:50
Declares entities whose ABI stability is guaranteed for documented symbols.
The top-level namespace within which all bsoncxx library entities are declared.
b_array()=default
Zero-initialize the represented value.
friend bool operator==(b_array const &lhs, b_array const &rhs)
Equivalent to lhs.value == rhs.value.
Definition view.hpp:232
friend bool operator!=(b_array const &lhs, b_array const &rhs)
Equivalent to !(lhs == rhs).
Definition view.hpp:239
v1::array::view value
The represented value.
Definition view.hpp:210
static constexpr id type_id
The type represented by this BSON type value.
Definition view.hpp:205
b_array(v1::array::view value)
Initialize with value.
Definition view.hpp:220
friend bool operator==(b_binary const &lhs, b_binary const &rhs)
Compare equal when the binary subtype and pointed-to bytes compare equal.
Definition view.hpp:288
b_binary(binary_subtype subtype, std::uint32_t size, std::uint8_t const *bytes)
Initialize with the given binary subtype and pointer to binary data.
Definition view.hpp:278
b_binary()=default
Zero-initialize the represented value.
static constexpr id type_id
The type represented by this BSON type value.
Definition view.hpp:253
friend bool operator!=(b_binary const &lhs, b_binary const &rhs)
Compare equal when the binary subtype and pointed-to bytes compare equal.
Definition view.hpp:304
binary_subtype subtype
The represented value's binary subtype component.
Definition view.hpp:258
std::uint8_t const * bytes
The represented value's binary data.
Definition view.hpp:268
std::uint32_t size
The represented value's length of binary data.
Definition view.hpp:263
b_bool(bool value)
Initialize with value.
Definition view.hpp:411
bool value
The represented value.
Definition view.hpp:401
friend bool operator!=(b_bool const &lhs, b_bool const &rhs)
Equivalent to !(lhs == rhs).
Definition view.hpp:430
static constexpr id type_id
The type represented by this BSON type value.
Definition view.hpp:396
friend bool operator==(b_bool const &lhs, b_bool const &rhs)
Equivalent to lhs.value == rhs.value.
Definition view.hpp:423
b_bool()=default
Zero-initialize the represented value.
static constexpr id type_id
The type represented by this BSON type value.
Definition view.hpp:628
friend bool operator!=(b_code const &lhs, b_code const &rhs)
Equivalent to !(lhs == rhs).
Definition view.hpp:662
v1::stdx::string_view code
The represented value.
Definition view.hpp:633
friend bool operator==(b_code const &lhs, b_code const &rhs)
Equivalent to lhs.code == rhs.code.
Definition view.hpp:655
b_code()=default
Zero-initialize the represented value.
b_code(v1::stdx::string_view code)
Initialize with code.
Definition view.hpp:643
v1::document::view scope
The represented value's "$scope" component.
Definition view.hpp:738
b_codewscope()=default
Zero-initialize the represented value.
friend bool operator==(b_codewscope const &lhs, b_codewscope const &rhs)
Equivalent to lhs.code == rhs.code && lhs.scope == rhs.scope.
Definition view.hpp:753
static constexpr id type_id
The type represented by this BSON type value.
Definition view.hpp:728
friend bool operator!=(b_codewscope const &lhs, b_codewscope const &rhs)
Equivalent to !(lhs == rhs).
Definition view.hpp:760
b_codewscope(v1::stdx::string_view code, v1::document::view scope)
Initialize with code and scope.
Definition view.hpp:748
v1::stdx::string_view code
The represented value's "$code" component.
Definition view.hpp:733
std::chrono::milliseconds value
The represented value (milliseconds relative to the Unix epoch).
Definition view.hpp:449
friend bool operator==(b_date const &lhs, b_date const &rhs)
Equivalent to lhs.value == rhs.value.
Definition view.hpp:482
friend bool operator!=(b_date const &lhs, b_date const &rhs)
Equivalent to !(lhs == rhs).
Definition view.hpp:489
static constexpr id type_id
The type represented by this BSON type value.
Definition view.hpp:444
b_date()=default
Zero-initialize the represented value.
b_date(std::chrono::milliseconds value)
Initialize with value (milliseconds relative to the Unix epoch).
Definition view.hpp:459
b_date(std::chrono::system_clock::time_point tp)
Initialize with tp (assuming the epoch of std::chrono::system_clock is the Unix epoch).
Definition view.hpp:464
friend bool operator==(b_dbpointer const &lhs, b_dbpointer const &rhs)
Equivalent to lhs.collection == rhs.collection && lhs.value == rhs.value.
Definition view.hpp:607
b_dbpointer(v1::stdx::string_view collection, v1::oid value)
Initialize with collection and value.
Definition view.hpp:602
friend bool operator!=(b_dbpointer const &lhs, b_dbpointer const &rhs)
Equivalent to !(lhs == rhs).
Definition view.hpp:614
static constexpr id type_id
The type represented by this BSON type value.
Definition view.hpp:582
b_dbpointer()=default
Zero-initialize the represented value.
v1::oid value
The represented value's "$id" (ObjectID) component.
Definition view.hpp:592
v1::stdx::string_view collection
The represented value's "$ref" (namespace) component.
Definition view.hpp:587
friend bool operator!=(b_decimal128 const &lhs, b_decimal128 const &rhs)
Equivalent to !(lhs == rhs).
Definition view.hpp:950
b_decimal128()=default
Zero-initialize the represented value.
friend bool operator==(b_decimal128 const &lhs, b_decimal128 const &rhs)
Equivalent to lhs.value == rhs.value.
Definition view.hpp:943
static constexpr id type_id
The type represented by this BSON type value.
Definition view.hpp:916
b_decimal128(v1::decimal128 value)
Initialize with value.
Definition view.hpp:931
v1::decimal128 value
The represented value.
Definition view.hpp:921
friend bool operator==(b_document const &lhs, b_document const &rhs)
Equivalent to lhs.value == rhs.value.
Definition view.hpp:184
operator v1::document::view() const
Implicitly convert to value.
Definition view.hpp:173
static constexpr id type_id
The type represented by this BSON type value.
Definition view.hpp:153
v1::document::view value
The represented value.
Definition view.hpp:158
friend bool operator!=(b_document const &lhs, b_document const &rhs)
Equivalent to !(lhs == rhs).
Definition view.hpp:191
b_document()=default
Zero-initialize the represented value.
b_document(v1::document::view value)
Initialize with value.
Definition view.hpp:168
b_double(double value)
Initialize with value.
Definition view.hpp:69
friend bool operator!=(b_double const &lhs, b_double const &rhs)
Equivalent to !(lhs == rhs).
Definition view.hpp:91
double value
The represented value.
Definition view.hpp:59
friend bool operator==(b_double const &lhs, b_double const &rhs)
Equivalent to lhs.value == rhs.value.
Definition view.hpp:81
b_double()=default
Zero-initialize the represented value.
static constexpr id type_id
The type represented by this BSON type value.
Definition view.hpp:54
friend bool operator==(b_int32 const &lhs, b_int32 const &rhs)
Equivalent to lhs.value == rhs.value.
Definition view.hpp:801
b_int32()=default
Zero-initialize the represented value.
static constexpr id type_id
The type represented by this BSON type value.
Definition view.hpp:774
std::int32_t value
The represented value.
Definition view.hpp:779
friend bool operator!=(b_int32 const &lhs, b_int32 const &rhs)
Equivalent to !(lhs == rhs).
Definition view.hpp:808
b_int32(std::int32_t value)
Initialize with value.
Definition view.hpp:789
static constexpr id type_id
The type represented by this BSON type value.
Definition view.hpp:868
friend bool operator!=(b_int64 const &lhs, b_int64 const &rhs)
Equivalent to !(lhs == rhs).
Definition view.hpp:902
friend bool operator==(b_int64 const &lhs, b_int64 const &rhs)
Equivalent to lhs.value == rhs.value.
Definition view.hpp:895
b_int64(std::int64_t value)
Initialize with value.
Definition view.hpp:883
b_int64()=default
Zero-initialize the represented value.
std::int64_t value
The represented value.
Definition view.hpp:873
BSON type value "Max Key".
Definition view.hpp:960
friend bool operator!=(b_maxkey const &lhs, b_maxkey const &rhs)
Return false.
Definition view.hpp:976
static constexpr id type_id
The type represented by this BSON type value.
Definition view.hpp:964
friend bool operator==(b_maxkey const &, b_maxkey const &)
Return true.
Definition view.hpp:969
BSON type value "Min Key".
Definition view.hpp:986
static constexpr id type_id
The type represented by this BSON type value.
Definition view.hpp:990
friend bool operator==(b_minkey const &, b_minkey const &)
Return true.
Definition view.hpp:995
friend bool operator!=(b_minkey const &lhs, b_minkey const &rhs)
Return false.
Definition view.hpp:1002
BSON type value "Null Value".
Definition view.hpp:499
friend bool operator==(b_null const &, b_null const &)
Return true.
Definition view.hpp:508
static constexpr id type_id
The type represented by this BSON type value.
Definition view.hpp:503
friend bool operator!=(b_null const &lhs, b_null const &rhs)
Return false.
Definition view.hpp:515
v1::oid value
The represented value.
Definition view.hpp:353
b_oid()=default
Zero-initialize the represented value.
b_oid(v1::oid const &value)
Initialize with value.
Definition view.hpp:363
friend bool operator==(b_oid const &lhs, b_oid const &rhs)
Equivalent to lhs.value == rhs.value.
Definition view.hpp:375
friend bool operator!=(b_oid const &lhs, b_oid const &rhs)
Equivalent to !(lhs == rhs).
Definition view.hpp:382
static constexpr id type_id
The type represented by this BSON type value.
Definition view.hpp:348
b_regex(v1::stdx::string_view regex, v1::stdx::string_view options)
Initialize with regex and options.
Definition view.hpp:554
static constexpr id type_id
The type represented by this BSON type value.
Definition view.hpp:529
v1::stdx::string_view regex
The represented value's "pattern" component.
Definition view.hpp:534
b_regex(v1::stdx::string_view regex)
Initialize with regex and an empty options.
Definition view.hpp:549
friend bool operator!=(b_regex const &lhs, b_regex const &rhs)
Equivalent to !(lhs == rhs).
Definition view.hpp:566
b_regex()=default
Zero-initialize the represented value.
v1::stdx::string_view options
The represented value's "options" component.
Definition view.hpp:539
friend bool operator==(b_regex const &lhs, b_regex const &rhs)
Equivalent to lhs.regex == rhs.regex && lhs.options == rhs.options.
Definition view.hpp:559
friend bool operator==(b_string const &lhs, b_string const &rhs)
Equivalent to lhs.value == rhs.value.
Definition view.hpp:132
b_string(v1::stdx::string_view value)
Initialize with value.
Definition view.hpp:120
v1::stdx::string_view value
The represented value.
Definition view.hpp:110
b_string()=default
Zero-initialize the represented value.
friend bool operator!=(b_string const &lhs, b_string const &rhs)
Equivalent to !(lhs == rhs).
Definition view.hpp:139
static constexpr id type_id
The type represented by this BSON type value.
Definition view.hpp:105
v1::stdx::string_view symbol
The represented value.
Definition view.hpp:683
b_symbol(v1::stdx::string_view symbol)
Initialize with symbol.
Definition view.hpp:693
friend bool operator==(b_symbol const &lhs, b_symbol const &rhs)
Equivalent to lhs.symbol == rhs.symbol.
Definition view.hpp:705
static constexpr id type_id
The type represented by this BSON type value.
Definition view.hpp:678
friend bool operator!=(b_symbol const &lhs, b_symbol const &rhs)
Equivalent to !(lhs == rhs).
Definition view.hpp:712
b_symbol()=default
Zero-initialize the represented value.
std::uint32_t increment
The represented value's "i" component.
Definition view.hpp:827
b_timestamp()=default
Zero-initialize the represented value.
friend bool operator==(b_timestamp const &lhs, b_timestamp const &rhs)
Equivalent to lhs.timestamp == rhs.timestamp.
Definition view.hpp:847
static constexpr id type_id
The type represented by this BSON type value.
Definition view.hpp:822
b_timestamp(std::uint32_t increment, std::uint32_t timestamp)
Initialize with increment and timestamp.
Definition view.hpp:842
std::uint32_t timestamp
The represented value's "t" component.
Definition view.hpp:832
friend bool operator!=(b_timestamp const &lhs, b_timestamp const &rhs)
Equivalent to !(lhs == rhs).
Definition view.hpp:854
BSON type value "Undefined (Value)".
Definition view.hpp:318
friend bool operator!=(b_undefined const &lhs, b_undefined const &rhs)
Return false.
Definition view.hpp:334
friend bool operator==(b_undefined const &, b_undefined const &)
Return true.
Definition view.hpp:327
static constexpr id type_id
The type represented by this BSON type value.
Definition view.hpp:322
Provides bsoncxx::v1::array::view.
Provides bsoncxx::v1::decimal128.
Provides bsoncxx::v1::document::view.
Provides bsoncxx::v1::oid.
Provides std::string_view-related polyfills for library API usage.
#define BSONCXX_V1_TYPES_XMACRO(X)
X-macro over the name and value of BSON types.
Definition id-fwd.hpp:44
Provides enumerations identifying the type of a BSON element.
Declares non-owning, read-only entities representing a BSON type value.