sbepp
Loading...
Searching...
No Matches
sbepp::detail::dynamic_array_ref< Byte, Value, Length, E > Class Template Reference

Represents reference to dynamic arrays used for <data> elements. More...

#include <sbepp.hpp>

Inheritance diagram for sbepp::detail::dynamic_array_ref< Byte, Value, Length, E >:
sbepp::detail::byte_range< Byte >

Public Types

using element_type = detail::apply_cv_qualifiers_t<Byte, Value>
 final element type. value_type with the same cv-qualifiers as Byte
 
using value_type = Value
 same as Value
 
using sbe_size_type = Length
 length SBE representation of data's encoding
 
using size_type = typename sbe_size_type::value_type
 raw size type
 
using difference_type = std::ptrdiff_t
 std::ptrdiff_t
 
using reference = element_type&
 element reference type
 
using pointer = element_type*
 element pointer type
 
using iterator = pointer
 iterator type. Satisfies std::random_access_iterator
 
using reverse_iterator = std::reverse_iterator<iterator>
 reverse iterator type
 

Public Member Functions

constexpr iterator begin () const noexcept
 Returns an iterator to the beginning.
 
constexpr iterator end () const noexcept
 Returns an iterator to the end.
 
constexpr reverse_iterator rbegin () const noexcept
 Returns a reverse iterator to the beginning.
 
constexpr reverse_iterator rend () const noexcept
 Returns a reverse iterator to the end.
 
constexpr reference front () const noexcept
 Access the first element.
 
constexpr reference back () const noexcept
 Access the last element.
 
constexpr pointer data () const noexcept
 Direct access to the underlying array.
 
constexpr reference operator[] (size_type pos) const noexcept
 Access element at pos
 
constexpr sbe_size_type sbe_size () const noexcept
 Returns SBE size representation.
 
constexpr size_type size () const noexcept
 Returns raw size.
 
constexpr bool empty () const noexcept
 Checks if size() != 0
 
template<typename T = void, typename = enable_if_writable_t<Byte, T>>
constexpr void clear () const noexcept
 Sets size to 0.
 
template<typename T = void, typename = enable_if_writable_t<Byte, T>>
constexpr void resize (size_type count) const noexcept
 Sets size to count, value initializes new elements.
 
template<typename T = void, typename = enable_if_writable_t<Byte, T>>
constexpr void resize (size_type count, value_type value) const noexcept
 Sets size to count, initializes new elements with value
 
template<typename T = void, typename = enable_if_writable_t<Byte, T>>
constexpr void resize (size_type count, sbepp::default_init_t) const noexcept
 Sets size to count, default initializes new elements.
 
template<typename T = void, typename = enable_if_writable_t<Byte, T>>
constexpr void push_back (value_type value) const noexcept
 Adds new element to the end.
 
template<typename T = void, typename = enable_if_writable_t<Byte, T>>
constexpr void pop_back () const noexcept
 Removes the last element.
 
template<typename T = void, typename = enable_if_writable_t<Byte, T>>
constexpr iterator erase (iterator pos) const noexcept
 Erases element at pos
 
template<typename T = void, typename = enable_if_writable_t<Byte, T>>
constexpr iterator erase (iterator first, iterator last) const noexcept
 Erases elements in [first; last) range.
 
template<typename T = void, typename = enable_if_writable_t<Byte, T>>
constexpr iterator insert (iterator pos, const value_type value) const noexcept
 Inserts value before pos
 
template<typename T = void, typename = enable_if_writable_t<Byte, T>>
constexpr iterator insert (iterator pos, size_type count, const value_type value) const noexcept
 Inserts count copies of value before pos
 
template<typename InputIt , typename = detail::enable_if_t< !std::is_const<Byte>::value && std::is_convertible< typename std::iterator_traits<InputIt>::iterator_category, std::input_iterator_tag>::value>>
constexpr iterator insert (iterator pos, InputIt first, InputIt last) const
 Inserts elements from [first; last) range before pos
 
template<typename T = void, typename = enable_if_writable_t<Byte, T>>
constexpr iterator insert (iterator pos, std::initializer_list< value_type > ilist) const noexcept
 Inserts elements from ilist before pos
 
template<typename T = void, typename = enable_if_writable_t<Byte, T>>
constexpr void assign (size_type count, const value_type value) const noexcept
 Replaces the contents of the container with count copies of value
 
template<typename InputIt , typename = enable_if_writable_t<Byte, InputIt>>
constexpr void assign (InputIt first, InputIt last) const
 Replaces the contents of the container with the elements from [first; last) range.
 
template<typename T = void, typename = enable_if_writable_t<Byte, T>>
constexpr void assign (std::initializer_list< value_type > ilist) const noexcept
 Replaces the contents of the container with the elements from ilist
 
constexpr dynamic_array_ref< Byte, detail::remove_cv_t< Byte >, Length, E > raw () const noexcept
 Returns dynamic_array_ref<Byte, Byte, Length, E>.
 
template<typename T = void, typename = enable_if_writable_t<Byte, T>>
constexpr void assign_string (const char *str) const noexcept
 Assigns null-terminated string.
 
template<typename R , typename = enable_if_t<!std::is_const<Byte>::value && is_range<R>::value>>
constexpr void assign_range (R &&r) const
 Assigns range.
 
- Public Member Functions inherited from sbepp::detail::byte_range< Byte >
 byte_range ()=default
 Initializes to nullptr
 
constexpr byte_range (Byte *begin, Byte *end) noexcept
 Constructs from a pair of pointers.
 
constexpr byte_range (Byte *ptr, const std::size_t size) noexcept
 Constructs from pointer and size.
 
template<typename Byte2 , typename = enable_if_convertible_t<Byte2, Byte>>
constexpr byte_range (const byte_range< Byte2 > &other) noexcept
 Copy constructor. Available if Byte2* is convertible to Byte*
 

Static Public Member Functions

static constexpr size_type max_size () noexcept
 Returns max value of SBE length representation.
 

Detailed Description

template<typename Byte, typename Value, typename Length, endian E>
class sbepp::detail::dynamic_array_ref< Byte, Value, Length, E >

Represents reference to dynamic arrays used for <data> elements.

The general precondition for most functions is that current buffer should be able to hold size() number of elements

Template Parameters
Bytebyte type
Valuearray element type
LengthSBE length type
Eschema endianness

Member Function Documentation

◆ assign_range()

template<typename Byte , typename Value , typename Length , endian E>
template<typename R , typename = enable_if_t<!std::is_const<Byte>::value && is_range<R>::value>>
constexpr void sbepp::detail::dynamic_array_ref< Byte, Value, Length, E >::assign_range ( R && r) const
inlineconstexpr

Assigns range.

Parameters
rrange to assign. In C++20, required to satisfy std::ranges::range, or std::begin(r)/std::end(r) as valid expressions for older C++ versions

◆ assign_string()

template<typename Byte , typename Value , typename Length , endian E>
template<typename T = void, typename = enable_if_writable_t<Byte, T>>
constexpr void sbepp::detail::dynamic_array_ref< Byte, Value, Length, E >::assign_string ( const char * str) const
inlineconstexprnoexcept

Assigns null-terminated string.

Parameters
strnull-terminated string
Precondition
str != nullptr

◆ back()

template<typename Byte , typename Value , typename Length , endian E>
constexpr reference sbepp::detail::dynamic_array_ref< Byte, Value, Length, E >::back ( ) const
inlineconstexprnoexcept

Access the last element.

Precondition
!empty()

◆ data()

template<typename Byte , typename Value , typename Length , endian E>
constexpr pointer sbepp::detail::dynamic_array_ref< Byte, Value, Length, E >::data ( ) const
inlineconstexprnoexcept

Direct access to the underlying array.

The pointer is such that range [data(), data() + size()) is always a valid range, even if the container is empty (data() is not dereferenceable in that case).

◆ front()

template<typename Byte , typename Value , typename Length , endian E>
constexpr reference sbepp::detail::dynamic_array_ref< Byte, Value, Length, E >::front ( ) const
inlineconstexprnoexcept

Access the first element.

Precondition
!empty()

◆ operator[]()

template<typename Byte , typename Value , typename Length , endian E>
constexpr reference sbepp::detail::dynamic_array_ref< Byte, Value, Length, E >::operator[] ( size_type pos) const
inlineconstexprnoexcept

Access element at pos

Precondition
pos < size()

◆ raw()

template<typename Byte , typename Value , typename Length , endian E>
constexpr dynamic_array_ref< Byte, detail::remove_cv_t< Byte >, Length, E > sbepp::detail::dynamic_array_ref< Byte, Value, Length, E >::raw ( ) const
inlineconstexprnoexcept

Returns dynamic_array_ref<Byte, Byte, Length, E>.

Useful in constexpr context to modify an array which has different Byte and Value types. For example see static_array_ref::raw()


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