29template <
typename TLenField, comms::ErrorStatus TStatus,
typename TBase>
32 using BaseImpl = TBase;
33 using LenField = TLenField;
35 static const std::size_t MaxAllowedLength =
36 static_cast<std::size_t
>(LenField::maxValue());
38 static_assert(!LenField::isVersionDependent(),
39 "Prefix fields must not be version dependent");
42 using ValueType =
typename BaseImpl::ValueType;
43 using ElementType =
typename BaseImpl::ElementType;
53 : BaseImpl(
std::move(val))
62 std::size_t length()
const
64 auto valLength = BaseImpl::length();
66 lenField.setValue(std::min(valLength, std::size_t(MaxAllowedLength)));
67 return lenField.length() + valLength;
70 static constexpr std::size_t minLength()
72 return LenField::minLength();
75 static constexpr std::size_t maxLength()
77 return LenField::maxLength() + BaseImpl::maxLength();
82 if ((!BaseImpl::valid()) || (!canWrite())) {
87 auto lenValue = std::min(BaseImpl::length(), std::size_t(MaxAllowedLength));
88 lenField.setValue(lenValue);
89 return lenField.valid();
92 template <
typename TIter>
97 auto es = lenField.read(iter, len);
102 auto diff =
static_cast<std::size_t
>(std::distance(fromIter, iter));
105 auto remLen =
static_cast<std::size_t
>(lenField.getValue());
110 es = BaseImpl::read(iter, remLen);
118 static constexpr bool hasReadNoStatus()
123 template <
typename TIter>
124 void readNoStatus(TIter& iter) =
delete;
126 bool canWrite()
const
128 if (!BaseImpl::canWrite()) {
132 auto len = BaseImpl::length();
133 if (MaxAllowedLength < len) {
138 lenField.setValue(len);
139 return lenField.canWrite();
142 template <
typename TIter>
149 auto lenVal = BaseImpl::length();
151 lenField.setValue(lenVal);
152 auto es = lenField.write(iter, len);
158 return BaseImpl::write(iter, lenVal);
161 static constexpr bool hasWriteNoStatus()
166 template <
typename TIter>
167 void writeNoStatus(TIter& iter)
const =
delete;
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::SequenceSerLengthFieldPrefix< TField, TReadErrorStatus > SequenceSerLengthFieldPrefix
Same as comms::option::def::SequenceSerLengthFieldPrefix.
Definition options.h:1568
Main namespace for all classes / functions of COMMS library.
ErrorStatus
Error statuses reported by the Communication module.
Definition ErrorStatus.h:19
@ Success
Used to indicate successful outcome of the operation.
@ InvalidMsgData
Used to indicate that a message has invalid data.