MongoDB C++ Driver
mongocxx-3.7.0
|
16 #if defined(__clang__)
17 #pragma clang diagnostic push
18 #pragma clang diagnostic ignored "-Wfloat-equal"
19 #elif defined(__GNUC__)
20 #pragma GCC diagnostic push
21 #pragma GCC diagnostic ignored "-Wfloat-equal"
27 #include <bsoncxx/array/view.hpp>
28 #include <bsoncxx/decimal128.hpp>
29 #include <bsoncxx/document/view.hpp>
30 #include <bsoncxx/oid.hpp>
31 #include <bsoncxx/stdx/string_view.hpp>
33 #include <bsoncxx/config/prelude.hpp>
36 BSONCXX_INLINE_NAMESPACE_BEGIN
46 enum class type : std::uint8_t {
47 #define BSONCXX_ENUM(name, val) k_##name = val,
48 #include <bsoncxx/enums/type.hpp>
67 #define BSONCXX_ENUM(name, val) k_##name = val,
68 #include <bsoncxx/enums/binary_sub_type.hpp>
98 static constexpr
auto type_id = type::k_double;
105 BSONCXX_INLINE
operator double()
const {
116 return lhs.value == rhs.value;
123 static constexpr
auto type_id = type::k_string;
131 template <
typename T,
132 typename std::enable_if<!std::is_same<b_string, typename std::decay<T>::type>::value,
134 BSONCXX_INLINE
explicit b_string(T&& t) : value(std::forward<T>(t)) {}
136 stdx::string_view value;
141 BSONCXX_INLINE
operator stdx::string_view()
const {
152 return lhs.value == rhs.value;
160 BSONCXX_DEPRECATED
typedef b_string b_utf8;
166 static constexpr
auto type_id = type::k_document;
191 return lhs.value == rhs.value;
198 static constexpr
auto type_id = type::k_array;
216 return lhs.value == rhs.value;
223 static constexpr
auto type_id = type::k_binary;
227 const uint8_t* bytes;
236 return lhs.sub_type == rhs.sub_type && lhs.size == rhs.size &&
237 (!lhs.size || (std::memcmp(lhs.bytes, rhs.bytes, lhs.size) == 0));
247 static constexpr
auto type_id = type::k_undefined;
263 static constexpr
auto type_id = type::k_oid;
274 return lhs.value == rhs.value;
281 static constexpr
auto type_id = type::k_bool;
288 BSONCXX_INLINE
operator bool()
const {
299 return lhs.value == rhs.value;
306 static constexpr
auto type_id = type::k_date;
315 explicit b_date(std::chrono::milliseconds value) : value(value) {}
324 explicit b_date(
const std::chrono::system_clock::time_point& tp)
325 : value(std::chrono::duration_cast<std::chrono::milliseconds>(tp.time_since_epoch())) {}
327 std::chrono::milliseconds value;
332 BSONCXX_INLINE
operator int64_t()
const {
333 return value.count();
340 return value.count();
346 BSONCXX_INLINE
operator std::chrono::system_clock::time_point()
const {
347 return std::chrono::system_clock::time_point(
348 std::chrono::duration_cast<std::chrono::system_clock::duration>(value));
358 return lhs.value == rhs.value;
365 static constexpr
auto type_id = type::k_null;
381 static constexpr
auto type_id = type::k_regex;
392 template <
typename T,
393 typename U = stdx::string_view,
394 typename std::enable_if<!std::is_same<b_regex, typename std::decay<T>::type>::value,
396 BSONCXX_INLINE
explicit b_regex(T&& regex, U&& options = U{})
397 : regex(std::forward<T>(regex)), options(std::forward<U>(options)) {}
399 stdx::string_view regex;
400 stdx::string_view options;
409 return lhs.regex == rhs.regex && lhs.options == rhs.options;
419 static constexpr
auto type_id = type::k_dbpointer;
421 stdx::string_view collection;
431 return lhs.collection == rhs.collection && lhs.value == rhs.value;
438 static constexpr
auto type_id = type::k_code;
446 template <
typename T,
447 typename std::enable_if<!std::is_same<b_code, typename std::decay<T>::type>::value,
449 BSONCXX_INLINE
explicit b_code(T&& t) : code(std::forward<T>(t)) {}
451 stdx::string_view code;
456 BSONCXX_INLINE
operator stdx::string_view()
const {
467 return lhs.code == rhs.code;
477 static constexpr
auto type_id = type::k_symbol;
485 template <
typename T,
486 typename std::enable_if<!std::is_same<b_symbol, typename std::decay<T>::type>::value,
488 BSONCXX_INLINE
explicit b_symbol(T&& t) : symbol(std::forward<T>(t)) {}
490 stdx::string_view symbol;
495 BSONCXX_INLINE
operator stdx::string_view()
const {
506 return lhs.symbol == rhs.symbol;
513 static constexpr
auto type_id = type::k_codewscope;
527 typename std::enable_if<!std::is_same<b_codewscope, typename std::decay<T>::type>::value,
530 : code(std::forward<T>(code)), scope(std::forward<U>(scope)) {}
532 stdx::string_view code;
542 return lhs.code == rhs.code && lhs.scope == rhs.scope;
549 static constexpr
auto type_id = type::k_int32;
556 BSONCXX_INLINE
operator int32_t()
const {
567 return lhs.value == rhs.value;
578 static constexpr
auto type_id = type::k_timestamp;
590 return lhs.increment == rhs.increment && lhs.timestamp == rhs.timestamp;
597 static constexpr
auto type_id = type::k_int64;
604 BSONCXX_INLINE
operator int64_t()
const {
615 return lhs.value == rhs.value;
622 static constexpr
auto type_id = type::k_decimal128;
634 typename std::enable_if<!std::is_same<b_decimal128, typename std::decay<T>::type>::value,
636 BSONCXX_INLINE
explicit b_decimal128(T&& t) : value(std::forward<T>(t)) {}
645 return lhs.value == rhs.value;
652 static constexpr
auto type_id = type::k_minkey;
668 static constexpr
auto type_id = type::k_maxkey;
680 #define BSONCXX_ENUM(name, val) \
681 BSONCXX_INLINE bool operator!=(const b_##name& lhs, const b_##name& rhs) { \
682 return !(lhs == rhs); \
684 #include <bsoncxx/enums/type.hpp>
688 BSONCXX_INLINE_NAMESPACE_END
691 #include <bsoncxx/config/postlude.hpp>
693 #if defined(__clang__)
694 #pragma clang diagnostic pop
695 #elif defined(__GNUC__)
696 #pragma GCC diagnostic pop
bool operator==(const b_decimal128 &lhs, const b_decimal128 &rhs)
free function comparator for b_decimal128
Definition: types.hpp:644
A BSON array value.
Definition: types.hpp:197
A BSON ObjectId value.
Definition: types.hpp:262
bool operator==(const b_document &lhs, const b_document &rhs)
free function comparator for b_document
Definition: types.hpp:190
bool operator==(const b_symbol &lhs, const b_symbol &rhs)
free function comparator for b_symbol
Definition: types.hpp:505
document::view view()
Returns an unwrapped document::view.
Definition: types.hpp:180
bool operator==(const b_undefined &, const b_undefined &)
free function comparator for b_undefined
Definition: types.hpp:255
bool operator==(const b_oid &lhs, const b_oid &rhs)
free function comparator for b_oid
Definition: types.hpp:273
bool operator==(const b_regex &lhs, const b_regex &rhs)
free function comparator for b_regex
Definition: types.hpp:408
Top level namespace for MongoDB C++ BSON functionality.
Definition: element.hpp:24
A BSON document value.
Definition: types.hpp:165
A BSON null value.
Definition: types.hpp:364
bool operator==(const b_maxkey &, const b_maxkey &)
free function comparator for b_maxkey
Definition: types.hpp:676
A BSON JavaScript code with scope value.
Definition: types.hpp:512
A BSON UTF-8 encoded string value.
Definition: types.hpp:122
A BSON 64-bit signed integer value.
Definition: types.hpp:596
binary_sub_type
An enumeration of each BSON binary sub type.
Definition: types.hpp:66
A BSON binary data value.
Definition: types.hpp:222
bool operator==(const b_dbpointer &lhs, const b_dbpointer &rhs)
free function comparator for b_dbpointer
Definition: types.hpp:430
b_symbol(T &&t)
Constructor for b_symbol.
Definition: types.hpp:488
A read-only, non-owning view of a BSON document.
Definition: view.hpp:40
int64_t to_int64() const
Manually convert this b_date to an int64_t.
Definition: types.hpp:339
b_codewscope(T &&code, U &&scope)
Constructor for b_codewscope.
Definition: types.hpp:529
bool operator==(const b_string &lhs, const b_string &rhs)
free function comparator for b_string
Definition: types.hpp:151
bool operator==(const b_null &, const b_null &)
free function comparator for b_null
Definition: types.hpp:373
A BSON Symbol value.
Definition: types.hpp:476
A BSON DBPointer value.
Definition: types.hpp:418
Represents a MongoDB ObjectId.
Definition: oid.hpp:38
b_string(T &&t)
Constructor for b_string.
Definition: types.hpp:134
b_date(const std::chrono::system_clock::time_point &tp)
Constructor for b_date.
Definition: types.hpp:324
bool operator==(const b_int32 &lhs, const b_int32 &rhs)
free function comparator for b_int32
Definition: types.hpp:566
A BSON regex value.
Definition: types.hpp:380
A BSON max-key value.
Definition: types.hpp:667
bool operator==(const b_array &lhs, const b_array &rhs)
free function comparator for b_array
Definition: types.hpp:215
b_code(T &&t)
Constructor for b_code.
Definition: types.hpp:449
Represents an IEEE 754-2008 BSON Decimal128 value in a platform-independent way.
Definition: decimal128.hpp:30
bool operator==(const b_codewscope &lhs, const b_codewscope &rhs)
free function comparator for b_codewscope
Definition: types.hpp:541
bool operator==(const b_date &lhs, const b_date &rhs)
free function comparator for b_date
Definition: types.hpp:357
A BSON replication timestamp value.
Definition: types.hpp:577
bool operator==(const b_code &lhs, const b_code &rhs)
free function comparator for b_code
Definition: types.hpp:466
A BSON date value.
Definition: types.hpp:305
A BSON signed 32-bit integer value.
Definition: types.hpp:548
A BSON min-key value.
Definition: types.hpp:651
bool operator==(const b_timestamp &lhs, const b_timestamp &rhs)
free function comparator for b_timestamp
Definition: types.hpp:589
bool operator==(const b_double &lhs, const b_double &rhs)
free function comparator for b_double
Definition: types.hpp:115
std::string to_string(type rhs)
Returns a stringification of the given type.
bool operator==(const b_bool &lhs, const b_bool &rhs)
free function comparator for b_bool
Definition: types.hpp:298
bool operator==(const b_binary &lhs, const b_binary &rhs)
free function comparator for b_binary
Definition: types.hpp:235
bool operator==(const b_minkey &, const b_minkey &)
free function comparator for b_minkey
Definition: types.hpp:660
bool operator==(const b_int64 &lhs, const b_int64 &rhs)
free function comparator for b_int64
Definition: types.hpp:614
A BSON JavaScript code value.
Definition: types.hpp:437
b_decimal128(T &&t)
Constructor for b_decimal128.
Definition: types.hpp:636
A BSON Decimal128 value.
Definition: types.hpp:621
type
An enumeration of each BSON type.
Definition: types.hpp:46
A BSON undefined value.
Definition: types.hpp:246
b_date(std::chrono::milliseconds value)
Constructor for b_date.
Definition: types.hpp:315
b_regex(T &®ex, U &&options=U{})
Constructor for b_regex.
Definition: types.hpp:396
A BSON boolean value.
Definition: types.hpp:280
A BSON double value.
Definition: types.hpp:97
A read-only, non-owning view of a BSON document.
Definition: view.hpp:33