A read-only, non-owning view of a BSON document.
More...
#include <view.hpp>
A read-only, non-owning view of a BSON document.
bsoncxx::array::view::view |
( |
| ) |
|
Default constructs a view.
The resulting view will be initialized to point at an empty BSON array.
bsoncxx::array::view::view |
( |
const std::uint8_t * |
data, |
|
|
std::size_t |
length |
|
) |
| |
Constructs a view from a buffer.
The caller is responsible for ensuring that the lifetime of the resulting view is a subset of the buffer's.
- Parameters
-
data | A buffer containing a valid BSON array. |
length | The size of the buffer, in bytes. |
iterator bsoncxx::array::view::begin |
( |
| ) |
const |
- Returns
- An iterator to the first element of the array.
const std::uint8_t* bsoncxx::array::view::data |
( |
| ) |
const |
Access the raw bytes of the underlying array.
- Returns
- A (non-owning) pointer to the view's buffer.
bool bsoncxx::array::view::empty |
( |
| ) |
const |
Checks if the underlying buffer is empty, i.e.
it is equivalent to the trivial array '[]'.
- Returns
- true if the underlying document is empty.
iterator bsoncxx::array::view::end |
( |
| ) |
const |
- Returns
- An iterator to the past-the-end element of the array.
iterator bsoncxx::array::view::find |
( |
std::uint32_t |
i | ) |
const |
Indexes into this BSON array.
If the index is out-of-bounds, a past-the-end iterator will be returned. As BSON represents arrays as documents, the runtime of find() is linear in the length of the array.
- Parameters
-
i | The index of the element. |
- Returns
- An iterator to the element if it exists, or the past-the-end iterator.
std::size_t bsoncxx::array::view::length |
( |
| ) |
const |
Gets the length of the underlying buffer.
- Returns
- The length of the array, in bytes.
element bsoncxx::array::view::operator[] |
( |
std::uint32_t |
i | ) |
const |
Indexes into this BSON array.
If the index is out-of-bounds, the invalid array::element will be returned. As BSON represents arrays as documents, the runtime of operator[] is linear in the length of the array.
- Parameters
-
i | The index of the element. |
- Returns
- The element if it exists, or the invalid element.
The documentation for this class was generated from the following file: