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::document::view::view |
( |
| ) |
|
Default constructs a view.
The resulting view will be initialized to point at an empty BSON document.
bsoncxx::document::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 document. |
length | The size of the buffer, in bytes. |
iterator bsoncxx::document::view::begin |
( |
| ) |
const |
- Returns
- An iterator to the first element of the document.
const std::uint8_t* bsoncxx::document::view::data |
( |
| ) |
const |
Access the raw bytes of the underlying document.
- Returns
- A (non-owning) pointer to the view's buffer.
bool bsoncxx::document::view::empty |
( |
| ) |
const |
Checks if the underlying document is empty, i.e.
it is equivalent to the trivial document '{}'.
- Returns
- true if the underlying document is empty.
iterator bsoncxx::document::view::end |
( |
| ) |
const |
- Returns
- An iterator to the past-the-end element of the document.
iterator bsoncxx::document::view::find |
( |
stdx::string_view |
key | ) |
const |
Finds the first element of the document with the provided key.
If there is no such element, the past-the-end iterator will be returned. The runtime of find() is linear in the length of the document. This method only searches the top-level document, and will not recurse to any subdocuments.
- Parameters
-
key | The key to search for. |
- Returns
- An iterator to the matching element, if found, or the past-the-end iterator.
std::size_t bsoncxx::document::view::length |
( |
| ) |
const |
Gets the length of the underlying buffer.
- Returns
- The length of the document, in bytes.
element bsoncxx::document::view::operator[] |
( |
stdx::string_view |
key | ) |
const |
Finds the first element of the document with the provided key.
If there is no such element, the invalid document::element will be returned. The runtime of operator[] is linear in the length of the document.
- Parameters
-
key | The key to search for. |
- Returns
- The matching element, if found, or the invalid element.
The documentation for this class was generated from the following file: