CppSerdes  1.0
A serialization/deserialization library designed with embedded systems in mind
serdes::delimited_array< T > Struct Template Reference

a container for dynamically sized arrays with their ending marked by a reserved delimiter value More...

#include <serdes_format_modifiers.h>

Public Types

using elem_type = typename detail::has_data_and_size< T >::elem_type
 

Public Member Functions

template<size_t max_elements>
constexpr delimited_array (T(&v)[max_elements], const T &d) noexcept
 Construct a new delimited array object using a referenced array and referenced delimiter. More...
 
template<size_t max_elements>
constexpr delimited_array (T(&v)[max_elements], const T &&d) noexcept
 Construct a new delimited array object using a referenced array and rvalue delimiter. More...
 
constexpr delimited_array (T *v, const T &d, size_t max_elements) noexcept
 Construct a new delimited array object using a pointer to an array, a referenced delimiter, and a max size. More...
 
constexpr delimited_array (T *v, const T &&d, size_t max_elements) noexcept
 Construct a new delimited array object using a pointer to an array, a rvalue delimiter, and a max size. More...
 
 delimited_array (T &v, const elem_type &d) noexcept
 Construct a new delimited array object from a data container with 'T* data()' and 'size_t size()' methods (such as std::array, or std::list) More...
 
 delimited_array (T &v, const elem_type &&d) noexcept
 Construct a new delimited array object from a data container with 'T* data()' and 'size_t size()' methods (such as std::array, or std::list) More...
 

Public Attributes

elem_typevalue
 pointer to the head of the array
 
const elem_typedelimiter
 reference to a reserved delimiter value marking the end of the array
 
const size_t max_size
 maximum size of the array (used for bounds checking)
 

Detailed Description

template<typename T>
struct serdes::delimited_array< T >

a container for dynamically sized arrays with their ending marked by a reserved delimiter value

Template Parameters
Tthe type of an array element
Examples
07_delimited_arrays.cpp, and 14_custom_types.cpp.

Member Typedef Documentation

◆ elem_type

template<typename T >
using serdes::delimited_array< T >::elem_type = typename detail::has_data_and_size<T>::elem_type

if the array is from a container with a "P* T.data()" method, elem_type will be P otherwise, elem_type will be T, allowing support for c-arrays (no data method) and std::array, std::list, std::vector, etc. (any c-array abstraction layer with a data() method)

Constructor & Destructor Documentation

◆ delimited_array() [1/6]

template<typename T >
template<size_t max_elements>
constexpr serdes::delimited_array< T >::delimited_array ( T(&)  v[max_elements],
const T &  d 
)
inlineconstexprnoexcept

Construct a new delimited array object using a referenced array and referenced delimiter.

Template Parameters
max_elementsmaximum size of the array
Parameters
vreference to the underlying array
dthe delimiter value

◆ delimited_array() [2/6]

template<typename T >
template<size_t max_elements>
constexpr serdes::delimited_array< T >::delimited_array ( T(&)  v[max_elements],
const T &&  d 
)
inlineconstexprnoexcept

Construct a new delimited array object using a referenced array and rvalue delimiter.

Template Parameters
max_elementsmaximum size of the array
Parameters
vreference to the underlying array
dthe delimiter value

◆ delimited_array() [3/6]

template<typename T >
constexpr serdes::delimited_array< T >::delimited_array ( T *  v,
const T &  d,
size_t  max_elements 
)
inlineconstexprnoexcept

Construct a new delimited array object using a pointer to an array, a referenced delimiter, and a max size.

Parameters
vpointer to the underlying array
dthe delimiter value
max_elementsmaximum size of the array

◆ delimited_array() [4/6]

template<typename T >
constexpr serdes::delimited_array< T >::delimited_array ( T *  v,
const T &&  d,
size_t  max_elements 
)
inlineconstexprnoexcept

Construct a new delimited array object using a pointer to an array, a rvalue delimiter, and a max size.

Parameters
vpointer to the underlying array
dthe delimiter value
max_elementsmaximum size of the array

◆ delimited_array() [5/6]

template<typename T >
serdes::delimited_array< T >::delimited_array ( T &  v,
const elem_type d 
)
inlinenoexcept

Construct a new delimited array object from a data container with 'T* data()' and 'size_t size()' methods (such as std::array, or std::list)

Parameters
vreference to the data container whose underlying data should be used as the array
da reference to the delimiter value

◆ delimited_array() [6/6]

template<typename T >
serdes::delimited_array< T >::delimited_array ( T &  v,
const elem_type &&  d 
)
inlinenoexcept

Construct a new delimited array object from a data container with 'T* data()' and 'size_t size()' methods (such as std::array, or std::list)

Parameters
vreference to the data container whose underlying data should be used as the array
da rvalue reference to the delimiter value

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