32#include <system_error>
64 enum : std::size_t { _empty_length = 5u };
66 std::uint8_t
const* _data;
68 template <detail::endian e = detail::endian::native>
69 std::int32_t raw_size()
const;
106 std::uint8_t
const*
data()
const {
118 std::size_t
size()
const;
135 return this->
size() == _empty_length && _data[4] == 0u;
143 explicit operator bool()
const {
144 return this->
size() >= _empty_length;
210 return !(lhs == rhs);
244inline std::int32_t view::raw_size<detail::endian::little>()
const {
246 std::memcpy(&res, _data,
sizeof(res));
251inline std::int32_t view::raw_size<detail::endian::big>()
const {
253 auto const bytes =
reinterpret_cast<unsigned char*
>(&res);
262 return _data ?
static_cast<std::uint32_t
>(this->raw_size()) : 0u;
352 if (!lhs._element != !rhs._element) {
356 return !lhs._element ||
357 (lhs._element.
raw() == rhs._element.
raw() && lhs._element.
offset() == rhs._element.
offset());
364 return !(lhs == rhs);
386 return *(this->
find(key));
Provides macros to control the set of symbols exported in the ABI.
#define BSONCXX_ABI_EXPORT
Exports the associated entity as part of the ABI.
Definition export.hpp:15
#define BSONCXX_ABI_EXPORT_CDECL(...)
Equivalent to BSONCXX_ABI_EXPORT with BSONCXX_ABI_CDECL.
Definition export.hpp:52
The bsoncxx v1 macro guard postlude header.
The bsoncxx v1 macro guard prelude header.
A const iterator over the elements of a view.
Definition view.hpp:274
const_iterator operator++(int)
Post-increment this iterator.
Definition view.hpp:339
friend bool operator!=(const_iterator const &lhs, const_iterator const &rhs)
Equivalent to !(lhs == rhs).
Definition view.hpp:363
const_iterator()=default
Initialize as an end iterator.
friend bool operator==(const_iterator const &lhs, const_iterator const &rhs)
Compare equal when lhs and rhs point to the same element within the same range of BSON bytes.
Definition view.hpp:351
const_iterator & operator++()
Pre-increment this iterator.
v1::element::view value_type
Provide std::iterator_traits<T>::value_type.
Definition view.hpp:287
pointer operator->() const
Access the current element.
Definition view.hpp:323
value_type reference
Provide std::iterator_traits<T>::reference.
Definition view.hpp:302
std::ptrdiff_t difference_type
Provide std::iterator_traits<T>::difference_type.
Definition view.hpp:292
value_type const * pointer
Provide std::iterator_traits<T>::pointer.
Definition view.hpp:297
reference operator*() const
Return the current element.
Definition view.hpp:314
std::input_iterator_tag iterator_category
Provide std::iterator_traits<T>::iterator_category.
Definition view.hpp:282
view()
Initialize as an empty view.
const_iterator iterator
Equivalent to const_iterator.
Definition view.hpp:61
friend bool operator!=(view lhs, view rhs)
Compare equal when the BSON bytes represented by lhs and rhs compare equal.
Definition view.hpp:209
friend bool operator==(view lhs, view rhs)
Compare equal when the BSON bytes represented by lhs and rhs compare equal.
Definition view.hpp:201
errc
Errors codes which may be returned by bsoncxx::v1::document::view.
Definition view.hpp:220
@ invalid_length
Length is invalid.
Definition view.hpp:222
@ zero
Zero.
Definition view.hpp:221
@ invalid_data
Data is invalid.
Definition view.hpp:223
v1::element::view operator[](v1::stdx::string_view key) const
Return the first element within the represented BSON document whose key compares equal to key.
Definition view.hpp:385
bool empty() const
Return true when the BSON bytes represents an empty view:
Definition view.hpp:134
std::size_t length() const
Return the length of the BSON bytes being represented.
Definition view.hpp:121
friend std::error_code make_error_code(errc v)
Support implicit conversion to std::error_code.
Definition view.hpp:238
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.
Definition view.hpp:377
std::uint8_t const * data() const
Return a pointer to the BSON bytes being represented.
Definition view.hpp:106
const_iterator cend() const
Return a const iterator to the end of the range of BSON elements within this view.
Definition view.hpp:373
const_iterator end() const
Return a const iterator to the end of the range of BSON elements within this view.
Definition view.hpp:381
std::size_t size() const
Return the length of the BSON bytes being represented.
Definition view.hpp:261
const_iterator find(v1::stdx::string_view key) const
Return a const iterator to the element within the represented BSON document whose key compares equal ...
static std::error_category const & error_category()
The error category for bsoncxx::v1::document::view::errc.
const_iterator cbegin() const
Return a const iterator to the beginning of the range of BSON elements within this view.
A non-owning, read-only BSON element.
Definition view.hpp:84
std::uint8_t const * raw() const
Return the "raw" component of the underlying BSON bytes.
std::uint32_t offset() const
Return the "offset" component of the underlying BSON bytes.
A polyfill for std::string_view.
Definition string_view.hpp:412
Declares entities representing a BSON document.
Declares entities representing a BSON element.
Declares entities whose ABI stability is guaranteed for documented symbols.
The top-level namespace within which all bsoncxx library entities are declared.
Declares bsoncxx::v1::document::view.
Provides bsoncxx::v1::element::view.
Provides std::string_view-related polyfills for library API usage.