 |
CppSerdes
1.0
A serialization/deserialization library designed with embedded systems in mind
|
Go to the documentation of this file. 1 #ifndef _SERDES_FORMAT_MODIFIERS_H_
8 #define _SERDES_FORMAT_MODIFIERS_H_
17 template <
typename ST>
25 constexpr
align(
const ST &bits) noexcept :
value{bits} {}
34 template <
typename ST>
42 constexpr
pad(
const ST &bits) noexcept :
value{bits} {}
46 constexpr
pad(ST &&bits) noexcept :
value{bits} {}
53 template <
typename T,
typename ST>
86 template <
typename T,
typename ST>
92 using elem_type =
typename detail::has_data_and_size<T>::elem_type;
112 template <
size_t max_elements>
119 template <
size_t max_elements>
159 template <
typename T>
165 using elem_type =
typename detail::has_data_and_size<T>::elem_type;
180 template <
size_t max_elements>
187 template <
size_t max_elements>
219 template <
typename FieldType,
typename FuncType>
223 template <
typename T,
typename ST>
224 struct default_bitsize<
bitpack<T, ST>>
226 static constexpr
size_t value = 0u;
228 template <
typename T,
typename T2>
229 struct default_bitsize<
array<T, T2>>
231 static constexpr
size_t value =
sizeof(T) * 8u;
233 template <
typename T>
234 struct default_bitsize<delimited_array<T>>
236 static constexpr
size_t value =
sizeof(T) * 8u;
238 template <
typename ST>
239 struct default_bitsize<align<ST>>
241 static constexpr
size_t value = 0u;
243 template <
typename ST>
244 struct default_bitsize<pad<ST>>
246 static constexpr
size_t value = 0u;
248 template <
typename T>
249 struct is_formatter : std::false_type
253 struct is_formatter<formatter> : std::true_type
256 template <
typename T>
257 struct is_validator : std::false_type
260 template <
typename FieldType,
typename FuncType>
261 struct is_validator<validator<FieldType, FuncType>> : std::true_type
264 template <
typename T>
265 struct is_format_modifier
267 static constexpr
bool value = has_format_method<T>::value;
270 struct is_format_modifier<formatter> : std::true_type
273 template <
typename ST>
274 struct is_format_modifier<pad<ST>> : std::true_type
277 template <
typename ST>
278 struct is_format_modifier<align<ST>> : std::true_type
281 template <
typename T,
typename ST>
282 struct is_format_modifier<bitpack<T, ST>> : std::true_type
285 template <
typename T1,
typename T2>
286 struct is_format_modifier<array<T1, T2>> : std::true_type
289 template <
typename T>
290 struct is_format_modifier<delimited_array<T>> : std::true_type
296 #endif // _SERDES_FORMAT_MODIFIERS_H_
constexpr align(const ST &bits) noexcept
Construct a new align object, binding to a reference of the number of bits to align by.
Definition: serdes_format_modifiers.h:25
constexpr array(T(&v)[max_elements], const ST &&s) noexcept
Construct a new array object from an existing array and a rvalue size.
Definition: serdes_format_modifiers.h:120
constexpr array(T *v, ST &s, const ST max_elements) noexcept
Construct a new array object from a pointer to the head of the array, a referenced dynamic size,...
Definition: serdes_format_modifiers.h:127
constexpr delimited_array(T(&v)[max_elements], const T &d) noexcept
Construct a new delimited array object using a referenced array and referenced delimiter.
Definition: serdes_format_modifiers.h:181
const elem_type & delimiter
reference to a reserved delimiter value marking the end of the array
Definition: serdes_format_modifiers.h:171
const ST & bits
a reference to the number of bits to use when storing/loading the referenced value
Definition: serdes_format_modifiers.h:60
array(T &v, const ST &s) noexcept
Construct a new "dynamically" sized array object from a data container with 'T* data()' and 'size_t s...
Definition: serdes_format_modifiers.h:141
array(T &v) noexcept
Construct a new "fixed" sized array object from a data container with 'T* data()' and 'size_t size()'...
Definition: serdes_format_modifiers.h:154
bitpack a value into an exact number of specified bits. If applied to an array it will be applied to ...
Definition: serdes_format_modifiers.h:54
Defines common bitcpy details as well as a info::version number, and bit_length function.
constexpr bitpack(T &v, const ST &&b) noexcept
Construct a new bitpack object from a reference value, and rvalue bit length.
Definition: serdes_format_modifiers.h:70
typename detail::has_data_and_size< T >::elem_type elem_type
Definition: serdes_format_modifiers.h:92
constexpr delimited_array(T(&v)[max_elements], const T &&d) noexcept
Construct a new delimited array object using a referenced array and rvalue delimiter.
Definition: serdes_format_modifiers.h:188
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,...
Definition: serdes_format_modifiers.h:200
const ST & size
a reference to a value that contains the dynamic size of the array for fixed sized arrays (where the ...
Definition: serdes_format_modifiers.h:103
elem_type * value
pointer to the head of the array
Definition: serdes_format_modifiers.h:168
T & value
a reference to the bitpacked value
Definition: serdes_format_modifiers.h:57
constexpr array(T *v, const ST &&s, const ST max_elements) noexcept
Construct a new array object from a pointer to the head of the array, a rvalue dynamic size,...
Definition: serdes_format_modifiers.h:134
a container for fixed or dynamically sized arrays, with an upper bounds limit for safety
Definition: serdes_format_modifiers.h:87
constexpr array(T(&v)[max_elements], const ST &s) noexcept
Construct a new array object from an existing array and a referenced size.
Definition: serdes_format_modifiers.h:113
a container for dynamically sized arrays with their ending marked by a reserved delimiter value
Definition: serdes_format_modifiers.h:160
specifies a number of bits to be used to align the bit offset as a multiple of
Definition: serdes_format_modifiers.h:18
typename detail::has_data_and_size< T >::elem_type elem_type
Definition: serdes_format_modifiers.h:165
constexpr bitpack(T &v, const ST &b) noexcept
Construct a new bitpack object from a reference value, and reference bit length.
Definition: serdes_format_modifiers.h:75
elem_type * value
a pointer to the array head
Definition: serdes_format_modifiers.h:95
const size_t max_size
maximum size of the array (used for bounds checking)
Definition: serdes_format_modifiers.h:174
a field and its attached functional validation callable object, note that validation will occur after...
Definition: serdes_format_modifiers.h:220
const ST & value
bit pad reference value
Definition: serdes_format_modifiers.h:38
constexpr align(ST &&bits) noexcept
Construct a new align object, binding to a rvalue of the number of bits to align by.
Definition: serdes_format_modifiers.h:29
constexpr bitpack(T &&v, const ST &b) noexcept
Construct a new bitpack object from a rvalue value, and reference bit length.
Definition: serdes_format_modifiers.h:80
constexpr pad(const ST &bits) noexcept
Construct a new pad object, binding to a reference of the number of bits to pad by.
Definition: serdes_format_modifiers.h:42
const size_t max_size
maximum size of the array (used for bounds checking)
Definition: serdes_format_modifiers.h:106
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()' met...
Definition: serdes_format_modifiers.h:214
constexpr bitpack(T &&v, const ST &&b) noexcept
Construct a new bitpack object from a rvalue value, and rvalue bit length.
Definition: serdes_format_modifiers.h:65
array(T &v, const ST &&s) noexcept
Construct a new "fixed" sized array object from a data container with 'T* data()' and 'size_t size()'...
Definition: serdes_format_modifiers.h:148
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,...
Definition: serdes_format_modifiers.h:194
CppSerdes library namespace.
Definition: bitcpy_common.h:68
const ST & value
bit alignment reference value
Definition: serdes_format_modifiers.h:21
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()' met...
Definition: serdes_format_modifiers.h:207
specifies a number of bits to be used to pad (add to) the current bit offset
Definition: serdes_format_modifiers.h:35
constexpr pad(ST &&bits) noexcept
Construct a new pad object, binding to a rvalue of the number of bits to pad by.
Definition: serdes_format_modifiers.h:46
const ST rvalue_size
holds onto an rvalue size if provide (so that const ST &size can have a local reference)
Definition: serdes_format_modifiers.h:98