#include <bsoncxx/v1/array/view.hpp>
A non-owning, read-only BSON array.
An "invalid" view, as indicated by operator bool() const, does not satisfy the minimum requirements of a valid BSON document, which are that:
The BSON bytes being represented is only validated as minimally required to satisfy a requested operation. When an operation is not satisfiable due to invalid data, the operation will throw an bsoncxx::v1::exception with bsoncxx::v1::document::view::errc::invalid_data.
Public Types | |
| using | const_iterator = v1::document::view::const_iterator |
| A const iterator over the elements of a view. | |
| using | iterator = const_iterator |
| Equivalent to const_iterator. | |
Public Member Functions | |
| view ()=default | |
| Initialize as an empty view. | |
| view (std::uint8_t const *data) | |
| Initialize with the given BSON bytes. | |
| view (std::uint8_t const *data, std::size_t length) | |
| Equivalent to view(std::uint8_t const* data), but validates the embedded length against length. | |
| const_iterator | begin () const |
| Return a const iterator to the beginning of the range of BSON elements within this view. | |
| const_iterator | cbegin () const |
| Return a const iterator to the beginning of the range of BSON elements within this view. | |
| const_iterator | cend () const |
| Return a const iterator to the end of the range of BSON elements within this view. | |
| std::uint8_t const * | data () const |
| Return a pointer to the BSON bytes being represented. | |
| bool | empty () const |
| Return true when the BSON bytes represents an empty view: | |
| const_iterator | end () const |
| Return a const iterator to the end of the range of BSON elements within this view. | |
| const_iterator | find (std::uint32_t i) const |
| Return a const iterator to the element within the represented BSON array at index i via key string comparison. | |
| std::size_t | length () const |
| Return the length of the BSON bytes being represented. | |
| operator bool () const | |
| Return true when this view is valid. | |
| operator v1::document::view () const | |
| Implicitly convert to a bsoncxx::v1::document::view. | |
| v1::element::view | operator[] (std::uint32_t i) const |
| Return the first element within the represented BSON array whose key compares equal to i. | |
| std::size_t | size () const |
| Return the length of the BSON bytes being represented. | |
Friends | |
| bool | operator!= (view lhs, view rhs) |
| Compare equal when the BSON bytes represented by lhs and rhs compare equal. | |
| bool | operator== (view lhs, view rhs) |
| Compare equal when the BSON bytes represented by lhs and rhs compare equal. | |
A const iterator over the elements of a view.
Equivalent to const_iterator.
|
default |
|
inlineexplicit |
|
inline |
Equivalent to view(std::uint8_t const* data), but validates the embedded length against length.
| bsoncxx::v1::exception | with bsoncxx::v1::document::view::errc::invalid_length if `length` is less than 5 or less than this->size(). |
|
inline |
Return a const iterator to the beginning of the range of BSON elements within this view.
If this view is invalid, returns an end iterator.
| bsoncxx::v1::exception | with bsoncxx::v1::document::view::errc::invalid_data if this operation failed due to invalid BSON bytes. |
|
inline |
Return a const iterator to the beginning of the range of BSON elements within this view.
If this view is invalid, returns an end iterator.
| bsoncxx::v1::exception | with bsoncxx::v1::document::view::errc::invalid_data if this operation failed due to invalid BSON bytes. |
|
inline |
Return a const iterator to the end of the range of BSON elements within this view.
|
inline |
Return a pointer to the BSON bytes being represented.
|
inline |
|
inline |
Return a const iterator to the end of the range of BSON elements within this view.
| const_iterator bsoncxx::v1::array::view::find | ( | std::uint32_t | i | ) | const |
Return a const iterator to the element within the represented BSON array at index i via key string comparison.
If this view is invalid or the requested field is not found, returns an end iterator.
| bsoncxx::v1::exception | with bsoncxx::v1::document::view::errc::invalid_data if this operation failed due to invalid BSON bytes. |
|
inline |
Return the length of the BSON bytes being represented.
If this->data() is null, returns 0.
|
inlineexplicit |
Return true when this view is valid.
|
inline |
Implicitly convert to a bsoncxx::v1::document::view.
|
inline |
Return the first element within the represented BSON array whose key compares equal to i.
| bsoncxx::v1::exception | with bsoncxx::v1::document::view::errc::invalid_data if this operation failed due to invalid BSON bytes. |
|
inline |
Return the length of the BSON bytes being represented.
If this->data() is null, returns 0.
Compare equal when the BSON bytes represented by lhs and rhs compare equal.
An invalid view only compares equal to another invalid view. The underlying BSON bytes (if any) is ignored for an invalid document.
Compare equal when the BSON bytes represented by lhs and rhs compare equal.
An invalid view only compares equal to another invalid view. The underlying BSON bytes (if any) is ignored for an invalid document.