22template <
typename TLenField, comms::ErrorStatus TStatus,
typename TBase>
25 using BaseImpl = TBase;
26 using LenField = TLenField;
28 static const std::size_t MaxAllowedLength =
29 static_cast<std::size_t
>(LenField::maxValue());
32 static_assert(!LenField::isVersionDependent(),
33 "Prefix fields must not be version dependent");
36 using ValueType =
typename BaseImpl::ValueType;
37 using ElementType =
typename BaseImpl::ElementType;
47 : BaseImpl(
std::move(val))
56 std::size_t length()
const
58 auto valLength = BaseImpl::length();
60 lenField.setValue(std::min(valLength, std::size_t(MaxAllowedLength)));
61 return lenField.length() + valLength;
64 static constexpr std::size_t minLength()
66 return LenField::minLength();
69 static constexpr std::size_t maxLength()
71 return LenField::maxLength() + BaseImpl::maxLength();
76 if ((!BaseImpl::valid()) || (!canWrite())) {
81 auto lenValue = std::min(BaseImpl::length(), std::size_t(MaxAllowedLength));
82 lenField.setValue(lenValue);
83 return lenField.valid();
86 template <
typename TIter>
91 auto es = lenField.read(iter, len);
96 auto diff =
static_cast<std::size_t
>(std::distance(fromIter, iter));
99 auto remLen =
static_cast<std::size_t
>(lenField.getValue());
104 es = BaseImpl::read(iter, remLen);
112 static constexpr bool hasReadNoStatus()
117 template <
typename TIter>
118 void readNoStatus(TIter& iter) =
delete;
120 bool canWrite()
const
122 if (!BaseImpl::canWrite()) {
126 auto len = BaseImpl::length();
127 if (MaxAllowedLength < len) {
132 lenField.setValue(len);
133 return lenField.canWrite();
136 template <
typename TIter>
143 auto lenVal = BaseImpl::length();
145 lenField.setValue(lenVal);
146 auto es = lenField.write(iter, len);
152 return BaseImpl::write(iter, lenVal);
155 static constexpr bool hasWriteNoStatus()
160 template <
typename TIter>
161 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:1513
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.
@ InvalidMsgData
Used to indicate that a message has invalid data.