Loading...
Searching...
No Matches
bsoncxx::v_noabi::array::element Class Reference

`#include <bsoncxx/v_noabi/bsoncxx/array/element.hpp>`

## Description

A variant view type that accesses values in serialized BSON arrays.

Element functions as a variant type, where the kind of the element can be interrogated by calling type() and a specific value can be extracted through get_X() accessors.

## Public Member Functions

v_noabi::types::b_minkey | get_minkey () const
| Return the BSON type value of this element.
v_noabi::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.
v_noabi::types::bson_value::view | get_value () const
| Getter for a types::bson_value::view variant wrapper of the value portion of the element.
v1::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.
v_noabi::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[] (v1::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.
std::uint8_t const * | raw () const
| Getter for the raw bson bytes the element points to.
v_noabi::type | type () const
| Getter for the type of the element.
v_noabi::types::bson_value::value | type_value () const
| Equivalent to get_owning_value() const.
v_noabi::types::bson_value::view | type_view () const
| Equivalent to get_value() const.

## Friends

bool | operator== (element const &lhs, v_noabi::types::bson_value::view const &rhs)
| Convenience methods to compare for equality against a bson_value.

## Related Symbols

(Note that these are not member symbols.)
bool | operator== (element const &lhs, v_noabi::types::bson_value::view const &rhs)
| Convenience methods to compare for equality against a bson_value.
bool | operator== (v_noabi::types::bson_value::view const &lhs, element const &rhs)
| Convenience methods to compare for equality against a bson_value.
bool | operator!= (element const &lhs, v_noabi::types::bson_value::view const &rhs)
| Convenience methods to compare for equality against a bson_value.
bool | operator!= (v_noabi::types::bson_value::view const &lhs, element const &rhs)
| Convenience methods to compare for equality against a bson_value.
Related Symbols inherited from bsoncxx::v_noabi::document::element
bool | operator== (element const &lhs, v_noabi::types::bson_value::view const &rhs)
| Convenience methods to compare for equality against a bson_value.
bool | operator== (v_noabi::types::bson_value::view const &lhs, element const &rhs)
| Convenience methods to compare for equality against a bson_value.
bool | operator!= (element const &lhs, v_noabi::types::bson_value::view const &rhs)
| Convenience methods to compare for equality against a bson_value.
bool | operator!= (v_noabi::types::bson_value::view const &lhs, element const &rhs)
| Convenience methods to compare for equality against a bson_value.

## Member Function Documentation

## get_minkey()

v_noabi::types::b_minkey bsoncxx::v_noabi::document::element::get_minkey | ( |  | ) | const

Return the BSON type value of this element.

Exceptions

  bsoncxx::v_noabi::exception | if this element is not the requested type.

## get_owning_value()

v_noabi::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.

Deprecated
  Use type_value() const instead (renamed).

Returns
  an owning version of the element's value.

## get_value()

v_noabi::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.

Deprecated
  Use type_view() const instead (renamed).

Returns
  the element's value.

## key()

v1::stdx::string_view bsoncxx::v_noabi::document::element::key | ( |  | ) | const

Getter for the element's key.

Returns
  the element's key.

Exceptions

  bsoncxx::v_noabi::exception | if this element is invalid.

## keylen()

std::uint32_t bsoncxx::v_noabi::document::element::keylen | ( |  | ) | const

inline

Getter for the element's key length.

Returns
  the element's key length.

## length()

std::uint32_t bsoncxx::v_noabi::document::element::length | ( |  | ) | const

inline

Getter for length of the raw bson bytes the element points to.

Returns
  a pointer to the length of the raw bson bytes.

## offset()

std::uint32_t bsoncxx::v_noabi::document::element::offset | ( |  | ) | const

inline

Getter for the offset into the raw bson bytes the element points to.

Returns
  the offset into the raw bson bytes.

## operator bool()

bsoncxx::v_noabi::document::element::operator bool | ( |  | ) | const

inline explicit

Conversion operator to bool which is true for valid elements and false for invalid elements.

## operator[]() [1/2]

v_noabi::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.

Parameters

  i | The index of the element.

Returns
  The element if it exists, or an invalid element.

## operator[]() [2/2]

element bsoncxx::v_noabi::document::element::operator[] | ( | v1::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.

Parameters

  key | The key to search for.

Returns
  The matching element, if found, or an invalid element.

## raw()

std::uint8_t const * bsoncxx::v_noabi::document::element::raw | ( |  | ) | const

inline

Getter for the raw bson bytes the element points to.

Returns
  a pointer to the raw bson bytes.

## type()

v_noabi::type bsoncxx::v_noabi::document::element::type | ( |  | ) | const

Getter for the type of the element.

Returns
  the element's type.

Exceptions

  bsoncxx::v_noabi::exception | if this element is invalid.

## type_value()

v_noabi::types::bson_value::value bsoncxx::v_noabi::document::element::type_value | ( |  | ) | const

Equivalent to get_owning_value() const.

To support incremental migration to bsoncxx::v1::element::view::type_value() const.

## type_view()

v_noabi::types::bson_value::view bsoncxx::v_noabi::document::element::type_view | ( |  | ) | const

Equivalent to get_value() const.

To support incremental migration to bsoncxx::v1::element::view::type_view() const.

## Friends And Related Symbol Documentation

## operator!=() [1/2]

bool operator!= | ( | element const & | lhs,
|  | v_noabi::types::bson_value::view const & | rhs )

related

Convenience methods to compare for equality against a bson_value.

Compares equal if this element contains a matching bson_value. Otherwise, compares unequal.

## operator!=() [2/2]

bool operator!= | ( | v_noabi::types::bson_value::view const & | lhs,
|  | element const & | rhs )

related

Convenience methods to compare for equality against a bson_value.

Compares equal if this element contains a matching bson_value. Otherwise, compares unequal.

## operator==() [1/3]

bool operator== | ( | element const & | lhs,
|  | v_noabi::types::bson_value::view const & | rhs )

related

Convenience methods to compare for equality against a bson_value.

Compares equal if this element contains a matching bson_value. Otherwise, compares unequal.

## operator== [2/3]

bool operator== | ( | element const & | lhs,
|  | v_noabi::types::bson_value::view const & | rhs )

friend

Convenience methods to compare for equality against a bson_value.

Compares equal if this element contains a matching bson_value. Otherwise, compares unequal.

## operator==() [3/3]

bool operator== | ( | v_noabi::types::bson_value::view const & | lhs,
|  | element const & | rhs )

related

Convenience methods to compare for equality against a bson_value.

Compares equal if this element contains a matching bson_value. Otherwise, compares unequal.

The documentation for this class was generated from the following file:

- bsoncxx/v_noabi/bsoncxx/array/element.hpp