13#include "comms/details/tag.h"
24template <
typename TTermField,
typename TBase>
27 using BaseImpl = TBase;
28 using TermField = TTermField;
30 static_assert(!TermField::isVersionDependent(),
31 "Suffix fields must not be version dependent");
34 using ValueType =
typename BaseImpl::ValueType;
35 using ElementType =
typename BaseImpl::ElementType;
45 : BaseImpl(
std::move(val))
54 constexpr std::size_t length()
const
56 return m_termField.length() + BaseImpl::length();
59 static constexpr std::size_t minLength()
61 return TermField::minLength() + BaseImpl::minLength();
64 static constexpr std::size_t maxLength()
66 return TermField::maxLength() + BaseImpl::maxLength();
69 template <
typename TIter>
72 using IterType =
typename std::decay<
decltype(iter)>::type;
73 using IterTag =
typename std::iterator_traits<IterType>::iterator_category;
74 static_assert(std::is_base_of<std::random_access_iterator_tag, IterTag>::value,
75 "Only random access iterator for reading is supported with comms::option::def::SequenceTerminationFieldSuffix option");
78 typename comms::util::LazyShallowConditional<
79 std::is_integral<ElementType>::value && (
sizeof(ElementType) ==
sizeof(std::uint8_t))
85 return readInternal(iter, len, ReadElemTag());
88 static constexpr bool hasReadNoStatus()
93 template <
typename TIter>
94 void readNoStatus(TIter& iter) =
delete;
96 template <
typename TIter>
99 auto trailLen = m_termField.length();
100 auto es = BaseImpl::write(iter, len - trailLen);
105 return m_termField.write(iter, trailLen);
108 template <
typename TIter>
109 void writeNoStatus(TIter& iter)
const
111 BaseImpl::writeNoStatus(iter);
112 m_termField.writeNoStatus(iter);
115 TermField& terminationFieldSuffix()
120 const TermField& terminationFieldSuffix()
const
126 template <
typename... TParams>
127 using RawDataTag = comms::details::tag::Tag1<>;
129 template <
typename... TParams>
130 using FieldTag = comms::details::tag::Tag2<>;
132 template <
typename TIter,
typename... TParams>
138 auto es = m_termField.read(iterCpy, len);
140 std::advance(iter, std::distance(iter, iterCpy));
144 auto& elem = BaseImpl::createBack();
145 es = BaseImpl::readElement(elem, iter, len);
147 BaseImpl::value().pop_back();
155 template <
typename TIter,
typename... TParams>
158 std::size_t consumed = 0U;
159 std::size_t termFieldLen = 0U;
160 while (consumed < len) {
161 auto iterCpy = iter + consumed;
162 auto es = m_termField.read(iterCpy, len - consumed);
164 termFieldLen =
static_cast<std::size_t
>(std::distance(iter + consumed, iterCpy));
171 if (len <= consumed) {
176 auto es = BaseImpl::read(iterCpy, consumed);
181 auto fullConsumeLen = consumed + termFieldLen;
183 std::advance(iter, fullConsumeLen);
187 TermField m_termField;
This file contains classes required for generic custom assertion functionality.
#define COMMS_ASSERT(expr)
Generic assert macro.
Definition Assert.h:170
This file contain definition of error statuses used by comms module.
comms::option::def::SequenceTerminationFieldSuffix< TField > SequenceTerminationFieldSuffix
Same as comms::option::def::SequenceTerminationFieldSuffix.
Definition options.h:1527
Main namespace for all classes / functions of COMMS library.
ErrorStatus
Error statuses reported by the Communication module.
Definition ErrorStatus.h:17
@ Success
Used to indicate successful outcome of the operation.
Replacement to some types from standard type_traits.