MongoDB C++ Driver mongocxx-3.11.0
Loading...
Searching...
No Matches
types.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 <chrono>
18#include <cstring>
19#include <string>
20
21#include <bsoncxx/types-fwd.hpp>
22
26#include <bsoncxx/oid.hpp>
29
31
32BSONCXX_PUSH_WARNINGS();
33BSONCXX_DISABLE_WARNING(GNU("-Wfloat-equal"));
34
35namespace bsoncxx {
36namespace v_noabi {
37
43enum class type : std::uint8_t {
44 k_double = 0x01,
45 k_string = 0x02,
46 k_utf8 = 0x02,
47 k_document = 0x03,
48 k_array = 0x04,
49 k_binary = 0x05,
50 k_undefined = 0x06,
51 k_oid = 0x07,
52 k_bool = 0x08,
53 k_date = 0x09,
54 k_null = 0x0A,
55 k_regex = 0x0B,
56 k_dbpointer = 0x0C,
57 k_code = 0x0D,
58 k_symbol = 0x0E,
59 k_codewscope = 0x0F,
60 k_int32 = 0x10,
61 k_timestamp = 0x11,
62 k_int64 = 0x12,
63 k_decimal128 = 0x13,
64 k_maxkey = 0x7F,
65 k_minkey = 0xFF,
66};
67
73enum class binary_sub_type : std::uint8_t {
74 k_binary = 0x00,
75 k_function = 0x01,
76 k_binary_deprecated = 0x02,
77 k_uuid_deprecated = 0x03,
78 k_uuid = 0x04,
79 k_md5 = 0x05,
80 k_encrypted = 0x06,
81 k_column = 0x07,
82 k_sensitive = 0x08,
83 k_user = 0x80,
84};
85
95
105
106namespace types {
107
111struct b_double {
112 BSONCXX_ABI_EXPORT static constexpr auto type_id = type::k_double;
113
114 double value;
115
119 operator double() const {
120 return value;
121 }
122};
123
129inline bool operator==(const b_double& lhs, const b_double& rhs) {
130 return lhs.value == rhs.value;
131}
132
136struct b_string {
137 BSONCXX_ABI_EXPORT static constexpr auto type_id = type::k_string;
138
145 template <typename T, detail::requires_not_t<int, detail::is_alike<b_string, T>> = 0>
146 explicit b_string(T&& t) : value(std::forward<T>(t)) {}
147
148 stdx::string_view value;
149
153 operator stdx::string_view() const {
154 return value;
155 }
156};
157
163inline bool operator==(const b_string& lhs, const b_string& rhs) {
164 return lhs.value == rhs.value;
165}
166
173
178 BSONCXX_ABI_EXPORT static constexpr auto type_id = type::k_document;
179
180 document::view value;
181
185 operator document::view() const {
186 return value;
187 }
188
193 return value;
194 }
195};
196
202inline bool operator==(const b_document& lhs, const b_document& rhs) {
203 return lhs.value == rhs.value;
204}
205
209struct b_array {
210 BSONCXX_ABI_EXPORT static constexpr auto type_id = type::k_array;
211
212 array::view value;
213
217 operator array::view() const {
218 return value;
219 }
220};
221
227inline bool operator==(const b_array& lhs, const b_array& rhs) {
228 return lhs.value == rhs.value;
229}
230
234struct b_binary {
235 BSONCXX_ABI_EXPORT static constexpr auto type_id = type::k_binary;
236
237 binary_sub_type sub_type;
238 uint32_t size;
239 const uint8_t* bytes;
240};
241
247inline bool operator==(const b_binary& lhs, const b_binary& rhs) {
248 return lhs.sub_type == rhs.sub_type && lhs.size == rhs.size &&
249 (!lhs.size || (std::memcmp(lhs.bytes, rhs.bytes, lhs.size) == 0));
250}
251
258 BSONCXX_ABI_EXPORT static constexpr auto type_id = type::k_undefined;
259};
260
266inline bool operator==(const b_undefined&, const b_undefined&) {
267 return true;
268}
269
273struct b_oid {
274 BSONCXX_ABI_EXPORT static constexpr auto type_id = type::k_oid;
275
276 oid value;
277};
278
284inline bool operator==(const b_oid& lhs, const b_oid& rhs) {
285 return lhs.value == rhs.value;
286}
287
291struct b_bool {
292 BSONCXX_ABI_EXPORT static constexpr auto type_id = type::k_bool;
293
294 bool value;
295
299 operator bool() const {
300 return value;
301 }
302};
303
309inline bool operator==(const b_bool& lhs, const b_bool& rhs) {
310 return lhs.value == rhs.value;
311}
312
316struct b_date {
317 BSONCXX_ABI_EXPORT static constexpr auto type_id = type::k_date;
318
325 explicit b_date(std::chrono::milliseconds value) : value(value) {}
326
333 explicit b_date(const std::chrono::system_clock::time_point& tp)
334 : value(std::chrono::duration_cast<std::chrono::milliseconds>(tp.time_since_epoch())) {}
335
336 std::chrono::milliseconds value;
337
341 operator int64_t() const {
342 return value.count();
343 }
344
348 int64_t to_int64() const {
349 return value.count();
350 }
351
355 operator std::chrono::system_clock::time_point() const {
356 return std::chrono::system_clock::time_point(
357 std::chrono::duration_cast<std::chrono::system_clock::duration>(value));
358 }
359};
360
366inline bool operator==(const b_date& lhs, const b_date& rhs) {
367 return lhs.value == rhs.value;
368}
369
373struct b_null {
374 BSONCXX_ABI_EXPORT static constexpr auto type_id = type::k_null;
375};
376
382inline bool operator==(const b_null&, const b_null&) {
383 return true;
384}
385
389struct b_regex {
390 BSONCXX_ABI_EXPORT static constexpr auto type_id = type::k_regex;
391
401 template <typename T,
402 typename U = stdx::string_view,
403 detail::requires_not_t<int, detail::is_alike<b_regex, T>> = 0>
404 explicit b_regex(T&& regex, U&& options = U{})
405 : regex(std::forward<T>(regex)), options(std::forward<U>(options)) {}
406
407 stdx::string_view regex;
408 stdx::string_view options;
409};
410
416inline bool operator==(const b_regex& lhs, const b_regex& rhs) {
417 return lhs.regex == rhs.regex && lhs.options == rhs.options;
418}
419
426 BSONCXX_ABI_EXPORT static constexpr auto type_id = type::k_dbpointer;
427
428 stdx::string_view collection;
429 oid value;
430};
431
437inline bool operator==(const b_dbpointer& lhs, const b_dbpointer& rhs) {
438 return lhs.collection == rhs.collection && lhs.value == rhs.value;
439}
440
444struct b_code {
445 BSONCXX_ABI_EXPORT static constexpr auto type_id = type::k_code;
446
453 template <typename T, detail::requires_not_t<int, detail::is_alike<b_code, T>> = 0>
454 explicit b_code(T&& t) : code(std::forward<T>(t)) {}
455
457
461 operator stdx::string_view() const {
462 return code;
463 }
464};
465
471inline bool operator==(const b_code& lhs, const b_code& rhs) {
472 return lhs.code == rhs.code;
473}
474
480struct b_symbol {
481 BSONCXX_ABI_EXPORT static constexpr auto type_id = type::k_symbol;
482
489 template <typename T, detail::requires_not_t<int, detail::is_alike<b_symbol, T>> = 0>
490 explicit b_symbol(T&& t) : symbol(std::forward<T>(t)) {}
491
492 stdx::string_view symbol;
493
497 operator stdx::string_view() const {
498 return symbol;
499 }
500};
501
507inline bool operator==(const b_symbol& lhs, const b_symbol& rhs) {
508 return lhs.symbol == rhs.symbol;
509}
510
515 BSONCXX_ABI_EXPORT static constexpr auto type_id = type::k_codewscope;
516
526 template <typename T,
527 typename U,
528 detail::requires_not_t<int, detail::is_alike<b_codewscope, T>> = 0>
529 explicit b_codewscope(T&& code, U&& scope)
530 : code(std::forward<T>(code)), scope(std::forward<U>(scope)) {}
531
533 document::view scope;
534};
535
541inline bool operator==(const b_codewscope& lhs, const b_codewscope& rhs) {
542 return lhs.code == rhs.code && lhs.scope == rhs.scope;
543}
544
548struct b_int32 {
549 BSONCXX_ABI_EXPORT static constexpr auto type_id = type::k_int32;
550
551 int32_t value;
552
556 operator int32_t() const {
557 return value;
558 }
559};
560
566inline bool operator==(const b_int32& lhs, const b_int32& rhs) {
567 return lhs.value == rhs.value;
568}
569
574 BSONCXX_ABI_EXPORT static constexpr auto type_id = type::k_timestamp;
575
576 uint32_t increment;
577 uint32_t timestamp;
578};
579
585inline bool operator==(const b_timestamp& lhs, const b_timestamp& rhs) {
586 return lhs.increment == rhs.increment && lhs.timestamp == rhs.timestamp;
587}
588
592struct b_int64 {
593 BSONCXX_ABI_EXPORT static constexpr auto type_id = type::k_int64;
594
595 int64_t value;
596
600 operator int64_t() const {
601 return value;
602 }
603};
604
610inline bool operator==(const b_int64& lhs, const b_int64& rhs) {
611 return lhs.value == rhs.value;
612}
613
618 BSONCXX_ABI_EXPORT static constexpr auto type_id = type::k_decimal128;
619
620 decimal128 value;
621
628 template <typename T, detail::requires_not_t<int, detail::is_alike<b_decimal128, T>> = 0>
629 explicit b_decimal128(T&& t) : value(std::forward<T>(t)) {}
630};
631
637inline bool operator==(const b_decimal128& lhs, const b_decimal128& rhs) {
638 return lhs.value == rhs.value;
639}
640
644struct b_minkey {
645 BSONCXX_ABI_EXPORT static constexpr auto type_id = type::k_minkey;
646};
647
653inline bool operator==(const b_minkey&, const b_minkey&) {
654 return true;
655}
656
660struct b_maxkey {
661 BSONCXX_ABI_EXPORT static constexpr auto type_id = type::k_maxkey;
662};
663
669inline bool operator==(const b_maxkey&, const b_maxkey&) {
670 return true;
671}
672
678inline bool operator!=(const b_double& lhs, const b_double& rhs) {
679 return !(lhs == rhs);
680}
681
687inline bool operator!=(const b_string& lhs, const b_string& rhs) {
688 return !(lhs == rhs);
689}
690
696inline bool operator!=(const b_document& lhs, const b_document& rhs) {
697 return !(lhs == rhs);
698}
699
705inline bool operator!=(const b_array& lhs, const b_array& rhs) {
706 return !(lhs == rhs);
707}
708
714inline bool operator!=(const b_binary& lhs, const b_binary& rhs) {
715 return !(lhs == rhs);
716}
717
723inline bool operator!=(const b_undefined& lhs, const b_undefined& rhs) {
724 return !(lhs == rhs);
725}
726
732inline bool operator!=(const b_oid& lhs, const b_oid& rhs) {
733 return !(lhs == rhs);
734}
735
741inline bool operator!=(const b_bool& lhs, const b_bool& rhs) {
742 return !(lhs == rhs);
743}
744
750inline bool operator!=(const b_date& lhs, const b_date& rhs) {
751 return !(lhs == rhs);
752}
753
759inline bool operator!=(const b_null& lhs, const b_null& rhs) {
760 return !(lhs == rhs);
761}
762
768inline bool operator!=(const b_regex& lhs, const b_regex& rhs) {
769 return !(lhs == rhs);
770}
771
777inline bool operator!=(const b_dbpointer& lhs, const b_dbpointer& rhs) {
778 return !(lhs == rhs);
779}
780
786inline bool operator!=(const b_code& lhs, const b_code& rhs) {
787 return !(lhs == rhs);
788}
789
795inline bool operator!=(const b_symbol& lhs, const b_symbol& rhs) {
796 return !(lhs == rhs);
797}
798
804inline bool operator!=(const b_codewscope& lhs, const b_codewscope& rhs) {
805 return !(lhs == rhs);
806}
807
813inline bool operator!=(const b_int32& lhs, const b_int32& rhs) {
814 return !(lhs == rhs);
815}
816
822inline bool operator!=(const b_timestamp& lhs, const b_timestamp& rhs) {
823 return !(lhs == rhs);
824}
825
831inline bool operator!=(const b_int64& lhs, const b_int64& rhs) {
832 return !(lhs == rhs);
833}
834
840inline bool operator!=(const b_decimal128& lhs, const b_decimal128& rhs) {
841 return !(lhs == rhs);
842}
843
849inline bool operator!=(const b_minkey& lhs, const b_minkey& rhs) {
850 return !(lhs == rhs);
851}
852
858inline bool operator!=(const b_maxkey& lhs, const b_maxkey& rhs) {
859 return !(lhs == rhs);
860}
861
862} // namespace types
863} // namespace v_noabi
864} // namespace bsoncxx
865
866BSONCXX_POP_WARNINGS();
867
868namespace bsoncxx {
869
870using ::bsoncxx::v_noabi::to_string;
871
872} // namespace bsoncxx
873
874namespace bsoncxx {
875namespace types {
876
877using ::bsoncxx::v_noabi::types::b_utf8; // Deprecated.
878
879using ::bsoncxx::v_noabi::types::operator==;
880using ::bsoncxx::v_noabi::types::operator!=;
881
882} // namespace types
883} // namespace bsoncxx
884
886
891
892#if defined(BSONCXX_PRIVATE_DOXYGEN_PREPROCESSOR)
893
894namespace bsoncxx {
895
897std::string to_string(v_noabi::type rhs);
898
901
902namespace types {
903
906struct b_utf8 {};
907
910
913
916
919
922
925
928
931
934
937
940
943
946
949
952
955
958
961
964
967
970
973
976
979
982
985
988
991
994
997
1000
1003
1006
1009
1012
1015
1018
1021
1024
1027
1030
1033
1034} // namespace types
1035
1036} // namespace bsoncxx
1037
1038#endif // defined(BSONCXX_PRIVATE_DOXYGEN_PREPROCESSOR)
Provides bsoncxx::v_noabi::array::view.
The bsoncxx macro guard postlude header.
The bsoncxx macro guard prelude header.
A read-only, non-owning view of a BSON document.
Definition view.hpp:36
Represents an IEEE 754-2008 BSON Decimal128 value in a platform-independent way.
Definition decimal128.hpp:32
A read-only, non-owning view of a BSON document.
Definition view.hpp:35
Represents a MongoDB ObjectId. As this BSON type is used within the MongoDB server as a primary key f...
Definition oid.hpp:41
A polyfill for std::string_view.
Definition string_view.hpp:503
Provides bsoncxx::v_noabi::decimal128.
Provides bsoncxx::v_noabi::document::view.
#define BSONCXX_DEPRECATED
Declares the associated entity as deprecated.
Definition fwd.hpp:261
#define BSONCXX_ABI_EXPORT
Exports the associated entity as part of the ABI.
Definition fwd.hpp:201
#define BSONCXX_ABI_EXPORT_CDECL(...)
Equivalent to BSONCXX_ABI_EXPORT with BSONCXX_ABI_CDECL.
Definition fwd.hpp:225
bool operator!=(const v_noabi::types::b_double &lhs, const v_noabi::types::b_double &rhs)
bsoncxx::v_noabi::types::operator!=(const v_noabi::types::b_double& lhs, const v_noabi::types::b_doub...
bool operator==(const v_noabi::types::b_double &lhs, const v_noabi::types::b_double &rhs)
bsoncxx::v_noabi::types::operator==(const v_noabi::types::b_double& lhs, const v_noabi::types::b_doub...
BSONCXX_DEPRECATED typedef b_string b_utf8
Equivalent to b_string.
Definition types.hpp:172
BSONCXX_DEPRECATED typedef types::bson_value::view value
Equivalent to bsoncxx::v_noabi::types::bson_value::view.
Definition value.hpp:30
binary_sub_type
An enumeration of each BSON binary sub type.
Definition types.hpp:73
@ k_column
Compressed BSON column.
@ k_encrypted
Encrypted BSON value.
std::string to_string(type rhs)
Returns a stringification of the given type.
type
An enumeration of each BSON type.
Definition types.hpp:43
@ k_decimal128
128-bit decimal floating point.
@ k_double
64-bit binary floating point.
@ k_int64
64-bit integer.
@ k_codewscope
JavaScript code with scope.
@ k_utf8
Equivalent to k_string.
@ k_regex
Regular expression.
@ k_string
UTF-8 string.
@ k_date
UTC datetime.
@ k_int32
32-bit integer.
@ k_undefined
Undefined value.
@ k_code
JavaScript code.
@ k_document
Embedded document.
@ k_binary
Binary data.
The top-level namespace within which all bsoncxx library entities are declared.
std::string to_string(v_noabi::type rhs)
bsoncxx::v_noabi::to_string(v_noabi::type rhs)
The top-level namespace reserved for the C++ standard library.
Provides bsoncxx::v_noabi::oid.
Provides std::string_view-related polyfills for library API usage.
bsoncxx::v_noabi::types::b_utf8
Definition types.hpp:906
A BSON array value.
Definition types.hpp:209
bool operator==(const b_array &lhs, const b_array &rhs)
free function comparator for b_array
Definition types.hpp:227
bool operator!=(const b_array &lhs, const b_array &rhs)
free function comparator for b_array
Definition types.hpp:705
A BSON binary data value.
Definition types.hpp:234
bool operator==(const b_binary &lhs, const b_binary &rhs)
free function comparator for b_binary
Definition types.hpp:247
bool operator!=(const b_binary &lhs, const b_binary &rhs)
free function comparator for b_binary
Definition types.hpp:714
A BSON boolean value.
Definition types.hpp:291
bool operator!=(const b_bool &lhs, const b_bool &rhs)
free function comparator for b_bool
Definition types.hpp:741
bool operator==(const b_bool &lhs, const b_bool &rhs)
free function comparator for b_bool
Definition types.hpp:309
A BSON JavaScript code value.
Definition types.hpp:444
bool operator==(const b_code &lhs, const b_code &rhs)
free function comparator for b_code
Definition types.hpp:471
bool operator!=(const b_code &lhs, const b_code &rhs)
free function comparator for b_code
Definition types.hpp:786
b_code(T &&t)
Constructor for b_code.
Definition types.hpp:454
A BSON JavaScript code with scope value.
Definition types.hpp:514
bool operator!=(const b_codewscope &lhs, const b_codewscope &rhs)
free function comparator for b_codewscope
Definition types.hpp:804
bool operator==(const b_codewscope &lhs, const b_codewscope &rhs)
free function comparator for b_codewscope
Definition types.hpp:541
b_codewscope(T &&code, U &&scope)
Constructor for b_codewscope.
Definition types.hpp:529
A BSON date value.
Definition types.hpp:316
bool operator==(const b_date &lhs, const b_date &rhs)
free function comparator for b_date
Definition types.hpp:366
b_date(const std::chrono::system_clock::time_point &tp)
Constructor for b_date.
Definition types.hpp:333
int64_t to_int64() const
Manually convert this b_date to an int64_t.
Definition types.hpp:348
bool operator!=(const b_date &lhs, const b_date &rhs)
free function comparator for b_date
Definition types.hpp:750
b_date(std::chrono::milliseconds value)
Constructor for b_date.
Definition types.hpp:325
A BSON DBPointer (aka DBRef) value.
Definition types.hpp:425
bool operator==(const b_dbpointer &lhs, const b_dbpointer &rhs)
free function comparator for b_dbpointer
Definition types.hpp:437
bool operator!=(const b_dbpointer &lhs, const b_dbpointer &rhs)
free function comparator for b_dbpointer
Definition types.hpp:777
A BSON Decimal128 value.
Definition types.hpp:617
bool operator!=(const b_decimal128 &lhs, const b_decimal128 &rhs)
free function comparator for b_decimal128
Definition types.hpp:840
bool operator==(const b_decimal128 &lhs, const b_decimal128 &rhs)
free function comparator for b_decimal128
Definition types.hpp:637
b_decimal128(T &&t)
Constructor for b_decimal128.
Definition types.hpp:629
A BSON document value.
Definition types.hpp:177
bool operator!=(const b_document &lhs, const b_document &rhs)
free function comparator for b_document
Definition types.hpp:696
document::view view()
Returns an unwrapped document::view.
Definition types.hpp:192
bool operator==(const b_document &lhs, const b_document &rhs)
free function comparator for b_document
Definition types.hpp:202
A BSON double value.
Definition types.hpp:111
bool operator==(const b_double &lhs, const b_double &rhs)
free function comparator for b_double
Definition types.hpp:129
bool operator!=(const b_double &lhs, const b_double &rhs)
free function comparator for b_double
Definition types.hpp:678
A BSON signed 32-bit integer value.
Definition types.hpp:548
bool operator==(const b_int32 &lhs, const b_int32 &rhs)
free function comparator for b_int32
Definition types.hpp:566
bool operator!=(const b_int32 &lhs, const b_int32 &rhs)
free function comparator for b_int32
Definition types.hpp:813
A BSON 64-bit signed integer value.
Definition types.hpp:592
bool operator==(const b_int64 &lhs, const b_int64 &rhs)
free function comparator for b_int64
Definition types.hpp:610
bool operator!=(const b_int64 &lhs, const b_int64 &rhs)
free function comparator for b_int64
Definition types.hpp:831
A BSON max-key value.
Definition types.hpp:660
bool operator!=(const b_maxkey &lhs, const b_maxkey &rhs)
free function comparator for b_maxkey
Definition types.hpp:858
bool operator==(const b_maxkey &, const b_maxkey &)
free function comparator for b_maxkey
Definition types.hpp:669
A BSON min-key value.
Definition types.hpp:644
bool operator!=(const b_minkey &lhs, const b_minkey &rhs)
free function comparator for b_minkey
Definition types.hpp:849
bool operator==(const b_minkey &, const b_minkey &)
free function comparator for b_minkey
Definition types.hpp:653
A BSON null value.
Definition types.hpp:373
bool operator!=(const b_null &lhs, const b_null &rhs)
free function comparator for b_null
Definition types.hpp:759
bool operator==(const b_null &, const b_null &)
free function comparator for b_null
Definition types.hpp:382
A BSON ObjectId value.
Definition types.hpp:273
bool operator==(const b_oid &lhs, const b_oid &rhs)
free function comparator for b_oid
Definition types.hpp:284
bool operator!=(const b_oid &lhs, const b_oid &rhs)
free function comparator for b_oid
Definition types.hpp:732
A BSON regex value.
Definition types.hpp:389
bool operator!=(const b_regex &lhs, const b_regex &rhs)
free function comparator for b_regex
Definition types.hpp:768
bool operator==(const b_regex &lhs, const b_regex &rhs)
free function comparator for b_regex
Definition types.hpp:416
b_regex(T &&regex, U &&options=U{})
Constructor for b_regex.
Definition types.hpp:404
A BSON UTF-8 encoded string value.
Definition types.hpp:136
b_string(T &&t)
Constructor for b_string.
Definition types.hpp:146
bool operator!=(const b_string &lhs, const b_string &rhs)
free function comparator for b_string
Definition types.hpp:687
bool operator==(const b_string &lhs, const b_string &rhs)
free function comparator for b_string
Definition types.hpp:163
A BSON Symbol value.
Definition types.hpp:480
b_symbol(T &&t)
Constructor for b_symbol.
Definition types.hpp:490
bool operator==(const b_symbol &lhs, const b_symbol &rhs)
free function comparator for b_symbol
Definition types.hpp:507
bool operator!=(const b_symbol &lhs, const b_symbol &rhs)
free function comparator for b_symbol
Definition types.hpp:795
A BSON replication timestamp value.
Definition types.hpp:573
bool operator!=(const b_timestamp &lhs, const b_timestamp &rhs)
free function comparator for b_timestamp
Definition types.hpp:822
bool operator==(const b_timestamp &lhs, const b_timestamp &rhs)
free function comparator for b_timestamp
Definition types.hpp:585
A BSON undefined value.
Definition types.hpp:257
bool operator!=(const b_undefined &lhs, const b_undefined &rhs)
free function comparator for b_undefined
Definition types.hpp:723
bool operator==(const b_undefined &, const b_undefined &)
free function comparator for b_undefined
Definition types.hpp:266
Provides <type_traits>-related polyfills for internal use.
Declares entities used to represent BSON types.