MongoDB C++ Driver 4.2.0
Loading...
Searching...
No Matches
view.hpp
Go to the documentation of this file.
1// Copyright 2009-present MongoDB, Inc.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15#pragma once
16
17#include <bsoncxx/v1/types/view-fwd.hpp> // IWYU pragma: export
18
19//
20
22
23#include <bsoncxx/v1/array/view.hpp> // IWYU pragma: export
25#include <bsoncxx/v1/decimal128.hpp> // IWYU pragma: export
28#include <bsoncxx/v1/document/view.hpp> // IWYU pragma: export
29#include <bsoncxx/v1/oid.hpp> // IWYU pragma: export
31#include <bsoncxx/v1/types/id.hpp> // IWYU pragma: export
32
33#include <chrono>
34#include <cstdint>
35#include <cstring>
36#include <system_error>
37#include <type_traits>
38
39namespace bsoncxx {
40namespace v1 {
41namespace types {
42
43// BSONCXX_V1_TYPES_XMACRO: update below.
44
50struct b_double {
54 static constexpr id type_id = id::k_double;
55
59 double value = {};
60
64 b_double() = default;
65
69 explicit b_double(double value) : value{value} {}
70
74 /* explicit(false) */ operator double() const {
75 return value;
76 }
77
81 friend bool operator==(b_double const& lhs, b_double const& rhs) {
82 BSONCXX_PRIVATE_WARNINGS_PUSH();
83 BSONCXX_PRIVATE_WARNINGS_DISABLE(GNU("-Wfloat-equal"));
84 return lhs.value == rhs.value;
85 BSONCXX_PRIVATE_WARNINGS_POP();
86 }
87
91 friend bool operator!=(b_double const& lhs, b_double const& rhs) {
92 return !(lhs == rhs);
93 }
94};
95
101struct b_string {
105 static constexpr id type_id = id::k_string;
106
111
115 b_string() = default;
116
121
125 /* explicit(false) */ operator v1::stdx::string_view() const {
126 return value;
127 }
128
132 friend bool operator==(b_string const& lhs, b_string const& rhs) {
133 return lhs.value == rhs.value;
134 }
135
139 friend bool operator!=(b_string const& lhs, b_string const& rhs) {
140 return !(lhs == rhs);
141 }
142};
143
153 static constexpr id type_id = id::k_document;
154
159
163 b_document() = default;
164
169
173 /* explicit(false) */ operator v1::document::view() const {
174 return value;
175 }
176
178 return value;
179 }
180
184 friend bool operator==(b_document const& lhs, b_document const& rhs) {
185 return lhs.value == rhs.value;
186 }
187
191 friend bool operator!=(b_document const& lhs, b_document const& rhs) {
192 return !(lhs == rhs);
193 }
194};
195
201struct b_array {
205 static constexpr id type_id = id::k_array;
206
211
215 b_array() = default;
216
221
225 /* explicit(false) */ operator v1::array::view() const {
226 return value;
227 }
228
232 friend bool operator==(b_array const& lhs, b_array const& rhs) {
233 return lhs.value == rhs.value;
234 }
235
239 friend bool operator!=(b_array const& lhs, b_array const& rhs) {
240 return !(lhs == rhs);
241 }
242};
243
249struct b_binary {
253 static constexpr id type_id = id::k_binary;
254
259
263 std::uint32_t size = {};
264
268 std::uint8_t const* bytes = {};
269
273 b_binary() = default;
274
278 b_binary(binary_subtype subtype, std::uint32_t size, std::uint8_t const* bytes)
280
288 friend bool operator==(b_binary const& lhs, b_binary const& rhs) {
289 if (lhs.size != rhs.size) {
290 return false;
291 }
292
293 if (!lhs.bytes != !rhs.bytes) {
294 return false;
295 }
296
297 if (!lhs.bytes || lhs.size == 0u) {
298 return true; // Empty.
299 }
300
301 return lhs.subtype == rhs.subtype && (std::memcmp(lhs.bytes, rhs.bytes, lhs.size) == 0);
302 }
303
304 friend bool operator!=(b_binary const& lhs, b_binary const& rhs) {
305 return !(lhs == rhs);
306 }
307
309};
310
322 static constexpr id type_id = id::k_undefined;
323
327 friend bool operator==(b_undefined const&, b_undefined const&) {
328 return true;
329 }
330
334 friend bool operator!=(b_undefined const& lhs, b_undefined const& rhs) {
335 return !(lhs == rhs);
336 }
337};
338
344struct b_oid {
348 static constexpr id type_id = id::k_oid;
349
354
358 b_oid() = default;
359
363 explicit b_oid(v1::oid const& value) : value{value} {}
364
368 /* explicit(false) */ operator v1::oid() const {
369 return value;
370 }
371
375 friend bool operator==(b_oid const& lhs, b_oid const& rhs) {
376 return lhs.value == rhs.value;
377 }
378
382 friend bool operator!=(b_oid const& lhs, b_oid const& rhs) {
383 return !(lhs == rhs);
384 }
385};
386
392struct b_bool {
396 static constexpr id type_id = id::k_bool;
397
401 bool value = false;
402
406 b_bool() = default;
407
411 explicit b_bool(bool value) : value{value} {}
412
416 /* explicit(false) */ operator bool() const {
417 return value;
418 }
419
423 friend bool operator==(b_bool const& lhs, b_bool const& rhs) {
424 return lhs.value == rhs.value;
425 }
426
430 friend bool operator!=(b_bool const& lhs, b_bool const& rhs) {
431 return !(lhs == rhs);
432 }
433};
434
440struct b_date {
444 static constexpr id type_id = id::k_date;
445
449 std::chrono::milliseconds value = {};
450
454 b_date() = default;
455
459 explicit b_date(std::chrono::milliseconds value) : value{value} {}
460
464 explicit b_date(std::chrono::system_clock::time_point tp)
465 : value{std::chrono::duration_cast<std::chrono::milliseconds>(tp.time_since_epoch())} {}
466
470 /* explicit(false) */ operator std::chrono::milliseconds() const {
471 return value;
472 }
473
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));
477 }
478
482 friend bool operator==(b_date const& lhs, b_date const& rhs) {
483 return lhs.value == rhs.value;
484 }
485
489 friend bool operator!=(b_date const& lhs, b_date const& rhs) {
490 return !(lhs == rhs);
491 }
492};
493
499struct b_null {
503 static constexpr id type_id = id::k_null;
504
508 friend bool operator==(b_null const& /* lhs */, b_null const& /* rhs */) {
509 return true;
510 }
511
515 friend bool operator!=(b_null const& lhs, b_null const& rhs) {
516 return !(lhs == rhs);
517 }
518};
519
525struct b_regex {
529 static constexpr id type_id = id::k_regex;
530
535
540
544 b_regex() = default;
545
550
555
559 friend bool operator==(b_regex const& lhs, b_regex const& rhs) {
560 return lhs.regex == rhs.regex && lhs.options == rhs.options;
561 }
562
566 friend bool operator!=(b_regex const& lhs, b_regex const& rhs) {
567 return !(lhs == rhs);
568 }
569};
570
582 static constexpr id type_id = id::k_dbpointer;
583
588
593
597 b_dbpointer() = default;
598
603
607 friend bool operator==(b_dbpointer const& lhs, b_dbpointer const& rhs) {
608 return lhs.collection == rhs.collection && lhs.value == rhs.value;
609 }
610
614 friend bool operator!=(b_dbpointer const& lhs, b_dbpointer const& rhs) {
615 return !(lhs == rhs);
616 }
617};
618
624struct b_code {
628 static constexpr id type_id = id::k_code;
629
634
638 b_code() = default;
639
644
648 /* explicit(false) */ operator v1::stdx::string_view() const {
649 return code;
650 }
651
655 friend bool operator==(b_code const& lhs, b_code const& rhs) {
656 return lhs.code == rhs.code;
657 }
658
662 friend bool operator!=(b_code const& lhs, b_code const& rhs) {
663 return !(lhs == rhs);
664 }
665};
666
674struct b_symbol {
678 static constexpr id type_id = id::k_symbol;
679
684
688 b_symbol() = default;
689
694
698 /* explicit(false) */ operator v1::stdx::string_view() const {
699 return symbol;
700 }
701
705 friend bool operator==(b_symbol const& lhs, b_symbol const& rhs) {
706 return lhs.symbol == rhs.symbol;
707 }
708
712 friend bool operator!=(b_symbol const& lhs, b_symbol const& rhs) {
713 return !(lhs == rhs);
714 }
715};
716
728 static constexpr id type_id = id::k_codewscope;
729
734
739
743 b_codewscope() = default;
744
749
753 friend bool operator==(b_codewscope const& lhs, b_codewscope const& rhs) {
754 return lhs.code == rhs.code && lhs.scope == rhs.scope;
755 }
756
760 friend bool operator!=(b_codewscope const& lhs, b_codewscope const& rhs) {
761 return !(lhs == rhs);
762 }
763};
764
770struct b_int32 {
774 static constexpr id type_id = id::k_int32;
775
779 std::int32_t value = {};
780
784 b_int32() = default;
785
789 explicit b_int32(std::int32_t value) : value{value} {}
790
794 /* explicit(false) */ operator std::int32_t() const {
795 return value;
796 }
797
801 friend bool operator==(b_int32 const& lhs, b_int32 const& rhs) {
802 return lhs.value == rhs.value;
803 }
804
808 friend bool operator!=(b_int32 const& lhs, b_int32 const& rhs) {
809 return !(lhs == rhs);
810 }
811};
812
822 static constexpr id type_id = id::k_timestamp;
823
827 std::uint32_t increment = {};
828
832 std::uint32_t timestamp = {};
833
837 b_timestamp() = default;
838
843
847 friend bool operator==(b_timestamp const& lhs, b_timestamp const& rhs) {
848 return lhs.timestamp == rhs.timestamp;
849 }
850
854 friend bool operator!=(b_timestamp const& lhs, b_timestamp const& rhs) {
855 return !(lhs == rhs);
856 }
857};
858
864struct b_int64 {
868 static constexpr id type_id = id::k_int64;
869
873 std::int64_t value = {};
874
878 b_int64() = default;
879
883 explicit b_int64(std::int64_t value) : value{value} {}
884
888 /* explicit(false) */ operator std::int64_t() const {
889 return value;
890 }
891
895 friend bool operator==(b_int64 const& lhs, b_int64 const& rhs) {
896 return lhs.value == rhs.value;
897 }
898
902 friend bool operator!=(b_int64 const& lhs, b_int64 const& rhs) {
903 return !(lhs == rhs);
904 }
905};
906
916 static constexpr id type_id = id::k_decimal128;
917
922
926 b_decimal128() = default;
927
932
936 /* explicit(false) */ operator v1::decimal128() const {
937 return value;
938 }
939
943 friend bool operator==(b_decimal128 const& lhs, b_decimal128 const& rhs) {
944 return lhs.value == rhs.value;
945 }
946
950 friend bool operator!=(b_decimal128 const& lhs, b_decimal128 const& rhs) {
951 return !(lhs == rhs);
952 }
953};
954
960struct b_maxkey {
964 static constexpr id type_id = id::k_maxkey;
965
969 friend bool operator==(b_maxkey const&, b_maxkey const&) {
970 return true;
971 }
972
976 friend bool operator!=(b_maxkey const& lhs, b_maxkey const& rhs) {
977 return !(lhs == rhs);
978 }
979};
980
986struct b_minkey {
990 static constexpr id type_id = id::k_minkey;
991
995 friend bool operator==(b_minkey const&, b_minkey const&) {
996 return true;
997 }
998
1002 friend bool operator!=(b_minkey const& lhs, b_minkey const& rhs) {
1003 return !(lhs == rhs);
1004 }
1005};
1006
1007// BSONCXX_V1_TYPES_XMACRO: update above.
1008
1009#pragma push_macro("X")
1010#undef X
1011#define X(_name, _val) BSONCXX_PRIVATE_INLINE_CXX17 constexpr id b_##_name::type_id;
1013#pragma pop_macro("X")
1014
1023class view {
1024 private:
1025 id _id;
1026
1027#pragma push_macro("X")
1028#undef X
1029#define X(_name, _value) b_##_name _b_##_name;
1030
1031 union {
1033 };
1034#pragma pop_macro("X")
1035
1036 template <typename T>
1037 using is_view = detail::is_alike<T, view>;
1038
1039 template <typename T>
1040 struct is_equality_comparable_with
1041 : detail::conjunction<detail::negation<is_view<T>>, std::is_constructible<view, T>> {};
1042
1043 public:
1045 view() : _id{id::k_null}, _b_null{} {}
1046
1047#pragma push_macro("X")
1048#undef X
1049#define X(_name, _value) \
1050 /* explicit(false) */ view(b_##_name v) : _id{v.type_id}, _b_##_name{v} {}
1051
1059#pragma pop_macro("X")
1060
1064 id type_id() const {
1065 return _id;
1066 }
1067
1068#pragma push_macro("X")
1069#undef X
1070#define X(_name, _value) BSONCXX_ABI_EXPORT_CDECL(b_##_name) get_##_name() const;
1071
1082#pragma pop_macro("X")
1083
1097 friend bool operator==(view const& lhs, view const& rhs) {
1098 if (lhs.type_id() != rhs.type_id()) {
1099 return false;
1100 }
1101
1102#pragma push_macro("X")
1103#undef X
1104#define X(_name, _value) \
1105 case v1::types::id::k_##_name: \
1106 return lhs.get_##_name() == rhs.get_##_name();
1107
1108 switch (lhs.type_id()) {
1110
1111 default:
1112 return true;
1113 }
1114#pragma pop_macro("X")
1115 }
1116
1120 friend bool operator!=(view const& lhs, view const& rhs) {
1121 return !(lhs == rhs);
1122 }
1123
1128 friend bool operator==(view const& v, v1::element::view const& e) {
1129 return v == e.type_view();
1130 }
1131
1132 friend bool operator==(v1::element::view const& e, view const& v) {
1133 return v == e.type_view();
1134 }
1135
1137
1142 friend bool operator!=(view const& v, v1::element::view const& e) {
1143 return !(v == e);
1144 }
1145
1146 friend bool operator!=(v1::element::view const& e, view const& v) {
1147 return !(v == e);
1148 }
1149
1151
1160 template <typename T, detail::enable_if_t<is_equality_comparable_with<T>::value>* = nullptr>
1161 friend bool operator==(view const& v, T const& value) {
1162 return v == view{value};
1163 }
1164
1165 template <typename T, detail::enable_if_t<is_equality_comparable_with<T>::value>* = nullptr>
1166 friend bool operator==(T const& value, view const& v) {
1167 return v == view{value};
1168 }
1169
1171
1176 template <typename T, detail::enable_if_t<is_equality_comparable_with<T>::value>* = nullptr>
1177 friend bool operator!=(view const& v, T const& value) {
1178 return !(v == value);
1179 }
1180
1181 template <typename T, detail::enable_if_t<is_equality_comparable_with<T>::value>* = nullptr>
1182 friend bool operator!=(T const& value, view const& v) {
1183 return !(v == value);
1184 }
1185
1187
1193 enum class errc {
1196 };
1197
1203 static BSONCXX_ABI_EXPORT_CDECL(std::error_category const&) error_category();
1204
1210 friend std::error_code make_error_code(errc v) {
1211 return {static_cast<int>(v), error_category()};
1212 }
1213
1214 class internal;
1215};
1216
1217} // namespace types
1218} // namespace v1
1219} // namespace bsoncxx
1220
1221template <>
1222struct std::is_error_code_enum<bsoncxx::v1::types::view::errc> : true_type {};
1223
1225
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
For internal use only!
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.
For internal use only!
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.