24template <
typename TLenField, comms::ErrorStatus TStatus,
typename TBase>
27 using BaseImpl = TBase;
28 using LenField = TLenField;
30 static const std::size_t MaxAllowedLength =
31 static_cast<std::size_t
>(LenField::maxValue());
33 static_assert(!LenField::isVersionDependent(),
34 "Prefix fields must not be version dependent");
37 using ValueType =
typename BaseImpl::ValueType;
38 using ElementType =
typename BaseImpl::ElementType;
48 : BaseImpl(
std::move(val))
57 std::size_t length()
const
59 auto valLength = BaseImpl::length();
61 lenField.setValue(std::min(valLength, std::size_t(MaxAllowedLength)));
62 return lenField.length() + valLength;
65 static constexpr std::size_t minLength()
67 return LenField::minLength();
70 static constexpr std::size_t maxLength()
72 return LenField::maxLength() + BaseImpl::maxLength();
77 if ((!BaseImpl::valid()) || (!canWrite())) {
82 auto lenValue = std::min(BaseImpl::length(), std::size_t(MaxAllowedLength));
83 lenField.setValue(lenValue);
84 return lenField.valid();
87 template <
typename TIter>
92 auto es = lenField.read(iter, len);
97 auto diff =
static_cast<std::size_t
>(std::distance(fromIter, iter));
100 auto remLen =
static_cast<std::size_t
>(lenField.getValue());
105 es = BaseImpl::read(iter, remLen);
113 static constexpr bool hasReadNoStatus()
118 template <
typename TIter>
119 void readNoStatus(TIter& iter) =
delete;
121 bool canWrite()
const
123 if (!BaseImpl::canWrite()) {
127 auto len = BaseImpl::length();
128 if (MaxAllowedLength < len) {
133 lenField.setValue(len);
134 return lenField.canWrite();
137 template <
typename TIter>
144 auto lenVal = BaseImpl::length();
146 lenField.setValue(lenVal);
147 auto es = lenField.write(iter, len);
153 return BaseImpl::write(iter, lenVal);
156 static constexpr bool hasWriteNoStatus()
161 template <
typename TIter>
162 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:168
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:1566
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.