COMMS
Template library intended to help with implementation of communication protocols.
|
Namespace for various utility classes and/or functions used by COMMS library. More...
Namespace for various utility classes and/or functions used by COMMS library.
Namespaces | |
namespace | alloc |
Namespace for various allocation classes. | |
namespace | detect |
Namespace for various compile-time detection operations of whether a type has certain member types and/or member functions. | |
namespace | traits |
Namespace for various utilities related trait classes. | |
Classes | |
class | ArrayView |
Describes an object that can refer to a constant contiguous sequence of other objects. More... | |
struct | Conditional |
Replacement to std::conditional. More... | |
struct | IsInTuple |
Check whether TType type is included in the tuple TTuple. More... | |
struct | IsTuple |
Check whether provided type is a variant of std::tuple. More... | |
class | ScopeGuard |
Implements Scope Guard Idiom. More... | |
class | StaticString |
Replacement to std::string when no dynamic memory allocation is allowed. More... | |
class | StaticVector |
Replacement to std::vector when no dynamic memory allocation is allowed. More... | |
class | StringView |
Describes an object that can refer to a constant contiguous sequence of char-like objects with the first element of the sequence at position zero. More... | |
struct | TupleAsAlignedUnion |
Calculated "aligned union" storage type for all the types in provided tuple. More... | |
struct | TupleCat |
Provides the type of std::tuple_cat operation. More... | |
Typedefs | |
template<bool TCond, typename TTrue , typename TFalse > | |
using | ConditionalT = typename Conditional< TCond >::template Type< TTrue, TFalse > |
Replacement to std::conditional. | |
template<typename TTuple > | |
using | TupleAsAlignedUnionT = typename TupleAsAlignedUnion< TTuple >::Type |
Alias to TupleAsAlignedUnion::Type. | |
Functions | |
template<typename T , typename TIter > | |
void | assign (T &obj, TIter from, TIter to) |
Assigns a new value to provided object. | |
template<typename TType > | |
constexpr bool | isTuple () |
Check whether provided type is a variant of std::tuple. | |
template<typename T , std::size_t TSize, typename TIter > | |
T | readBig (TIter &iter) |
Read part of integral value from the input area using big endian notation. | |
template<typename T , typename TIter > | |
T | readBig (TIter &iter) |
Read integral value from the input area using big endian notation. | |
template<typename T , typename TIter > | |
T | readBig (TIter &iter, std::size_t size) |
Read integral value from the input area using big endian notation. | |
template<typename T , typename TIter > | |
T | readData (TIter &iter, const traits::endian::Big &endian) |
Same as readBig<T, TIter>() | |
template<typename T , std::size_t TSize, typename TIter > | |
T | readData (TIter &iter, const traits::endian::Big &endian) |
Same as readBig<T, TSize, TIter>() | |
template<typename T , typename TIter > | |
T | readData (TIter &iter, const traits::endian::Little &endian) |
Same as readLittle<T, TIter>() | |
template<typename T , std::size_t TSize, typename TIter > | |
T | readData (TIter &iter, const traits::endian::Little &endian) |
Same as readData<T, TSize, TIter>() | |
template<typename T , typename TIter > | |
T | readData (TIter &iter, std::size_t size, const traits::endian::Big &endian) |
Same as readBig<T, TIter>() | |
template<typename T , typename TIter > | |
T | readData (TIter &iter, std::size_t size, const traits::endian::Little &endian) |
Same as readBig<T, TIter>() | |
template<typename T , std::size_t TSize, typename TIter > | |
T | readLittle (TIter &iter) |
Read part of integral value from the input area using little endian notation. | |
template<typename T , typename TIter > | |
T | readLittle (TIter &iter) |
Read integral value from the input area using little endian notation. | |
template<typename T , typename TIter > | |
T | readLittle (TIter &iter, std::size_t size) |
Read integral value from the input area using little endian notation. | |
template<typename TTuple , typename TValue , typename TFunc > | |
constexpr TValue | tupleAccumulate (TTuple &&tuple, const TValue &value, TFunc &&func) |
Performs "accumulate" algorithm on every element of the tuple. | |
template<std::size_t TFrom, std::size_t TUntil, typename TTuple , typename TValue , typename TFunc > | |
constexpr TValue | tupleAccumulateFromUntil (TTuple &&tuple, const TValue &value, TFunc &&func) |
Performs "accumulate" algorithm on every element of the tuple. | |
template<typename TTuple , typename TFunc > | |
void | tupleForEach (TTuple &&tuple, TFunc &&func) |
Invoke provided functor for every element in the tuple. | |
template<std::size_t TIdx, typename TTuple , typename TFunc > | |
void | tupleForEachFrom (TTuple &&tuple, TFunc &&func) |
Invoke provided functor for every element in the tuple starting from element with specified index. | |
template<std::size_t TFromIdx, std::size_t TUntilIdx, typename TTuple , typename TFunc > | |
void | tupleForEachFromUntil (TTuple &&tuple, TFunc &&func) |
Invoke provided functor for every element in the tuple which indices are in range [TFromIdx, TUntilIdx). | |
template<typename TTuple , typename TFunc > | |
void | tupleForEachType (TFunc &&func) |
Invoke provided functor for every type in the tuple. | |
template<std::size_t TIdx, typename TTuple , typename TFunc > | |
void | tupleForEachUntil (TTuple &&tuple, TFunc &&func) |
Invoke provided functor for every element in the tuple until element with specified index is reached. | |
template<typename TTuple , typename TFunc > | |
void | tupleForEachWithIdx (TTuple &&tuple, TFunc &&func) |
Invoke provided functor for every element in the tuple while providing information about element index in the tuple. | |
template<typename TTuple , typename TFunc > | |
void | tupleForEachWithTemplateParamIdx (TTuple &&tuple, TFunc &&func) |
Invoke provided functor for every element in the tuple while providing information about element index in the tuple as a template parameter. | |
template<typename TTuple , typename TFunc > | |
void | tupleForSelectedType (std::size_t idx, TFunc &&func) |
Invoke provided functor for a selected type when element index is known only at run time. | |
template<typename TTail , typename TTuple > | |
constexpr bool | tupleIsTailOf () |
Compile time check of whether one tuple is a "tail" of another. | |
template<typename TTuple , typename TValue , typename TFunc > | |
constexpr TValue | tupleTypeAccumulate (const TValue &value, TFunc &&func) |
Performs "accumulate" algorithm on every type of the tuple. | |
template<std::size_t TFrom, std::size_t TUntil, typename TTuple , typename TValue , typename TFunc > | |
constexpr TValue | tupleTypeAccumulateFromUntil (const TValue &value, TFunc &&func) |
Performs "accumulate" algorithm on specified types inside the tuple. | |
template<typename TTuple , typename TFunc > | |
constexpr bool | tupleTypeIsAnyOf (TFunc &&func) |
Compile time check of whether any type within a tuple has a certain condition. | |
template<typename T , typename TIter > | |
void | writeBig (T value, std::size_t size, TIter &iter) |
Write part of integral value into the output area using big endian notation. | |
template<std::size_t TSize, typename T , typename TIter > | |
void | writeBig (T value, TIter &iter) |
Write part of integral value into the output area using big endian notation. | |
template<typename T , typename TIter > | |
void | writeBig (T value, TIter &iter) |
Write integral value into the output area using big endian notation. | |
template<typename T , typename TIter > | |
void | writeData (T value, std::size_t size, TIter &iter, const traits::endian::Big &endian) |
Same as writeBig<T, TIter>() | |
template<typename T , typename TIter > | |
void | writeData (T value, std::size_t size, TIter &iter, const traits::endian::Little &endian) |
Same as writeLittle<T, TIter>() | |
template<typename T , typename TIter > | |
void | writeData (T value, TIter &iter, const traits::endian::Big &endian) |
Same as writeBig<T, TIter>() | |
template<std::size_t TSize, typename T , typename TIter > | |
void | writeData (T value, TIter &iter, const traits::endian::Big &endian) |
Same as writeBig<TSize, T, TIter>() | |
template<typename T , typename TIter > | |
void | writeData (T value, TIter &iter, const traits::endian::Little &endian) |
Same as writeLittle<T, TIter>() | |
template<std::size_t TSize, typename T , typename TIter > | |
void | writeData (T value, TIter &iter, const traits::endian::Little &endian) |
Same as writeLittle<TSize, T, TIter>() | |
template<typename T , typename TIter > | |
void | writeLittle (T value, std::size_t size, TIter &iter) |
Write part of integral value into the output area using little endian notation. | |
template<std::size_t TSize, typename T , typename TIter > | |
void | writeLittle (T value, TIter &iter) |
Write part of integral value into the output area using little endian notation. | |
template<typename T , typename TIter > | |
void | writeLittle (T value, TIter &iter) |
Write integral value into the output area using big endian notation. | |
void comms::util::assign | ( | T & | obj, |
TIter | from, | ||
TIter | to | ||
) |
Assigns a new value to provided object.
The function detects at compile-time presence of assign() member function and uses it. In case the assign() member function does not exist (for types like std::string_view or std::span) the function checks for presence of a constructor that can receive a pointer to the first element + number of elements (size) and uses it instead to create temporary object and then uses move / copy constructor to assign the value.
|
constexpr |
Check whether provided type is a variant of std::tuple.
TType | Type to check. |
T comms::util::readBig | ( | TIter & | iter | ) |
Read part of integral value from the input area using big endian notation.
T | Type to read. |
TSize | Number of bytes to read. |
[in,out] | iter | Input iterator. |
T comms::util::readBig | ( | TIter & | iter | ) |
Read integral value from the input area using big endian notation.
T | Type to read. |
[in,out] | iter | Input iterator. |
T comms::util::readBig | ( | TIter & | iter, |
std::size_t | size | ||
) |
Read integral value from the input area using big endian notation.
T | Type to read. |
[in,out] | iter | Input iterator. |
[in] | size | length to read |
T comms::util::readLittle | ( | TIter & | iter | ) |
Read part of integral value from the input area using little endian notation.
T | Type to read. |
TSize | Number of bytes to read. |
[in,out] | iter | Input iterator. |
T comms::util::readLittle | ( | TIter & | iter | ) |
Read integral value from the input area using little endian notation.
T | Type to read. |
[in,out] | iter | Input iterator. |
T comms::util::readLittle | ( | TIter & | iter, |
std::size_t | size | ||
) |
Read integral value from the input area using little endian notation.
T | Type to read. |
[in,out] | iter | Input iterator. |
[in] | size | length to read |
|
constexpr |
Performs "accumulate" algorithm on every element of the tuple.
The algorithm invokes operator() of the provided functor object with initial value and first element of the tuple, then provides the returned value as a parameter to the next invocation of operator() and second element in the tuple, and so on until all elements in the tuple is handled.
[in] | tuple | Reference (l- or r-value) to tuple object. |
[in] | value | Initial value. |
[in] | func | Functor object. The class must provide operator() with the following signature: struct MyFunc
{
template <typename TValue, typename TTupleElem>
TValue operator()(const TValue& value, TTupleElem&& elem) {...}
};
|
|
constexpr |
Performs "accumulate" algorithm on every element of the tuple.
Similar to tupleAccumulate(), but allows specifying range of indices of tuple elements.
TFrom | Index of the first tuple element to evaluate |
TUntil | Index of the one past the last tuple element to evaluate. |
[in] | tuple | Reference (l- or r-value) to tuple object. |
[in] | value | Initial value. |
[in] | func | Functor object. The class must provide operator() with the following signature: struct MyFunc
{
template <typename TValue, typename TTupleElem>
TValue operator()(const TValue& value, TTupleElem&& elem) {...}
};
|
void comms::util::tupleForEach | ( | TTuple && | tuple, |
TFunc && | func | ||
) |
Invoke provided functor for every element in the tuple.
The functor object class must define operator() with following signature:
[in] | tuple | Reference (l- or r-value) to tuple object. |
[in] | func | Functor object. |
void comms::util::tupleForEachFrom | ( | TTuple && | tuple, |
TFunc && | func | ||
) |
Invoke provided functor for every element in the tuple starting from element with specified index.
Very similar to tupleForEach() function, but also receives index of the first element as a template parameter.
TIdx | Index of the first element to invoke functor on. |
[in] | tuple | Reference (l- or r-value) to tuple object. |
[in] | func | Functor object. |
void comms::util::tupleForEachFromUntil | ( | TTuple && | tuple, |
TFunc && | func | ||
) |
Invoke provided functor for every element in the tuple which indices are in range [TFromIdx, TUntilIdx).
Very similar to tupleForEach() function, but also receives indices of the first and last elements as a template parameters.
TFromIdx | Index of the first element to invoke functor on. |
TUntilIdx | Index of the last (not included) element. |
[in] | tuple | Reference (l- or r-value) to tuple object. |
[in] | func | Functor object. |
void comms::util::tupleForEachType | ( | TFunc && | func | ) |
Invoke provided functor for every type in the tuple.
The functor object class must define operator() with following signature:
[in] | func | Functor object. |
void comms::util::tupleForEachUntil | ( | TTuple && | tuple, |
TFunc && | func | ||
) |
Invoke provided functor for every element in the tuple until element with specified index is reached.
Very similar to tupleForEach() function, but also receives index of the last element as a template parameter. The provided functor is NOT invoked for the element with index TIdx.
TIdx | Index of the last (not included) element. |
[in] | tuple | Reference (l- or r-value) to tuple object. |
[in] | func | Functor object. |
void comms::util::tupleForEachWithIdx | ( | TTuple && | tuple, |
TFunc && | func | ||
) |
Invoke provided functor for every element in the tuple while providing information about element index in the tuple.
Very similar to tupleForEach(), but the operator() in the functor receives additional information about index of the element. The functor object class must define operator() with following signature:
[in] | tuple | Reference (l- or r-value) to tuple object. |
[in] | func | Functor object. |
void comms::util::tupleForEachWithTemplateParamIdx | ( | TTuple && | tuple, |
TFunc && | func | ||
) |
Invoke provided functor for every element in the tuple while providing information about element index in the tuple as a template parameter.
Very similar to tupleForEachWithIdx(), but the operator() in the functor receives additional information about index of the element as a template parameter instead of as argument to the function. The functor object class must define operator() with following signature:
[in] | tuple | Reference (l- or r-value) to tuple object. |
[in] | func | Functor object. |
void comms::util::tupleForSelectedType | ( | std::size_t | idx, |
TFunc && | func | ||
) |
Invoke provided functor for a selected type when element index is known only at run time.
The functor object class must define operator() with following signature:
[in] | idx | Index of the type in the tuple |
[in] | func | Functor object. |
|
constexpr |
Compile time check of whether one tuple is a "tail" of another.
TTail | Tail tuple |
TTuple | Containing tuple |
|
constexpr |
Performs "accumulate" algorithm on every type of the tuple.
Very similar to tupleAccumulate(), but without actual tuple object, provides only type information to operator() of the functor.
[in] | value | Initial value. |
[in] | func | Functor object. The class must provide operator() with the following signature: struct MyFunc
{
template <typename TTupleElem, typename TValue>
TValue operator()(const TValue& value) {...}
};
|
|
constexpr |
Performs "accumulate" algorithm on specified types inside the tuple.
Very similar to tupleTypeAccumulate(), but allows specifying range of indices of tuple elements.
TFrom | Index of the first tuple type to evaluate |
TUntil | Index of the one past the last tuple type to evaluate. |
[in] | value | Initial value. |
[in] | func | Functor object. The class must provide operator() with the following signature: struct MyFunc
{
template <typename TTupleElem, typename TValue>
TValue operator()(const TValue& value) {...}
};
|
|
constexpr |
Compile time check of whether any type within a tuple has a certain condition.
The functor object class must define operator() with following signature:
TTuple | Tuple |
TFunc | Functor object type |
void comms::util::writeBig | ( | T | value, |
std::size_t | size, | ||
TIter & | iter | ||
) |
Write part of integral value into the output area using big endian notation.
[in] | value | Integral type value to be written. |
[in] | size | Number of bytes to write. |
[in,out] | iter | Output iterator. |
void comms::util::writeBig | ( | T | value, |
TIter & | iter | ||
) |
Write part of integral value into the output area using big endian notation.
TSize | Number of bytes to write. |
[in] | value | Integral type value to be written. |
[in,out] | iter | Output iterator. |
void comms::util::writeBig | ( | T | value, |
TIter & | iter | ||
) |
Write integral value into the output area using big endian notation.
[in] | value | Integral type value to be written. |
[in,out] | iter | Output iterator. |
void comms::util::writeLittle | ( | T | value, |
std::size_t | size, | ||
TIter & | iter | ||
) |
Write part of integral value into the output area using little endian notation.
[in] | value | Integral type value to be written. |
[in] | size | Number of bytes to write. |
[in,out] | iter | Output iterator. |
void comms::util::writeLittle | ( | T | value, |
TIter & | iter | ||
) |
Write part of integral value into the output area using little endian notation.
TSize | Number of bytes to write. |
[in] | value | Integral type value to be written. |
[in,out] | iter | Output iterator. |
void comms::util::writeLittle | ( | T | value, |
TIter & | iter | ||
) |
Write integral value into the output area using big endian notation.
[in] | value | Integral type value to be written. |
[in,out] | iter | Output iterator. |