36#include <system_error>
72 operator double()
const {
80 BSONCXX_PRIVATE_WARNINGS_PUSH();
81 BSONCXX_PRIVATE_WARNINGS_DISABLE(GNU(
"-Wfloat-equal"));
83 BSONCXX_PRIVATE_WARNINGS_POP();
136 return !(lhs == rhs);
186 return !(lhs == rhs);
232 return !(lhs == rhs);
295 return !(lhs == rhs);
323 return !(lhs == rhs);
369 return !(lhs == rhs);
400 operator bool()
const {
415 return !(lhs == rhs);
431 std::chrono::milliseconds
value = {};
446 explicit b_date(std::chrono::system_clock::time_point tp)
447 :
value{std::chrono::duration_cast<std::chrono::milliseconds>(tp.time_since_epoch())} {}
452 operator std::chrono::milliseconds()
const {
456 explicit operator std::chrono::system_clock::time_point()
const {
457 return std::chrono::system_clock::time_point(
458 std::chrono::duration_cast<std::chrono::system_clock::duration>(
value));
472 return !(lhs == rhs);
496 return !(lhs == rhs);
545 return !(lhs == rhs);
591 return !(lhs == rhs);
637 return !(lhs == rhs);
685 return !(lhs == rhs);
731 return !(lhs == rhs);
762 operator std::int32_t()
const {
777 return !(lhs == rhs);
821 return !(lhs == rhs);
852 operator std::int64_t()
const {
867 return !(lhs == rhs);
913 return !(lhs == rhs);
937 return !(lhs == rhs);
961 return !(lhs == rhs);
967#pragma push_macro("X")
969#define X(_name, _val) BSONCXX_PRIVATE_INLINE_CXX17 constexpr id b_##_name::type_id;
971#pragma pop_macro("X")
983#pragma push_macro("X")
985#define X(_name, _value) b_##_name _b_##_name;
990#pragma pop_macro("X")
992 template <
typename T>
993 using is_view = detail::is_alike<T, view>;
995 template <
typename T>
996 struct is_equality_comparable_with
997 : detail::conjunction<detail::negation<is_view<T>>, std::is_constructible<view, T>> {};
1003#pragma push_macro("X")
1005#define X(_name, _value) \
1006 view(b_##_name v) : _id{v.type_id}, _b_##_name{v} {}
1015#pragma pop_macro("X")
1024#pragma push_macro("X")
1026#define X(_name, _value) BSONCXX_ABI_EXPORT_CDECL(b_##_name) get_##_name() const;
1038#pragma pop_macro("X")
1058#pragma push_macro("X")
1060#define X(_name, _value) \
1061 case v1::types::id::k_##_name: \
1062 return lhs.get_##_name() == rhs.get_##_name();
1070#pragma pop_macro("X")
1077 return !(lhs == rhs);
1116 template <typename T, detail::enable_if_t<is_equality_comparable_with<T>::value>* =
nullptr>
1121 template <typename T, detail::enable_if_t<is_equality_comparable_with<T>::value>* =
nullptr>
1132 template <typename T, detail::enable_if_t<is_equality_comparable_with<T>::value>* =
nullptr>
1134 return !(v ==
value);
1137 template <typename T, detail::enable_if_t<is_equality_comparable_with<T>::value>* =
nullptr>
1139 return !(v ==
value);
1172struct 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:47
A BSON Decimal128.
Definition decimal128.hpp:37
A non-owning, read-only BSON document.
Definition view.hpp:52
A non-owning, read-only BSON element.
Definition view.hpp:82
v1::types::view type_view() const
Return a view of the underlying BSON type value.
A BSON ObjectID.
Definition oid.hpp:41
A polyfill for std::string_view.
Definition string_view.hpp:412
A union of BSON type values.
Definition value.hpp:52
id type_id() const
Return the type of the underlying BSON type value.
Definition view.hpp:1020
friend bool operator!=(v1::element::view const &e, view const &v)
Equivalent to !(v == e).
Definition view.hpp:1102
friend bool operator==(view const &v, v1::element::view const &e)
Equivalent to v == e.type_view().
Definition view.hpp:1084
friend bool operator==(view const &v, T const &value)
Equivalent to v == bsoncxx::v1::types::view{value}.
Definition view.hpp:1117
friend bool operator!=(view const &v, T const &value)
Equivalent to !(v == value).
Definition view.hpp:1133
friend bool operator!=(T const &value, view const &v)
Equivalent to !(v == value).
Definition view.hpp:1138
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:1053
friend std::error_code make_error_code(errc v)
Support implicit conversion to std::error_code.
Definition view.hpp:1160
view()
Initialize with bsoncxx::v1::types::b_null.
Definition view.hpp:1001
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:1076
friend bool operator==(T const &value, view const &v)
Equivalent to v == bsoncxx::v1::types::view{value}.
Definition view.hpp:1122
errc
Errors codes which may be returned by bsoncxx::v1::types::view.
Definition view.hpp:1147
@ type_mismatch
Requested type does not match the underlying type.
Definition view.hpp:1149
@ zero
Zero.
Definition view.hpp:1148
friend bool operator!=(view const &v, v1::element::view const &e)
Equivalent to !(v == e).
Definition view.hpp:1098
friend bool operator==(v1::element::view const &e, view const &v)
Equivalent to v == e.type_view().
Definition view.hpp:1088
Declares entities representing a BSON type value.
binary_subtype
Enumeration identifying a BSON binary subtype.
Definition id.hpp:71
id
Enumeration identifying a BSON type.
Definition id.hpp:37
@ k_decimal128
128-bit decimal floating point.
Definition id.hpp:57
@ k_minkey
Min key.
Definition id.hpp:38
@ k_double
64-bit binary floating point.
Definition id.hpp:39
@ k_dbpointer
DBPointer.
Definition id.hpp:50
@ k_int64
64-bit integer.
Definition id.hpp:56
@ k_codewscope
JavaScript code with scope.
Definition id.hpp:53
@ k_regex
Regular expression.
Definition id.hpp:49
@ k_string
UTF-8 string.
Definition id.hpp:40
@ k_array
Array.
Definition id.hpp:42
@ k_bool
Boolean.
Definition id.hpp:46
@ k_symbol
Symbol.
Definition id.hpp:52
@ k_oid
ObjectId.
Definition id.hpp:45
@ k_date
UTC datetime.
Definition id.hpp:47
@ k_int32
32-bit integer.
Definition id.hpp:54
@ k_timestamp
Timestamp.
Definition id.hpp:55
@ k_undefined
Undefined value.
Definition id.hpp:44
@ k_code
JavaScript code.
Definition id.hpp:51
@ k_document
Embedded document.
Definition id.hpp:41
@ k_maxkey
Max key.
Definition id.hpp:58
@ k_binary
Binary data.
Definition id.hpp:43
@ k_null
Null value.
Definition id.hpp:48
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:224
friend bool operator!=(b_array const &lhs, b_array const &rhs)
Equivalent to !(lhs == rhs).
Definition view.hpp:231
v1::array::view value
The represented value.
Definition view.hpp:202
static constexpr id type_id
The type represented by this BSON type value.
Definition view.hpp:197
b_array(v1::array::view value)
Initialize with value.
Definition view.hpp:212
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:278
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:268
b_binary()=default
Zero-initialize the represented value.
static constexpr id type_id
The type represented by this BSON type value.
Definition view.hpp:243
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:294
binary_subtype subtype
The represented value's binary subtype component.
Definition view.hpp:248
std::uint8_t const * bytes
The represented value's binary data.
Definition view.hpp:258
std::uint32_t size
The represented value's length of binary data.
Definition view.hpp:253
b_bool(bool value)
Initialize with value.
Definition view.hpp:395
bool value
The represented value.
Definition view.hpp:385
friend bool operator!=(b_bool const &lhs, b_bool const &rhs)
Equivalent to !(lhs == rhs).
Definition view.hpp:414
static constexpr id type_id
The type represented by this BSON type value.
Definition view.hpp:380
friend bool operator==(b_bool const &lhs, b_bool const &rhs)
Equivalent to lhs.value == rhs.value.
Definition view.hpp:407
b_bool()=default
Zero-initialize the represented value.
static constexpr id type_id
The type represented by this BSON type value.
Definition view.hpp:602
friend bool operator!=(b_code const &lhs, b_code const &rhs)
Equivalent to !(lhs == rhs).
Definition view.hpp:636
v1::stdx::string_view code
The represented value.
Definition view.hpp:607
friend bool operator==(b_code const &lhs, b_code const &rhs)
Equivalent to lhs.code == rhs.code.
Definition view.hpp:629
b_code()=default
Zero-initialize the represented value.
b_code(v1::stdx::string_view code)
Initialize with code.
Definition view.hpp:617
v1::document::view scope
The represented value's "$scope" component.
Definition view.hpp:708
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:723
static constexpr id type_id
The type represented by this BSON type value.
Definition view.hpp:698
friend bool operator!=(b_codewscope const &lhs, b_codewscope const &rhs)
Equivalent to !(lhs == rhs).
Definition view.hpp:730
b_codewscope(v1::stdx::string_view code, v1::document::view scope)
Initialize with code and scope.
Definition view.hpp:718
v1::stdx::string_view code
The represented value's "$code" component.
Definition view.hpp:703
std::chrono::milliseconds value
The represented value (milliseconds relative to the Unix epoch).
Definition view.hpp:431
friend bool operator==(b_date const &lhs, b_date const &rhs)
Equivalent to lhs.value == rhs.value.
Definition view.hpp:464
friend bool operator!=(b_date const &lhs, b_date const &rhs)
Equivalent to !(lhs == rhs).
Definition view.hpp:471
static constexpr id type_id
The type represented by this BSON type value.
Definition view.hpp:426
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:441
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:446
friend bool operator==(b_dbpointer const &lhs, b_dbpointer const &rhs)
Equivalent to lhs.collection == rhs.collection && lhs.value == rhs.value.
Definition view.hpp:583
b_dbpointer(v1::stdx::string_view collection, v1::oid value)
Initialize with collection and value.
Definition view.hpp:578
friend bool operator!=(b_dbpointer const &lhs, b_dbpointer const &rhs)
Equivalent to !(lhs == rhs).
Definition view.hpp:590
static constexpr id type_id
The type represented by this BSON type value.
Definition view.hpp:558
b_dbpointer()=default
Zero-initialize the represented value.
v1::oid value
The represented value's "$id" (ObjectID) component.
Definition view.hpp:568
v1::stdx::string_view collection
The represented value's "$ref" (namespace) component.
Definition view.hpp:563
friend bool operator!=(b_decimal128 const &lhs, b_decimal128 const &rhs)
Equivalent to !(lhs == rhs).
Definition view.hpp:912
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:905
static constexpr id type_id
The type represented by this BSON type value.
Definition view.hpp:878
b_decimal128(v1::decimal128 value)
Initialize with value.
Definition view.hpp:893
v1::decimal128 value
The represented value.
Definition view.hpp:883
friend bool operator==(b_document const &lhs, b_document const &rhs)
Equivalent to lhs.value == rhs.value.
Definition view.hpp:178
operator v1::document::view() const
Implicitly convert to value.
Definition view.hpp:167
static constexpr id type_id
The type represented by this BSON type value.
Definition view.hpp:147
v1::document::view value
The represented value.
Definition view.hpp:152
friend bool operator!=(b_document const &lhs, b_document const &rhs)
Equivalent to !(lhs == rhs).
Definition view.hpp:185
b_document()=default
Zero-initialize the represented value.
b_document(v1::document::view value)
Initialize with value.
Definition view.hpp:162
b_double(double value)
Initialize with value.
Definition view.hpp:67
friend bool operator!=(b_double const &lhs, b_double const &rhs)
Equivalent to !(lhs == rhs).
Definition view.hpp:89
double value
The represented value.
Definition view.hpp:57
friend bool operator==(b_double const &lhs, b_double const &rhs)
Equivalent to lhs.value == rhs.value.
Definition view.hpp:79
b_double()=default
Zero-initialize the represented value.
static constexpr id type_id
The type represented by this BSON type value.
Definition view.hpp:52
friend bool operator==(b_int32 const &lhs, b_int32 const &rhs)
Equivalent to lhs.value == rhs.value.
Definition view.hpp:769
b_int32()=default
Zero-initialize the represented value.
static constexpr id type_id
The type represented by this BSON type value.
Definition view.hpp:742
std::int32_t value
The represented value.
Definition view.hpp:747
friend bool operator!=(b_int32 const &lhs, b_int32 const &rhs)
Equivalent to !(lhs == rhs).
Definition view.hpp:776
b_int32(std::int32_t value)
Initialize with value.
Definition view.hpp:757
static constexpr id type_id
The type represented by this BSON type value.
Definition view.hpp:832
friend bool operator!=(b_int64 const &lhs, b_int64 const &rhs)
Equivalent to !(lhs == rhs).
Definition view.hpp:866
friend bool operator==(b_int64 const &lhs, b_int64 const &rhs)
Equivalent to lhs.value == rhs.value.
Definition view.hpp:859
b_int64(std::int64_t value)
Initialize with value.
Definition view.hpp:847
b_int64()=default
Zero-initialize the represented value.
std::int64_t value
The represented value.
Definition view.hpp:837
BSON type value "Max Key".
Definition view.hpp:920
friend bool operator!=(b_maxkey const &lhs, b_maxkey const &rhs)
Return false.
Definition view.hpp:936
static constexpr id type_id
The type represented by this BSON type value.
Definition view.hpp:924
friend bool operator==(b_maxkey const &, b_maxkey const &)
Return true.
Definition view.hpp:929
BSON type value "Min Key".
Definition view.hpp:944
static constexpr id type_id
The type represented by this BSON type value.
Definition view.hpp:948
friend bool operator==(b_minkey const &, b_minkey const &)
Return true.
Definition view.hpp:953
friend bool operator!=(b_minkey const &lhs, b_minkey const &rhs)
Return false.
Definition view.hpp:960
BSON type value "Null Value".
Definition view.hpp:479
friend bool operator==(b_null const &, b_null const &)
Return true.
Definition view.hpp:488
static constexpr id type_id
The type represented by this BSON type value.
Definition view.hpp:483
friend bool operator!=(b_null const &lhs, b_null const &rhs)
Return false.
Definition view.hpp:495
v1::oid value
The represented value.
Definition view.hpp:339
b_oid()=default
Zero-initialize the represented value.
b_oid(v1::oid const &value)
Initialize with value.
Definition view.hpp:349
friend bool operator==(b_oid const &lhs, b_oid const &rhs)
Equivalent to lhs.value == rhs.value.
Definition view.hpp:361
friend bool operator!=(b_oid const &lhs, b_oid const &rhs)
Equivalent to !(lhs == rhs).
Definition view.hpp:368
static constexpr id type_id
The type represented by this BSON type value.
Definition view.hpp:334
b_regex(v1::stdx::string_view regex, v1::stdx::string_view options)
Initialize with regex and options.
Definition view.hpp:532
static constexpr id type_id
The type represented by this BSON type value.
Definition view.hpp:507
v1::stdx::string_view regex
The represented value's "pattern" component.
Definition view.hpp:512
b_regex(v1::stdx::string_view regex)
Initialize with regex and an empty options.
Definition view.hpp:527
friend bool operator!=(b_regex const &lhs, b_regex const &rhs)
Equivalent to !(lhs == rhs).
Definition view.hpp:544
b_regex()=default
Zero-initialize the represented value.
v1::stdx::string_view options
The represented value's "options" component.
Definition view.hpp:517
friend bool operator==(b_regex const &lhs, b_regex const &rhs)
Equivalent to lhs.regex == rhs.regex && lhs.options == rhs.options.
Definition view.hpp:537
friend bool operator==(b_string const &lhs, b_string const &rhs)
Equivalent to lhs.value == rhs.value.
Definition view.hpp:128
b_string(v1::stdx::string_view value)
Initialize with value.
Definition view.hpp:116
v1::stdx::string_view value
The represented value.
Definition view.hpp:106
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:135
static constexpr id type_id
The type represented by this BSON type value.
Definition view.hpp:101
v1::stdx::string_view symbol
The represented value.
Definition view.hpp:655
b_symbol(v1::stdx::string_view symbol)
Initialize with symbol.
Definition view.hpp:665
friend bool operator==(b_symbol const &lhs, b_symbol const &rhs)
Equivalent to lhs.symbol == rhs.symbol.
Definition view.hpp:677
static constexpr id type_id
The type represented by this BSON type value.
Definition view.hpp:650
friend bool operator!=(b_symbol const &lhs, b_symbol const &rhs)
Equivalent to !(lhs == rhs).
Definition view.hpp:684
b_symbol()=default
Zero-initialize the represented value.
std::uint32_t increment
The represented value's "i" component.
Definition view.hpp:793
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:813
static constexpr id type_id
The type represented by this BSON type value.
Definition view.hpp:788
b_timestamp(std::uint32_t increment, std::uint32_t timestamp)
Initialize with increment and timestamp.
Definition view.hpp:808
std::uint32_t timestamp
The represented value's "t" component.
Definition view.hpp:798
friend bool operator!=(b_timestamp const &lhs, b_timestamp const &rhs)
Equivalent to !(lhs == rhs).
Definition view.hpp:820
BSON type value "Undefined (Value)".
Definition view.hpp:306
friend bool operator!=(b_undefined const &lhs, b_undefined const &rhs)
Return false.
Definition view.hpp:322
friend bool operator==(b_undefined const &, b_undefined const &)
Return true.
Definition view.hpp:315
static constexpr id type_id
The type represented by this BSON type value.
Definition view.hpp:310
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.