Loading...
Searching...
No Matches
view.hpp
Go to the documentation of this file.
// Copyright 2009-present MongoDB, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#pragma once
#include <bsoncxx/v1/types/view-fwd.hpp> // IWYU pragma: export
//
#include <bsoncxx/v1/detail/prelude.hpp>
#include <bsoncxx/v1/array/view.hpp> // IWYU pragma: export
#include <bsoncxx/v1/config/export.hpp>
#include <bsoncxx/v1/decimal128.hpp> // IWYU pragma: export
#include <bsoncxx/v1/detail/macros.hpp>
#include <bsoncxx/v1/detail/type_traits.hpp>
#include <bsoncxx/v1/document/view.hpp> // IWYU pragma: export
#include <bsoncxx/v1/oid.hpp> // IWYU pragma: export
#include <bsoncxx/v1/stdx/string_view.hpp>
#include <bsoncxx/v1/types/id.hpp> // IWYU pragma: export
#include <chrono>
#include <cstdint>
#include <cstring>
#include <system_error>
#include <type_traits>
namespace bsoncxx {
namespace v1 {
namespace types {
// BSONCXX_V1_TYPES_XMACRO: update below.
struct b_double {
static constexpr id type_id = id::k_double;
double value = {};
b_double() = default;
explicit b_double(double value) : value{value} {}
/* explicit(false) */ operator double() const {
return value;
}
friend bool operator==(b_double const& lhs, b_double const& rhs) {
BSONCXX_PRIVATE_WARNINGS_PUSH();
BSONCXX_PRIVATE_WARNINGS_DISABLE(GNU("-Wfloat-equal"));
return lhs.value == rhs.value;
BSONCXX_PRIVATE_WARNINGS_POP();
}
friend bool operator!=(b_double const& lhs, b_double const& rhs) {
return !(lhs == rhs);
}
};
struct b_string {
static constexpr id type_id = id::k_string;
v1::stdx::string_view value;
b_string() = default;
explicit b_string(v1::stdx::string_view value) : value{value} {}
/* explicit(false) */ operator v1::stdx::string_view() const {
return value;
}
friend bool operator==(b_string const& lhs, b_string const& rhs) {
return lhs.value == rhs.value;
}
friend bool operator!=(b_string const& lhs, b_string const& rhs) {
return !(lhs == rhs);
}
};
struct b_document {
static constexpr id type_id = id::k_document;
v1::document::view value;
b_document() = default;
explicit b_document(v1::document::view value) : value{value} {}
/* explicit(false) */ operator v1::document::view() const {
return value;
}
v1::document::view view() {
return value;
}
friend bool operator==(b_document const& lhs, b_document const& rhs) {
return lhs.value == rhs.value;
}
friend bool operator!=(b_document const& lhs, b_document const& rhs) {
return !(lhs == rhs);
}
};
struct b_array {
static constexpr id type_id = id::k_array;
v1::array::view value;
b_array() = default;
explicit b_array(v1::array::view value) : value{value} {}
/* explicit(false) */ operator v1::array::view() const {
return value;
}
friend bool operator==(b_array const& lhs, b_array const& rhs) {
return lhs.value == rhs.value;
}
friend bool operator!=(b_array const& lhs, b_array const& rhs) {
return !(lhs == rhs);
}
};
struct b_binary {
static constexpr id type_id = id::k_binary;
binary_subtype subtype = {};
std::uint32_t size = {};
std::uint8_t const* bytes = {};
b_binary() = default;
b_binary(binary_subtype subtype, std::uint32_t size, std::uint8_t const* bytes)
: subtype{subtype}, size{size}, bytes{bytes} {}
friend bool operator==(b_binary const& lhs, b_binary const& rhs) {
if (lhs.size != rhs.size) {
return false;
}
if (!lhs.bytes != !rhs.bytes) {
return false;
}
if (!lhs.bytes || lhs.size == 0u) {
return true; // Empty.
}
return lhs.subtype == rhs.subtype && (std::memcmp(lhs.bytes, rhs.bytes, lhs.size) == 0);
}
friend bool operator!=(b_binary const& lhs, b_binary const& rhs) {
return !(lhs == rhs);
}
};
struct b_undefined {
static constexpr id type_id = id::k_undefined;
friend bool operator==(b_undefined const&, b_undefined const&) {
return true;
}
friend bool operator!=(b_undefined const& lhs, b_undefined const& rhs) {
return !(lhs == rhs);
}
};
struct b_oid {
static constexpr id type_id = id::k_oid;
v1::oid value;
b_oid() = default;
explicit b_oid(v1::oid const& value) : value{value} {}
/* explicit(false) */ operator v1::oid() const {
return value;
}
friend bool operator==(b_oid const& lhs, b_oid const& rhs) {
return lhs.value == rhs.value;
}
friend bool operator!=(b_oid const& lhs, b_oid const& rhs) {
return !(lhs == rhs);
}
};
struct b_bool {
static constexpr id type_id = id::k_bool;
bool value = false;
b_bool() = default;
explicit b_bool(bool value) : value{value} {}
/* explicit(false) */ operator bool() const {
return value;
}
friend bool operator==(b_bool const& lhs, b_bool const& rhs) {
return lhs.value == rhs.value;
}
friend bool operator!=(b_bool const& lhs, b_bool const& rhs) {
return !(lhs == rhs);
}
};
struct b_date {
static constexpr id type_id = id::k_date;
std::chrono::milliseconds value = {};
b_date() = default;
explicit b_date(std::chrono::milliseconds value) : value{value} {}
explicit b_date(std::chrono::system_clock::time_point tp)
: value{std::chrono::duration_cast<std::chrono::milliseconds>(tp.time_since_epoch())} {}
/* explicit(false) */ operator std::chrono::milliseconds() const {
return value;
}
explicit operator std::chrono::system_clock::time_point() const {
return std::chrono::system_clock::time_point(
std::chrono::duration_cast<std::chrono::system_clock::duration>(value));
}
friend bool operator==(b_date const& lhs, b_date const& rhs) {
return lhs.value == rhs.value;
}
friend bool operator!=(b_date const& lhs, b_date const& rhs) {
return !(lhs == rhs);
}
};
struct b_null {
static constexpr id type_id = id::k_null;
friend bool operator==(b_null const& /* lhs */, b_null const& /* rhs */) {
return true;
}
friend bool operator!=(b_null const& lhs, b_null const& rhs) {
return !(lhs == rhs);
}
};
struct b_regex {
static constexpr id type_id = id::k_regex;
v1::stdx::string_view regex;
v1::stdx::string_view options;
b_regex() = default;
explicit b_regex(v1::stdx::string_view regex) : regex{regex}, options{} {}
b_regex(v1::stdx::string_view regex, v1::stdx::string_view options) : regex{regex}, options{options} {}
friend bool operator==(b_regex const& lhs, b_regex const& rhs) {
return lhs.regex == rhs.regex && lhs.options == rhs.options;
}
friend bool operator!=(b_regex const& lhs, b_regex const& rhs) {
return !(lhs == rhs);
}
};
struct b_dbpointer {
static constexpr id type_id = id::k_dbpointer;
v1::stdx::string_view collection;
v1::oid value;
b_dbpointer() = default;
b_dbpointer(v1::stdx::string_view collection, v1::oid value) : collection{collection}, value{value} {}
friend bool operator==(b_dbpointer const& lhs, b_dbpointer const& rhs) {
return lhs.collection == rhs.collection && lhs.value == rhs.value;
}
friend bool operator!=(b_dbpointer const& lhs, b_dbpointer const& rhs) {
return !(lhs == rhs);
}
};
struct b_code {
static constexpr id type_id = id::k_code;
v1::stdx::string_view code;
b_code() = default;
explicit b_code(v1::stdx::string_view code) : code{code} {}
/* explicit(false) */ operator v1::stdx::string_view() const {
return code;
}
friend bool operator==(b_code const& lhs, b_code const& rhs) {
return lhs.code == rhs.code;
}
friend bool operator!=(b_code const& lhs, b_code const& rhs) {
return !(lhs == rhs);
}
};
struct b_symbol {
static constexpr id type_id = id::k_symbol;
v1::stdx::string_view symbol;
b_symbol() = default;
explicit b_symbol(v1::stdx::string_view symbol) : symbol{symbol} {}
/* explicit(false) */ operator v1::stdx::string_view() const {
return symbol;
}
friend bool operator==(b_symbol const& lhs, b_symbol const& rhs) {
return lhs.symbol == rhs.symbol;
}
friend bool operator!=(b_symbol const& lhs, b_symbol const& rhs) {
return !(lhs == rhs);
}
};
struct b_codewscope {
static constexpr id type_id = id::k_codewscope;
v1::stdx::string_view code;
v1::document::view scope;
b_codewscope() = default;
b_codewscope(v1::stdx::string_view code, v1::document::view scope) : code{code}, scope{scope} {}
friend bool operator==(b_codewscope const& lhs, b_codewscope const& rhs) {
return lhs.code == rhs.code && lhs.scope == rhs.scope;
}
friend bool operator!=(b_codewscope const& lhs, b_codewscope const& rhs) {
return !(lhs == rhs);
}
};
struct b_int32 {
static constexpr id type_id = id::k_int32;
std::int32_t value = {};
b_int32() = default;
explicit b_int32(std::int32_t value) : value{value} {}
/* explicit(false) */ operator std::int32_t() const {
return value;
}
friend bool operator==(b_int32 const& lhs, b_int32 const& rhs) {
return lhs.value == rhs.value;
}
friend bool operator!=(b_int32 const& lhs, b_int32 const& rhs) {
return !(lhs == rhs);
}
};
struct b_timestamp {
static constexpr id type_id = id::k_timestamp;
std::uint32_t increment = {};
std::uint32_t timestamp = {};
b_timestamp() = default;
b_timestamp(std::uint32_t increment, std::uint32_t timestamp) : increment{increment}, timestamp{timestamp} {}
friend bool operator==(b_timestamp const& lhs, b_timestamp const& rhs) {
return lhs.timestamp == rhs.timestamp;
}
friend bool operator!=(b_timestamp const& lhs, b_timestamp const& rhs) {
return !(lhs == rhs);
}
};
struct b_int64 {
static constexpr id type_id = id::k_int64;
std::int64_t value = {};
b_int64() = default;
explicit b_int64(std::int64_t value) : value{value} {}
/* explicit(false) */ operator std::int64_t() const {
return value;
}
friend bool operator==(b_int64 const& lhs, b_int64 const& rhs) {
return lhs.value == rhs.value;
}
friend bool operator!=(b_int64 const& lhs, b_int64 const& rhs) {
return !(lhs == rhs);
}
};
struct b_decimal128 {
static constexpr id type_id = id::k_decimal128;
v1::decimal128 value;
b_decimal128() = default;
explicit b_decimal128(v1::decimal128 value) : value{value} {}
/* explicit(false) */ operator v1::decimal128() const {
return value;
}
friend bool operator==(b_decimal128 const& lhs, b_decimal128 const& rhs) {
return lhs.value == rhs.value;
}
friend bool operator!=(b_decimal128 const& lhs, b_decimal128 const& rhs) {
return !(lhs == rhs);
}
};
struct b_maxkey {
static constexpr id type_id = id::k_maxkey;
friend bool operator==(b_maxkey const&, b_maxkey const&) {
return true;
}
friend bool operator!=(b_maxkey const& lhs, b_maxkey const& rhs) {
return !(lhs == rhs);
}
};
struct b_minkey {
static constexpr id type_id = id::k_minkey;
friend bool operator==(b_minkey const&, b_minkey const&) {
return true;
}
friend bool operator!=(b_minkey const& lhs, b_minkey const& rhs) {
return !(lhs == rhs);
}
};
// BSONCXX_V1_TYPES_XMACRO: update above.
#pragma push_macro("X")
#undef X
#define X(_name, _val) BSONCXX_PRIVATE_INLINE_CXX17 constexpr id b_##_name::type_id;
BSONCXX_V1_TYPES_XMACRO(X)
#pragma pop_macro("X")
class view {
private:
id _id;
#pragma push_macro("X")
#undef X
#define X(_name, _value) b_##_name _b_##_name;
union {
BSONCXX_V1_TYPES_XMACRO(X)
};
#pragma pop_macro("X")
template <typename T>
using is_view = detail::is_alike<T, view>;
template <typename T>
struct is_equality_comparable_with
: detail::conjunction<detail::negation<is_view<T>>, std::is_constructible<view, T>> {};
public:
view() : _id{id::k_null}, _b_null{} {}
#pragma push_macro("X")
#undef X
#define X(_name, _value) \
/* explicit(false) */ view(b_##_name v) : _id{v.type_id}, _b_##_name{v} {}
BSONCXX_V1_TYPES_XMACRO(X)
#pragma pop_macro("X")
id type_id() const {
return _id;
}
#pragma push_macro("X")
#undef X
#define X(_name, _value) BSONCXX_ABI_EXPORT_CDECL(b_##_name) get_##_name() const;
BSONCXX_V1_TYPES_XMACRO(X)
#pragma pop_macro("X")
friend bool operator==(view const& lhs, view const& rhs) {
if (lhs.type_id() != rhs.type_id()) {
return false;
}
#pragma push_macro("X")
#undef X
#define X(_name, _value) \
case v1::types::id::k_##_name: \
return lhs.get_##_name() == rhs.get_##_name();
switch (lhs.type_id()) {
BSONCXX_V1_TYPES_XMACRO(X)
default:
return true;
}
#pragma pop_macro("X")
}
friend bool operator!=(view const& lhs, view const& rhs) {
return !(lhs == rhs);
}
friend bool operator==(view const& v, v1::element::view const& e) {
return v == e.type_view();
}
friend bool operator==(v1::element::view const& e, view const& v) {
return v == e.type_view();
}
friend bool operator!=(view const& v, v1::element::view const& e) {
return !(v == e);
}
friend bool operator!=(v1::element::view const& e, view const& v) {
return !(v == e);
}
template <typename T, detail::enable_if_t<is_equality_comparable_with<T>::value>* = nullptr>
friend bool operator==(view const& v, T const& value) {
return v == view{value};
}
template <typename T, detail::enable_if_t<is_equality_comparable_with<T>::value>* = nullptr>
friend bool operator==(T const& value, view const& v) {
return v == view{value};
}
template <typename T, detail::enable_if_t<is_equality_comparable_with<T>::value>* = nullptr>
friend bool operator!=(view const& v, T const& value) {
return !(v == value);
}
template <typename T, detail::enable_if_t<is_equality_comparable_with<T>::value>* = nullptr>
friend bool operator!=(T const& value, view const& v) {
return !(v == value);
}
enum class errc {
zero,
type_mismatch,
};
static BSONCXX_ABI_EXPORT_CDECL(std::error_category const&) error_category();
friend std::error_code make_error_code(errc v) {
return {static_cast<int>(v), error_category()};
}
class internal;
};
} // namespace types
} // namespace v1
} // namespace bsoncxx
template <>
struct std::is_error_code_enum<bsoncxx::v1::types::view::errc> : true_type {};
#include <bsoncxx/v1/detail/postlude.hpp>
export.hpp
Provides macros to control the set of symbols exported in the ABI.
BSONCXX_ABI_EXPORT_CDECL
#define BSONCXX_ABI_EXPORT_CDECL(...)
Equivalent to BSONCXX_ABI_EXPORT with BSONCXX_ABI_CDECL.
Definition export.hpp:52
macros.hpp
For internal use only!
postlude.hpp
The bsoncxx v1 macro guard postlude header.
prelude.hpp
The bsoncxx v1 macro guard prelude header.
bsoncxx::v1::array::view
A non-owning, read-only BSON array.
Definition view.hpp:47
bsoncxx::v1::decimal128
A BSON Decimal128.
Definition decimal128.hpp:37
bsoncxx::v1::document::view
A non-owning, read-only BSON document.
Definition view.hpp:52
bsoncxx::v1::element::view
A non-owning, read-only BSON element.
Definition view.hpp:82
bsoncxx::v1::element::view::type_view
v1::types::view type_view() const
Return a view of the underlying BSON type value.
bsoncxx::v1::oid
A BSON ObjectID.
Definition oid.hpp:41
bsoncxx::v1::stdx::string_view
A polyfill for std::string_view.
Definition string_view.hpp:412
bsoncxx::v1::types::value
A union of BSON type values.
Definition value.hpp:52
bsoncxx::v1::types::view::type_id
id type_id() const
Return the type of the underlying BSON type value.
Definition view.hpp:1020
bsoncxx::v1::types::view::operator!=
friend bool operator!=(v1::element::view const &e, view const &v)
Equivalent to !(v == e).
Definition view.hpp:1102
bsoncxx::v1::types::view::operator==
friend bool operator==(view const &v, v1::element::view const &e)
Equivalent to v == e.type_view().
Definition view.hpp:1084
bsoncxx::v1::types::view::operator==
friend bool operator==(view const &v, T const &value)
Equivalent to v == bsoncxx::v1::types::view{value}.
Definition view.hpp:1117
bsoncxx::v1::types::view::operator!=
friend bool operator!=(view const &v, T const &value)
Equivalent to !(v == value).
Definition view.hpp:1133
bsoncxx::v1::types::view::operator!=
friend bool operator!=(T const &value, view const &v)
Equivalent to !(v == value).
Definition view.hpp:1138
bsoncxx::v1::types::view::operator==
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
bsoncxx::v1::types::view::make_error_code
friend std::error_code make_error_code(errc v)
Support implicit conversion to std::error_code.
Definition view.hpp:1160
bsoncxx::v1::types::view::view
view()
Initialize with bsoncxx::v1::types::b_null.
Definition view.hpp:1001
bsoncxx::v1::types::view::error_category
static std::error_category const & error_category()
The error category for bsoncxx::v1::types::view::errc.
bsoncxx::v1::types::view::operator!=
friend bool operator!=(view const &lhs, view const &rhs)
Equivalent to !(lhs == rhs).
Definition view.hpp:1076
bsoncxx::v1::types::view::operator==
friend bool operator==(T const &value, view const &v)
Equivalent to v == bsoncxx::v1::types::view{value}.
Definition view.hpp:1122
bsoncxx::v1::types::view::errc
errc
Errors codes which may be returned by bsoncxx::v1::types::view.
Definition view.hpp:1147
bsoncxx::v1::types::view::errc::type_mismatch
@ type_mismatch
Requested type does not match the underlying type.
Definition view.hpp:1149
bsoncxx::v1::types::view::errc::zero
@ zero
Zero.
Definition view.hpp:1148
bsoncxx::v1::types::view::operator!=
friend bool operator!=(view const &v, v1::element::view const &e)
Equivalent to !(v == e).
Definition view.hpp:1098
bsoncxx::v1::types::view::operator==
friend bool operator==(v1::element::view const &e, view const &v)
Equivalent to v == e.type_view().
Definition view.hpp:1088
bsoncxx::v1::types
Declares entities representing a BSON type value.
bsoncxx::v1::types::binary_subtype
binary_subtype
Enumeration identifying a BSON binary subtype.
Definition id.hpp:71
bsoncxx::v1::types::id
id
Enumeration identifying a BSON type.
Definition id.hpp:37
bsoncxx::v1::types::id::k_decimal128
@ k_decimal128
128-bit decimal floating point.
Definition id.hpp:57
bsoncxx::v1::types::id::k_minkey
@ k_minkey
Min key.
Definition id.hpp:38
bsoncxx::v1::types::id::k_double
@ k_double
64-bit binary floating point.
Definition id.hpp:39
bsoncxx::v1::types::id::k_dbpointer
@ k_dbpointer
DBPointer.
Definition id.hpp:50
bsoncxx::v1::types::id::k_int64
@ k_int64
64-bit integer.
Definition id.hpp:56
bsoncxx::v1::types::id::k_codewscope
@ k_codewscope
JavaScript code with scope.
Definition id.hpp:53
bsoncxx::v1::types::id::k_regex
@ k_regex
Regular expression.
Definition id.hpp:49
bsoncxx::v1::types::id::k_string
@ k_string
UTF-8 string.
Definition id.hpp:40
bsoncxx::v1::types::id::k_array
@ k_array
Array.
Definition id.hpp:42
bsoncxx::v1::types::id::k_bool
@ k_bool
Boolean.
Definition id.hpp:46
bsoncxx::v1::types::id::k_symbol
@ k_symbol
Symbol.
Definition id.hpp:52
bsoncxx::v1::types::id::k_oid
@ k_oid
ObjectId.
Definition id.hpp:45
bsoncxx::v1::types::id::k_date
@ k_date
UTC datetime.
Definition id.hpp:47
bsoncxx::v1::types::id::k_int32
@ k_int32
32-bit integer.
Definition id.hpp:54
bsoncxx::v1::types::id::k_timestamp
@ k_timestamp
Timestamp.
Definition id.hpp:55
bsoncxx::v1::types::id::k_undefined
@ k_undefined
Undefined value.
Definition id.hpp:44
bsoncxx::v1::types::id::k_code
@ k_code
JavaScript code.
Definition id.hpp:51
bsoncxx::v1::types::id::k_document
@ k_document
Embedded document.
Definition id.hpp:41
bsoncxx::v1::types::id::k_maxkey
@ k_maxkey
Max key.
Definition id.hpp:58
bsoncxx::v1::types::id::k_binary
@ k_binary
Binary data.
Definition id.hpp:43
bsoncxx::v1::types::id::k_null
@ k_null
Null value.
Definition id.hpp:48
bsoncxx::v1
Declares entities whose ABI stability is guaranteed for documented symbols.
bsoncxx
The top-level namespace within which all bsoncxx library entities are declared.
bsoncxx::v1::types::b_array::b_array
b_array()=default
Zero-initialize the represented value.
bsoncxx::v1::types::b_array::operator==
friend bool operator==(b_array const &lhs, b_array const &rhs)
Equivalent to lhs.value == rhs.value.
Definition view.hpp:224
bsoncxx::v1::types::b_array::operator!=
friend bool operator!=(b_array const &lhs, b_array const &rhs)
Equivalent to !(lhs == rhs).
Definition view.hpp:231
bsoncxx::v1::types::b_array::value
v1::array::view value
The represented value.
Definition view.hpp:202
bsoncxx::v1::types::b_array::type_id
static constexpr id type_id
The type represented by this BSON type value.
Definition view.hpp:197
bsoncxx::v1::types::b_array::b_array
b_array(v1::array::view value)
Initialize with value.
Definition view.hpp:212
bsoncxx::v1::types::b_binary::operator==
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
bsoncxx::v1::types::b_binary::b_binary
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
bsoncxx::v1::types::b_binary::b_binary
b_binary()=default
Zero-initialize the represented value.
bsoncxx::v1::types::b_binary::type_id
static constexpr id type_id
The type represented by this BSON type value.
Definition view.hpp:243
bsoncxx::v1::types::b_binary::operator!=
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
bsoncxx::v1::types::b_binary::subtype
binary_subtype subtype
The represented value's binary subtype component.
Definition view.hpp:248
bsoncxx::v1::types::b_binary::bytes
std::uint8_t const * bytes
The represented value's binary data.
Definition view.hpp:258
bsoncxx::v1::types::b_binary::size
std::uint32_t size
The represented value's length of binary data.
Definition view.hpp:253
bsoncxx::v1::types::b_bool::b_bool
b_bool(bool value)
Initialize with value.
Definition view.hpp:395
bsoncxx::v1::types::b_bool::value
bool value
The represented value.
Definition view.hpp:385
bsoncxx::v1::types::b_bool::operator!=
friend bool operator!=(b_bool const &lhs, b_bool const &rhs)
Equivalent to !(lhs == rhs).
Definition view.hpp:414
bsoncxx::v1::types::b_bool::type_id
static constexpr id type_id
The type represented by this BSON type value.
Definition view.hpp:380
bsoncxx::v1::types::b_bool::operator==
friend bool operator==(b_bool const &lhs, b_bool const &rhs)
Equivalent to lhs.value == rhs.value.
Definition view.hpp:407
bsoncxx::v1::types::b_bool::b_bool
b_bool()=default
Zero-initialize the represented value.
bsoncxx::v1::types::b_code::type_id
static constexpr id type_id
The type represented by this BSON type value.
Definition view.hpp:602
bsoncxx::v1::types::b_code::operator!=
friend bool operator!=(b_code const &lhs, b_code const &rhs)
Equivalent to !(lhs == rhs).
Definition view.hpp:636
bsoncxx::v1::types::b_code::code
v1::stdx::string_view code
The represented value.
Definition view.hpp:607
bsoncxx::v1::types::b_code::operator==
friend bool operator==(b_code const &lhs, b_code const &rhs)
Equivalent to lhs.code == rhs.code.
Definition view.hpp:629
bsoncxx::v1::types::b_code::b_code
b_code()=default
Zero-initialize the represented value.
bsoncxx::v1::types::b_code::b_code
b_code(v1::stdx::string_view code)
Initialize with code.
Definition view.hpp:617
bsoncxx::v1::types::b_codewscope::scope
v1::document::view scope
The represented value's "$scope" component.
Definition view.hpp:708
bsoncxx::v1::types::b_codewscope::b_codewscope
b_codewscope()=default
Zero-initialize the represented value.
bsoncxx::v1::types::b_codewscope::operator==
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
bsoncxx::v1::types::b_codewscope::type_id
static constexpr id type_id
The type represented by this BSON type value.
Definition view.hpp:698
bsoncxx::v1::types::b_codewscope::operator!=
friend bool operator!=(b_codewscope const &lhs, b_codewscope const &rhs)
Equivalent to !(lhs == rhs).
Definition view.hpp:730
bsoncxx::v1::types::b_codewscope::b_codewscope
b_codewscope(v1::stdx::string_view code, v1::document::view scope)
Initialize with code and scope.
Definition view.hpp:718
bsoncxx::v1::types::b_codewscope::code
v1::stdx::string_view code
The represented value's "$code" component.
Definition view.hpp:703
bsoncxx::v1::types::b_date::value
std::chrono::milliseconds value
The represented value (milliseconds relative to the Unix epoch).
Definition view.hpp:431
bsoncxx::v1::types::b_date::operator==
friend bool operator==(b_date const &lhs, b_date const &rhs)
Equivalent to lhs.value == rhs.value.
Definition view.hpp:464
bsoncxx::v1::types::b_date::operator!=
friend bool operator!=(b_date const &lhs, b_date const &rhs)
Equivalent to !(lhs == rhs).
Definition view.hpp:471
bsoncxx::v1::types::b_date::type_id
static constexpr id type_id
The type represented by this BSON type value.
Definition view.hpp:426
bsoncxx::v1::types::b_date::b_date
b_date()=default
Zero-initialize the represented value.
bsoncxx::v1::types::b_date::b_date
b_date(std::chrono::milliseconds value)
Initialize with value (milliseconds relative to the Unix epoch).
Definition view.hpp:441
bsoncxx::v1::types::b_date::b_date
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
bsoncxx::v1::types::b_dbpointer::operator==
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
bsoncxx::v1::types::b_dbpointer::b_dbpointer
b_dbpointer(v1::stdx::string_view collection, v1::oid value)
Initialize with collection and value.
Definition view.hpp:578
bsoncxx::v1::types::b_dbpointer::operator!=
friend bool operator!=(b_dbpointer const &lhs, b_dbpointer const &rhs)
Equivalent to !(lhs == rhs).
Definition view.hpp:590
bsoncxx::v1::types::b_dbpointer::type_id
static constexpr id type_id
The type represented by this BSON type value.
Definition view.hpp:558
bsoncxx::v1::types::b_dbpointer::b_dbpointer
b_dbpointer()=default
Zero-initialize the represented value.
bsoncxx::v1::types::b_dbpointer::value
v1::oid value
The represented value's "$id" (ObjectID) component.
Definition view.hpp:568
bsoncxx::v1::types::b_dbpointer::collection
v1::stdx::string_view collection
The represented value's "$ref" (namespace) component.
Definition view.hpp:563
bsoncxx::v1::types::b_decimal128::operator!=
friend bool operator!=(b_decimal128 const &lhs, b_decimal128 const &rhs)
Equivalent to !(lhs == rhs).
Definition view.hpp:912
bsoncxx::v1::types::b_decimal128::b_decimal128
b_decimal128()=default
Zero-initialize the represented value.
bsoncxx::v1::types::b_decimal128::operator==
friend bool operator==(b_decimal128 const &lhs, b_decimal128 const &rhs)
Equivalent to lhs.value == rhs.value.
Definition view.hpp:905
bsoncxx::v1::types::b_decimal128::type_id
static constexpr id type_id
The type represented by this BSON type value.
Definition view.hpp:878
bsoncxx::v1::types::b_decimal128::b_decimal128
b_decimal128(v1::decimal128 value)
Initialize with value.
Definition view.hpp:893
bsoncxx::v1::types::b_decimal128::value
v1::decimal128 value
The represented value.
Definition view.hpp:883
bsoncxx::v1::types::b_document::operator==
friend bool operator==(b_document const &lhs, b_document const &rhs)
Equivalent to lhs.value == rhs.value.
Definition view.hpp:178
bsoncxx::v1::types::b_document::view
operator v1::document::view() const
Implicitly convert to value.
Definition view.hpp:167
bsoncxx::v1::types::b_document::type_id
static constexpr id type_id
The type represented by this BSON type value.
Definition view.hpp:147
bsoncxx::v1::types::b_document::value
v1::document::view value
The represented value.
Definition view.hpp:152
bsoncxx::v1::types::b_document::operator!=
friend bool operator!=(b_document const &lhs, b_document const &rhs)
Equivalent to !(lhs == rhs).
Definition view.hpp:185
bsoncxx::v1::types::b_document::b_document
b_document()=default
Zero-initialize the represented value.
bsoncxx::v1::types::b_document::b_document
b_document(v1::document::view value)
Initialize with value.
Definition view.hpp:162
bsoncxx::v1::types::b_double::b_double
b_double(double value)
Initialize with value.
Definition view.hpp:67
bsoncxx::v1::types::b_double::operator!=
friend bool operator!=(b_double const &lhs, b_double const &rhs)
Equivalent to !(lhs == rhs).
Definition view.hpp:89
bsoncxx::v1::types::b_double::value
double value
The represented value.
Definition view.hpp:57
bsoncxx::v1::types::b_double::operator==
friend bool operator==(b_double const &lhs, b_double const &rhs)
Equivalent to lhs.value == rhs.value.
Definition view.hpp:79
bsoncxx::v1::types::b_double::b_double
b_double()=default
Zero-initialize the represented value.
bsoncxx::v1::types::b_double::type_id
static constexpr id type_id
The type represented by this BSON type value.
Definition view.hpp:52
bsoncxx::v1::types::b_int32::operator==
friend bool operator==(b_int32 const &lhs, b_int32 const &rhs)
Equivalent to lhs.value == rhs.value.
Definition view.hpp:769
bsoncxx::v1::types::b_int32::b_int32
b_int32()=default
Zero-initialize the represented value.
bsoncxx::v1::types::b_int32::type_id
static constexpr id type_id
The type represented by this BSON type value.
Definition view.hpp:742
bsoncxx::v1::types::b_int32::value
std::int32_t value
The represented value.
Definition view.hpp:747
bsoncxx::v1::types::b_int32::operator!=
friend bool operator!=(b_int32 const &lhs, b_int32 const &rhs)
Equivalent to !(lhs == rhs).
Definition view.hpp:776
bsoncxx::v1::types::b_int32::b_int32
b_int32(std::int32_t value)
Initialize with value.
Definition view.hpp:757
bsoncxx::v1::types::b_int64::type_id
static constexpr id type_id
The type represented by this BSON type value.
Definition view.hpp:832
bsoncxx::v1::types::b_int64::operator!=
friend bool operator!=(b_int64 const &lhs, b_int64 const &rhs)
Equivalent to !(lhs == rhs).
Definition view.hpp:866
bsoncxx::v1::types::b_int64::operator==
friend bool operator==(b_int64 const &lhs, b_int64 const &rhs)
Equivalent to lhs.value == rhs.value.
Definition view.hpp:859
bsoncxx::v1::types::b_int64::b_int64
b_int64(std::int64_t value)
Initialize with value.
Definition view.hpp:847
bsoncxx::v1::types::b_int64::b_int64
b_int64()=default
Zero-initialize the represented value.
bsoncxx::v1::types::b_int64::value
std::int64_t value
The represented value.
Definition view.hpp:837
bsoncxx::v1::types::b_maxkey
BSON type value "Max Key".
Definition view.hpp:920
bsoncxx::v1::types::b_maxkey::operator!=
friend bool operator!=(b_maxkey const &lhs, b_maxkey const &rhs)
Return false.
Definition view.hpp:936
bsoncxx::v1::types::b_maxkey::type_id
static constexpr id type_id
The type represented by this BSON type value.
Definition view.hpp:924
bsoncxx::v1::types::b_maxkey::operator==
friend bool operator==(b_maxkey const &, b_maxkey const &)
Return true.
Definition view.hpp:929
bsoncxx::v1::types::b_minkey
BSON type value "Min Key".
Definition view.hpp:944
bsoncxx::v1::types::b_minkey::type_id
static constexpr id type_id
The type represented by this BSON type value.
Definition view.hpp:948
bsoncxx::v1::types::b_minkey::operator==
friend bool operator==(b_minkey const &, b_minkey const &)
Return true.
Definition view.hpp:953
bsoncxx::v1::types::b_minkey::operator!=
friend bool operator!=(b_minkey const &lhs, b_minkey const &rhs)
Return false.
Definition view.hpp:960
bsoncxx::v1::types::b_null
BSON type value "Null Value".
Definition view.hpp:479
bsoncxx::v1::types::b_null::operator==
friend bool operator==(b_null const &, b_null const &)
Return true.
Definition view.hpp:488
bsoncxx::v1::types::b_null::type_id
static constexpr id type_id
The type represented by this BSON type value.
Definition view.hpp:483
bsoncxx::v1::types::b_null::operator!=
friend bool operator!=(b_null const &lhs, b_null const &rhs)
Return false.
Definition view.hpp:495
bsoncxx::v1::types::b_oid::value
v1::oid value
The represented value.
Definition view.hpp:339
bsoncxx::v1::types::b_oid::b_oid
b_oid()=default
Zero-initialize the represented value.
bsoncxx::v1::types::b_oid::b_oid
b_oid(v1::oid const &value)
Initialize with value.
Definition view.hpp:349
bsoncxx::v1::types::b_oid::operator==
friend bool operator==(b_oid const &lhs, b_oid const &rhs)
Equivalent to lhs.value == rhs.value.
Definition view.hpp:361
bsoncxx::v1::types::b_oid::operator!=
friend bool operator!=(b_oid const &lhs, b_oid const &rhs)
Equivalent to !(lhs == rhs).
Definition view.hpp:368
bsoncxx::v1::types::b_oid::type_id
static constexpr id type_id
The type represented by this BSON type value.
Definition view.hpp:334
bsoncxx::v1::types::b_regex::b_regex
b_regex(v1::stdx::string_view regex, v1::stdx::string_view options)
Initialize with regex and options.
Definition view.hpp:532
bsoncxx::v1::types::b_regex::type_id
static constexpr id type_id
The type represented by this BSON type value.
Definition view.hpp:507
bsoncxx::v1::types::b_regex::regex
v1::stdx::string_view regex
The represented value's "pattern" component.
Definition view.hpp:512
bsoncxx::v1::types::b_regex::b_regex
b_regex(v1::stdx::string_view regex)
Initialize with regex and an empty options.
Definition view.hpp:527
bsoncxx::v1::types::b_regex::operator!=
friend bool operator!=(b_regex const &lhs, b_regex const &rhs)
Equivalent to !(lhs == rhs).
Definition view.hpp:544
bsoncxx::v1::types::b_regex::b_regex
b_regex()=default
Zero-initialize the represented value.
bsoncxx::v1::types::b_regex::options
v1::stdx::string_view options
The represented value's "options" component.
Definition view.hpp:517
bsoncxx::v1::types::b_regex::operator==
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
bsoncxx::v1::types::b_string::operator==
friend bool operator==(b_string const &lhs, b_string const &rhs)
Equivalent to lhs.value == rhs.value.
Definition view.hpp:128
bsoncxx::v1::types::b_string::b_string
b_string(v1::stdx::string_view value)
Initialize with value.
Definition view.hpp:116
bsoncxx::v1::types::b_string::value
v1::stdx::string_view value
The represented value.
Definition view.hpp:106
bsoncxx::v1::types::b_string::b_string
b_string()=default
Zero-initialize the represented value.
bsoncxx::v1::types::b_string::operator!=
friend bool operator!=(b_string const &lhs, b_string const &rhs)
Equivalent to !(lhs == rhs).
Definition view.hpp:135
bsoncxx::v1::types::b_string::type_id
static constexpr id type_id
The type represented by this BSON type value.
Definition view.hpp:101
bsoncxx::v1::types::b_symbol::symbol
v1::stdx::string_view symbol
The represented value.
Definition view.hpp:655
bsoncxx::v1::types::b_symbol::b_symbol
b_symbol(v1::stdx::string_view symbol)
Initialize with symbol.
Definition view.hpp:665
bsoncxx::v1::types::b_symbol::operator==
friend bool operator==(b_symbol const &lhs, b_symbol const &rhs)
Equivalent to lhs.symbol == rhs.symbol.
Definition view.hpp:677
bsoncxx::v1::types::b_symbol::type_id
static constexpr id type_id
The type represented by this BSON type value.
Definition view.hpp:650
bsoncxx::v1::types::b_symbol::operator!=
friend bool operator!=(b_symbol const &lhs, b_symbol const &rhs)
Equivalent to !(lhs == rhs).
Definition view.hpp:684
bsoncxx::v1::types::b_symbol::b_symbol
b_symbol()=default
Zero-initialize the represented value.
bsoncxx::v1::types::b_timestamp::increment
std::uint32_t increment
The represented value's "i" component.
Definition view.hpp:793
bsoncxx::v1::types::b_timestamp::b_timestamp
b_timestamp()=default
Zero-initialize the represented value.
bsoncxx::v1::types::b_timestamp::operator==
friend bool operator==(b_timestamp const &lhs, b_timestamp const &rhs)
Equivalent to lhs.timestamp == rhs.timestamp.
Definition view.hpp:813
bsoncxx::v1::types::b_timestamp::type_id
static constexpr id type_id
The type represented by this BSON type value.
Definition view.hpp:788
bsoncxx::v1::types::b_timestamp::b_timestamp
b_timestamp(std::uint32_t increment, std::uint32_t timestamp)
Initialize with increment and timestamp.
Definition view.hpp:808
bsoncxx::v1::types::b_timestamp::timestamp
std::uint32_t timestamp
The represented value's "t" component.
Definition view.hpp:798
bsoncxx::v1::types::b_timestamp::operator!=
friend bool operator!=(b_timestamp const &lhs, b_timestamp const &rhs)
Equivalent to !(lhs == rhs).
Definition view.hpp:820
bsoncxx::v1::types::b_undefined
BSON type value "Undefined (Value)".
Definition view.hpp:306
bsoncxx::v1::types::b_undefined::operator!=
friend bool operator!=(b_undefined const &lhs, b_undefined const &rhs)
Return false.
Definition view.hpp:322
bsoncxx::v1::types::b_undefined::operator==
friend bool operator==(b_undefined const &, b_undefined const &)
Return true.
Definition view.hpp:315
bsoncxx::v1::types::b_undefined::type_id
static constexpr id type_id
The type represented by this BSON type value.
Definition view.hpp:310
view.hpp
Provides bsoncxx::v1::array::view.
decimal128.hpp
Provides bsoncxx::v1::decimal128.
type_traits.hpp
For internal use only!
view.hpp
Provides bsoncxx::v1::document::view.
oid.hpp
Provides bsoncxx::v1::oid.
string_view.hpp
Provides std::string_view-related polyfills for library API usage.
BSONCXX_V1_TYPES_XMACRO
#define BSONCXX_V1_TYPES_XMACRO(X)
X-macro over the name and value of BSON types.
Definition id-fwd.hpp:44
id.hpp
Provides enumerations identifying the type of a BSON element.
view-fwd.hpp
Declares non-owning, read-only entities representing a BSON type value.