MongoDB C++ Driver 4.1.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
bsoncxx::vector::accessor< Format > Class Template Reference

#include <bsoncxx/v_noabi/bsoncxx/vector/accessor.hpp>

Description

template<typename Format>
class bsoncxx::vector::accessor< Format >

Accessor for the contents of a valid BSON Binary Vector.

Template Parameters
FormatOne of the bsoncxx::v_noabi::vector::formats types, optionally with a const qualifier.

This accessor operates on data formatted for the bsoncxx::v_noabi::binary_sub_type::k_vector BSON binary subtype. A mutable accessor may be constructed only using bsoncxx::v_noabi::builder::basic::sub_binary. A const accessor may be constructed by validating any bsoncxx::v_noabi::types::b_binary.

The specific iterator and element types vary for each supported format.

bsoncxx::v_noabi::vector::formats::f_float32 uses a custom element type to support packed storage with a fixed byte order.

bsoncxx::v_noabi::vector::formats::f_packed_bit uses a custom element and iterator type for single bits that unpacks them as bool. It also has custom element and iterator types for byte access, which serve to mask writes to reserved bits.

Public Types

using byte_count_type
 Type for byte counts.
 
using byte_difference_type
 Type for signed differences between byte iterators.
 
using byte_iterator
 Byte iterator type.
 
using byte_reference
 Type for referencing vector bytes in-place.
 
using byte_type
 Type for the underlying byte data.
 
using const_byte_iterator
 Iterator for const-qualified vector bytes.
 
using const_byte_reference
 Type for referencing const-qualified vector bytes in-place.
 
using const_iterator
 Iterator for const-qualified vector elements.
 
using const_reference
 Type for referencing const-qualified vector elements in-place.
 
using const_value_type
 Const qualified version of value_type.
 
using element_count_type
 Type for element counts.
 
using element_difference_type
 Type for signed differences between element iterators.
 
using format = Format
 The type from bsoncxx::v_noabi::vector::formats representing this vector's layout and element type.
 
using iterator
 Element iterator type.
 
using reference
 Type for referencing vector elements in-place.
 
using value_type
 A type suitable for holding element values.
 

Public Member Functions

 accessor (types::b_binary const &binary)
 Construct a const vector accessor by validating a bsoncxx::v_noabi::types::b_binary reference.
 
constexpr accessor< format const > as_const () const noexcept
 Obtain a const version of this vector accessor, without re-validating the vector data.
 
reference at (element_count_type index)
 Obtain a reference to a numbered element, with bounds checking.
 
const_reference at (element_count_type index) const
 Obtain a const reference to a numbered element, with bounds checking.
 
constexpr const_reference back () const noexcept
 Obtain a const reference to the last element.
 
reference back () noexcept
 Obtain a reference to the last element.
 
constexpr iterator begin () const noexcept
 Obtain a per-element iterator pointing to the beginning of the vector.
 
byte_reference byte_at (byte_count_type index)
 Obtain a reference to a numbered byte, with bounds checking.
 
const_byte_reference byte_at (byte_count_type index) const
 Obtain a const reference to a numbered byte, with bounds checking.
 
constexpr const_byte_reference byte_back () const noexcept
 Obtain a const reference to the last byte.
 
byte_reference byte_back () noexcept
 Obtain a reference to the last byte.
 
constexpr byte_iterator byte_begin () const noexcept
 Obtain a per-byte iterator pointing to the beginning of the vector.
 
constexpr const_byte_iterator byte_cbegin () const noexcept
 Obtain a const per-byte iterator pointing to the beginning of the vector.
 
constexpr const_byte_iterator byte_cend () const noexcept
 Obtain a const per-byte end iterator.
 
constexpr byte_iterator byte_end () const noexcept
 Obtain a per-byte end iterator.
 
constexpr const_byte_reference byte_front () const noexcept
 Obtain a const reference to the first byte.
 
byte_reference byte_front () noexcept
 Obtain a reference to the first byte.
 
constexpr byte_count_type byte_size () const noexcept
 Count the bytes of element data, not including any headers.
 
constexpr const_iterator cbegin () const noexcept
 Obtain a const per-element iterator pointing to the beginning of the vector.
 
constexpr const_iterator cend () const noexcept
 Obtain a const per-element end iterator.
 
constexpr bool empty () const noexcept
 Test whether the vector is empty.
 
constexpr iterator end () const noexcept
 Obtain a per-element end iterator.
 
constexpr const_reference front () const noexcept
 Obtain a const reference to the first element.
 
reference front () noexcept
 Obtain a reference to the first element.
 
constexpr const_reference operator[] (element_count_type index) const noexcept
 Obtain a const reference to a numbered element, without bounds checking.
 
reference operator[] (element_count_type index) noexcept
 Obtain a reference to a numbered element, without bounds checking.
 
constexpr element_count_type size () const noexcept
 Count the number of elements.
 

Friends

class bsoncxx::v_noabi::builder::basic::sub_binary
 

Member Typedef Documentation

◆ byte_count_type

template<typename Format>
using bsoncxx::v_noabi::vector::accessor< Format >::byte_count_type

Type for byte counts.

For example: std::uint32_t, due to BSON size limits.

◆ byte_difference_type

template<typename Format>
using bsoncxx::v_noabi::vector::accessor< Format >::byte_difference_type

Type for signed differences between byte iterators.

For example: std::ptrdiff_t

◆ byte_iterator

template<typename Format>
using bsoncxx::v_noabi::vector::accessor< Format >::byte_iterator

Byte iterator type.

For example: std::uint8_t*, std::uint8_t const*, bsoncxx::v_noabi::vector::iterators::packed_bit_byte

◆ byte_reference

template<typename Format>
using bsoncxx::v_noabi::vector::accessor< Format >::byte_reference

Type for referencing vector bytes in-place.

For example: std::uint8_t&, std::uint8_t const&, bsoncxx::v_noabi::vector::elements::packed_bit_byte

◆ byte_type

template<typename Format>
using bsoncxx::v_noabi::vector::accessor< Format >::byte_type

Type for the underlying byte data.

For example: std::uint8_t, std::uint8_t const

◆ const_byte_iterator

template<typename Format>
using bsoncxx::v_noabi::vector::accessor< Format >::const_byte_iterator

Iterator for const-qualified vector bytes.

◆ const_byte_reference

template<typename Format>
using bsoncxx::v_noabi::vector::accessor< Format >::const_byte_reference

Type for referencing const-qualified vector bytes in-place.

◆ const_iterator

template<typename Format>
using bsoncxx::v_noabi::vector::accessor< Format >::const_iterator

Iterator for const-qualified vector elements.

◆ const_reference

template<typename Format>
using bsoncxx::v_noabi::vector::accessor< Format >::const_reference

Type for referencing const-qualified vector elements in-place.

◆ const_value_type

template<typename Format>
using bsoncxx::v_noabi::vector::accessor< Format >::const_value_type

Const qualified version of value_type.

◆ element_count_type

template<typename Format>
using bsoncxx::v_noabi::vector::accessor< Format >::element_count_type

Type for element counts.

For example: std::size_t

◆ element_difference_type

template<typename Format>
using bsoncxx::v_noabi::vector::accessor< Format >::element_difference_type

Type for signed differences between element iterators.

For example: std::ptrdiff_t

◆ format

template<typename Format>
using bsoncxx::v_noabi::vector::accessor< Format >::format = Format

The type from bsoncxx::v_noabi::vector::formats representing this vector's layout and element type.

◆ iterator

template<typename Format>
using bsoncxx::v_noabi::vector::accessor< Format >::iterator

◆ reference

template<typename Format>
using bsoncxx::v_noabi::vector::accessor< Format >::reference

Type for referencing vector elements in-place.

For example: std::int8_t&, bsoncxx::v_noabi::vector::elements::float32&, bsoncxx::v_noabi::vector::elements::packed_bit_element

◆ value_type

template<typename Format>
using bsoncxx::v_noabi::vector::accessor< Format >::value_type

A type suitable for holding element values.

For example: std::int8_t, float, bool

Constructor & Destructor Documentation

◆ accessor()

template<typename Format>
bsoncxx::v_noabi::vector::accessor< Format >::accessor ( types::b_binary const & binary)
inline

Construct a const vector accessor by validating a bsoncxx::v_noabi::types::b_binary reference.

Parameters
binaryNon-owning reference to BSON binary data
Exceptions
bsoncxx::v_noabi::exceptionwith bsoncxx::v_noabi::error_code::k_invalid_vector, if validation fails.

The Binary data is validated as a vector of the templated Format. On success, an accessor is created which references the same data as the bsoncxx::v_noabi::types::b_binary pointer.

Member Function Documentation

◆ as_const()

template<typename Format>
accessor< format const > bsoncxx::v_noabi::vector::accessor< Format >::as_const ( ) const
inlineconstexprnoexcept

Obtain a const version of this vector accessor, without re-validating the vector data.

◆ at() [1/2]

template<typename Format>
reference bsoncxx::v_noabi::vector::accessor< Format >::at ( element_count_type index)
inline

Obtain a reference to a numbered element, with bounds checking.

Parameters
indexIndex in the range 0 to size()-1 inclusive.
Exceptions
bsoncxx::v_noabi::exceptionwith bsoncxx::v_noabi::error_code::k_vector_out_of_range, if the index is outside the allowed range.

◆ at() [2/2]

template<typename Format>
const_reference bsoncxx::v_noabi::vector::accessor< Format >::at ( element_count_type index) const
inline

Obtain a const reference to a numbered element, with bounds checking.

Parameters
indexIndex in the range 0 to size()-1 inclusive.
Exceptions
bsoncxx::v_noabi::exceptionwith bsoncxx::v_noabi::error_code::k_vector_out_of_range, if the index is outside the allowed range.

◆ back() [1/2]

template<typename Format>
const_reference bsoncxx::v_noabi::vector::accessor< Format >::back ( ) const
inlineconstexprnoexcept

Obtain a const reference to the last element.

Warning
Undefined behavior if the vector is empty.

◆ back() [2/2]

template<typename Format>
reference bsoncxx::v_noabi::vector::accessor< Format >::back ( )
inlinenoexcept

Obtain a reference to the last element.

Warning
Undefined behavior if the vector is empty.

◆ begin()

template<typename Format>
iterator bsoncxx::v_noabi::vector::accessor< Format >::begin ( ) const
inlineconstexprnoexcept

Obtain a per-element iterator pointing to the beginning of the vector.

◆ byte_at() [1/2]

template<typename Format>
byte_reference bsoncxx::v_noabi::vector::accessor< Format >::byte_at ( byte_count_type index)
inline

Obtain a reference to a numbered byte, with bounds checking.

Parameters
indexIndex in the range 0 to byte_size()-1 inclusive.
Exceptions
bsoncxx::v_noabi::exceptionwith bsoncxx::v_noabi::error_code::k_vector_out_of_range, if the index is outside the allowed range.

◆ byte_at() [2/2]

template<typename Format>
const_byte_reference bsoncxx::v_noabi::vector::accessor< Format >::byte_at ( byte_count_type index) const
inline

Obtain a const reference to a numbered byte, with bounds checking.

Parameters
indexIndex in the range 0 to byte_size()-1 inclusive.
Exceptions
bsoncxx::v_noabi::exceptionwith bsoncxx::v_noabi::error_code::k_vector_out_of_range, if the index is outside the allowed range.

◆ byte_back() [1/2]

template<typename Format>
const_byte_reference bsoncxx::v_noabi::vector::accessor< Format >::byte_back ( ) const
inlineconstexprnoexcept

Obtain a const reference to the last byte.

Warning
Undefined behavior if the vector is empty.

◆ byte_back() [2/2]

template<typename Format>
byte_reference bsoncxx::v_noabi::vector::accessor< Format >::byte_back ( )
inlinenoexcept

Obtain a reference to the last byte.

Warning
Undefined behavior if the vector is empty.

◆ byte_begin()

template<typename Format>
byte_iterator bsoncxx::v_noabi::vector::accessor< Format >::byte_begin ( ) const
inlineconstexprnoexcept

Obtain a per-byte iterator pointing to the beginning of the vector.

◆ byte_cbegin()

template<typename Format>
const_byte_iterator bsoncxx::v_noabi::vector::accessor< Format >::byte_cbegin ( ) const
inlineconstexprnoexcept

Obtain a const per-byte iterator pointing to the beginning of the vector.

◆ byte_cend()

template<typename Format>
const_byte_iterator bsoncxx::v_noabi::vector::accessor< Format >::byte_cend ( ) const
inlineconstexprnoexcept

Obtain a const per-byte end iterator.

◆ byte_end()

template<typename Format>
byte_iterator bsoncxx::v_noabi::vector::accessor< Format >::byte_end ( ) const
inlineconstexprnoexcept

Obtain a per-byte end iterator.

◆ byte_front() [1/2]

template<typename Format>
const_byte_reference bsoncxx::v_noabi::vector::accessor< Format >::byte_front ( ) const
inlineconstexprnoexcept

Obtain a const reference to the first byte.

Warning
Undefined behavior if the vector is empty.

◆ byte_front() [2/2]

template<typename Format>
byte_reference bsoncxx::v_noabi::vector::accessor< Format >::byte_front ( )
inlinenoexcept

Obtain a reference to the first byte.

Warning
Undefined behavior if the vector is empty.

◆ byte_size()

template<typename Format>
byte_count_type bsoncxx::v_noabi::vector::accessor< Format >::byte_size ( ) const
inlineconstexprnoexcept

Count the bytes of element data, not including any headers.

◆ cbegin()

template<typename Format>
const_iterator bsoncxx::v_noabi::vector::accessor< Format >::cbegin ( ) const
inlineconstexprnoexcept

Obtain a const per-element iterator pointing to the beginning of the vector.

◆ cend()

template<typename Format>
const_iterator bsoncxx::v_noabi::vector::accessor< Format >::cend ( ) const
inlineconstexprnoexcept

Obtain a const per-element end iterator.

◆ empty()

template<typename Format>
bool bsoncxx::v_noabi::vector::accessor< Format >::empty ( ) const
inlineconstexprnoexcept

Test whether the vector is empty.

◆ end()

template<typename Format>
iterator bsoncxx::v_noabi::vector::accessor< Format >::end ( ) const
inlineconstexprnoexcept

Obtain a per-element end iterator.

◆ front() [1/2]

template<typename Format>
const_reference bsoncxx::v_noabi::vector::accessor< Format >::front ( ) const
inlineconstexprnoexcept

Obtain a const reference to the first element.

Warning
Undefined behavior if the vector is empty.

◆ front() [2/2]

template<typename Format>
reference bsoncxx::v_noabi::vector::accessor< Format >::front ( )
inlinenoexcept

Obtain a reference to the first element.

Warning
Undefined behavior if the vector is empty.

◆ operator[]() [1/2]

template<typename Format>
const_reference bsoncxx::v_noabi::vector::accessor< Format >::operator[] ( element_count_type index) const
inlineconstexprnoexcept

Obtain a const reference to a numbered element, without bounds checking.

Parameters
indexIndex in the range 0 to size()-1 inclusive.
Warning
Undefined behavior if the index is out of bounds.

◆ operator[]() [2/2]

template<typename Format>
reference bsoncxx::v_noabi::vector::accessor< Format >::operator[] ( element_count_type index)
inlinenoexcept

Obtain a reference to a numbered element, without bounds checking.

Parameters
indexIndex in the range 0 to size()-1 inclusive.
Warning
Undefined behavior if the index is out of bounds.

◆ size()

template<typename Format>
element_count_type bsoncxx::v_noabi::vector::accessor< Format >::size ( ) const
inlineconstexprnoexcept

Count the number of elements.


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