MongoDB C++ Driver mongocxx-4.0.0
|
#include <bsoncxx/v_noabi/bsoncxx/document/element.hpp>
A variant view type that accesses values in serialized BSON documents.
Element functions as a variant type, where the kind of the element can be interrogated by calling type(), the key can be extracted by calling key() and a specific value can be extracted through get_X() accessors.
Public Member Functions | |
element () | |
Construct an invalid element. | |
types::b_array | get_array () const |
Getter for elements of the b_array type. | |
types::b_binary | get_binary () const |
Getter for elements of the b_binary type. | |
types::b_bool | get_bool () const |
Getter for elements of the b_bool type. | |
types::b_code | get_code () const |
Getter for elements of the b_code type. | |
types::b_codewscope | get_codewscope () const |
Getter for elements of the b_codewscope type. | |
types::b_date | get_date () const |
Getter for elements of the b_date type. | |
types::b_dbpointer | get_dbpointer () const |
Getter for elements of the b_dbpointer type. | |
types::b_decimal128 | get_decimal128 () const |
Getter for elements of the b_decimal128 type. | |
types::b_document | get_document () const |
Getter for elements of the b_document type. | |
types::b_double | get_double () const |
Getter for elements of the b_double type. | |
types::b_int32 | get_int32 () const |
Getter for elements of the b_int32 type. | |
types::b_int64 | get_int64 () const |
Getter for elements of the b_int64 type. | |
types::b_maxkey | get_maxkey () const |
Getter for elements of the b_maxkey type. | |
types::b_minkey | get_minkey () const |
Getter for elements of the b_minkey type. | |
types::b_null | get_null () const |
Getter for elements of the b_null type. | |
types::b_oid | get_oid () const |
Getter for elements of the b_oid type. | |
types::bson_value::value | get_owning_value () const |
Getter for a types::bson_value::value variant wrapper of the value portion of the element. The returned object will make a copy of the buffer from this object. | |
types::b_regex | get_regex () const |
Getter for elements of the b_regex type. | |
types::b_string | get_string () const |
Getter for elements of the b_string type. | |
types::b_symbol | get_symbol () const |
Getter for elements of the b_symbol type. | |
types::b_timestamp | get_timestamp () const |
Getter for elements of the b_timestamp type. | |
types::b_undefined | get_undefined () const |
Getter for elements of the b_undefined type. | |
types::bson_value::view | get_value () const |
Getter for a types::bson_value::view variant wrapper of the value portion of the element. | |
stdx::string_view | key () const |
Getter for the element's key. | |
std::uint32_t | keylen () const |
Getter for the element's key length. | |
std::uint32_t | length () const |
Getter for length of the raw bson bytes the element points to. | |
std::uint32_t | offset () const |
Getter for the offset into the raw bson bytes the element points to. | |
operator bool () const | |
Conversion operator to bool which is true for valid elements and false for invalid elements. | |
array::element | operator[] (std::uint32_t i) const |
If this element is an array, indexes into this BSON array. If the index is out-of-bounds, an invalid array::element will be returned. As BSON represents arrays as documents, the runtime of operator[] is linear in the length of the array. | |
element | operator[] (stdx::string_view key) const |
If this element is a document, finds the first element of the document with the provided key. If there is no such element, an invalid document::element will be returned. The runtime of operator[] is linear in the length of the document. | |
const std::uint8_t * | raw () const |
Getter for the raw bson bytes the element points to. | |
bsoncxx::v_noabi::type | type () const |
Getter for the type of the element. | |
Related Symbols | |
(Note that these are not member symbols.) | |
bool | operator== (const element &elem, const types::bson_value::view &v) |
Convenience methods to compare for equality against a bson_value. | |
bool | operator== (const types::bson_value::view &v, const element &elem) |
Convenience methods to compare for equality against a bson_value. | |
bool | operator!= (const element &elem, const types::bson_value::view &v) |
Convenience methods to compare for equality against a bson_value. | |
bool | operator!= (const types::bson_value::view &v, const element &elem) |
Convenience methods to compare for equality against a bson_value. | |
bsoncxx::v_noabi::document::element::element | ( | ) |
Construct an invalid element.
This is useful when mapping the end iterator of a document or array view.
types::b_array bsoncxx::v_noabi::document::element::get_array | ( | ) | const |
Getter for elements of the b_array type.
bsoncxx::v_noabi::exception | if this element is not a b_array. |
types::b_binary bsoncxx::v_noabi::document::element::get_binary | ( | ) | const |
Getter for elements of the b_binary type.
bsoncxx::v_noabi::exception | if this element is not a b_binary. |
types::b_bool bsoncxx::v_noabi::document::element::get_bool | ( | ) | const |
Getter for elements of the b_bool type.
bsoncxx::v_noabi::exception | if this element is not a b_bool. |
types::b_code bsoncxx::v_noabi::document::element::get_code | ( | ) | const |
Getter for elements of the b_code type.
bsoncxx::v_noabi::exception | if this element is not a b_code. |
types::b_codewscope bsoncxx::v_noabi::document::element::get_codewscope | ( | ) | const |
Getter for elements of the b_codewscope type.
bsoncxx::v_noabi::exception | if this element is not a b_codewscope. |
types::b_date bsoncxx::v_noabi::document::element::get_date | ( | ) | const |
Getter for elements of the b_date type.
bsoncxx::v_noabi::exception | if this element is not a b_date. |
types::b_dbpointer bsoncxx::v_noabi::document::element::get_dbpointer | ( | ) | const |
Getter for elements of the b_dbpointer type.
bsoncxx::v_noabi::exception | if this element is not a b_dbpointer. |
types::b_decimal128 bsoncxx::v_noabi::document::element::get_decimal128 | ( | ) | const |
Getter for elements of the b_decimal128 type.
bsoncxx::v_noabi::exception | if this element is not a b_decimal128. |
types::b_document bsoncxx::v_noabi::document::element::get_document | ( | ) | const |
Getter for elements of the b_document type.
bsoncxx::v_noabi::exception | if this element is not a b_document. |
types::b_double bsoncxx::v_noabi::document::element::get_double | ( | ) | const |
Getter for elements of the b_double type.
bsoncxx::v_noabi::exception | if this element is not a b_double. |
types::b_int32 bsoncxx::v_noabi::document::element::get_int32 | ( | ) | const |
Getter for elements of the b_int32 type.
bsoncxx::v_noabi::exception | if this element is not a b_int32. |
types::b_int64 bsoncxx::v_noabi::document::element::get_int64 | ( | ) | const |
Getter for elements of the b_int64 type.
bsoncxx::v_noabi::exception | if this element is not a b_int64. |
types::b_maxkey bsoncxx::v_noabi::document::element::get_maxkey | ( | ) | const |
Getter for elements of the b_maxkey type.
bsoncxx::v_noabi::exception | if this element is not a b_maxkey. |
types::b_minkey bsoncxx::v_noabi::document::element::get_minkey | ( | ) | const |
Getter for elements of the b_minkey type.
bsoncxx::v_noabi::exception | if this element is not a b_minkey. |
types::b_null bsoncxx::v_noabi::document::element::get_null | ( | ) | const |
Getter for elements of the b_null type.
bsoncxx::v_noabi::exception | if this element is not a b_null. |
types::b_oid bsoncxx::v_noabi::document::element::get_oid | ( | ) | const |
Getter for elements of the b_oid type.
bsoncxx::v_noabi::exception | if this element is not a b_oid. |
types::bson_value::value bsoncxx::v_noabi::document::element::get_owning_value | ( | ) | const |
Getter for a types::bson_value::value variant wrapper of the value portion of the element. The returned object will make a copy of the buffer from this object.
types::b_regex bsoncxx::v_noabi::document::element::get_regex | ( | ) | const |
Getter for elements of the b_regex type.
bsoncxx::v_noabi::exception | if this element is not a b_regex. |
types::b_string bsoncxx::v_noabi::document::element::get_string | ( | ) | const |
Getter for elements of the b_string type.
bsoncxx::v_noabi::exception | if this element is not a b_string. |
types::b_symbol bsoncxx::v_noabi::document::element::get_symbol | ( | ) | const |
Getter for elements of the b_symbol type.
bsoncxx::v_noabi::exception | if this element is not a b_symbol. |
types::b_timestamp bsoncxx::v_noabi::document::element::get_timestamp | ( | ) | const |
Getter for elements of the b_timestamp type.
bsoncxx::v_noabi::exception | if this element is not a b_timestamp. |
types::b_undefined bsoncxx::v_noabi::document::element::get_undefined | ( | ) | const |
Getter for elements of the b_undefined type.
bsoncxx::v_noabi::exception | if this element is not a b_undefined. |
types::bson_value::view bsoncxx::v_noabi::document::element::get_value | ( | ) | const |
Getter for a types::bson_value::view variant wrapper of the value portion of the element.
stdx::string_view bsoncxx::v_noabi::document::element::key | ( | ) | const |
Getter for the element's key.
bsoncxx::v_noabi::exception | if this element is invalid. |
std::uint32_t bsoncxx::v_noabi::document::element::keylen | ( | ) | const |
Getter for the element's key length.
std::uint32_t bsoncxx::v_noabi::document::element::length | ( | ) | const |
Getter for length of the raw bson bytes the element points to.
std::uint32_t bsoncxx::v_noabi::document::element::offset | ( | ) | const |
Getter for the offset into the raw bson bytes the element points to.
|
explicit |
Conversion operator to bool which is true for valid elements and false for invalid elements.
array::element bsoncxx::v_noabi::document::element::operator[] | ( | std::uint32_t | i | ) | const |
If this element is an array, indexes into this BSON array. If the index is out-of-bounds, an invalid array::element will be returned. As BSON represents arrays as documents, the runtime of operator[] is linear in the length of the array.
If this element is not an array, an invalid array::element will be returned.
i | The index of the element. |
element bsoncxx::v_noabi::document::element::operator[] | ( | stdx::string_view | key | ) | const |
If this element is a document, finds the first element of the document with the provided key. If there is no such element, an invalid document::element will be returned. The runtime of operator[] is linear in the length of the document.
If this element is not a document, an invalid document::element will be returned.
key | The key to search for. |
const std::uint8_t * bsoncxx::v_noabi::document::element::raw | ( | ) | const |
Getter for the raw bson bytes the element points to.
bsoncxx::v_noabi::type bsoncxx::v_noabi::document::element::type | ( | ) | const |
Getter for the type of the element.
bsoncxx::v_noabi::exception | if this element is invalid. |
|
related |
Convenience methods to compare for equality against a bson_value.
Compares equal if the element contains a matching bson_value. Otherwise, compares unequal.
|
related |
Convenience methods to compare for equality against a bson_value.
Compares equal if the element contains a matching bson_value. Otherwise, compares unequal.
|
related |
Convenience methods to compare for equality against a bson_value.
Compares equal if the element contains a matching bson_value. Otherwise, compares unequal.
|
related |
Convenience methods to compare for equality against a bson_value.
Compares equal if the element contains a matching bson_value. Otherwise, compares unequal.