22template <
typename TSizeField,
typename TBase>
25 using BaseImpl = TBase;
26 using SizeField = TSizeField;
28 static const std::size_t MaxAllowedSize =
29 static_cast<std::size_t
>(SizeField::maxValue());
31 static_assert(!SizeField::isVersionDependent(),
32 "Prefix fields must not be version dependent");
35 using ValueType =
typename BaseImpl::ValueType;
36 using ElementType =
typename BaseImpl::ElementType;
46 : BaseImpl(
std::move(val))
55 std::size_t length()
const
58 sizeField.setValue(BaseImpl::getValue().size());
59 return sizeField.length() + BaseImpl::length();
62 static constexpr std::size_t minLength()
64 return SizeField::minLength();
67 static constexpr std::size_t maxLength()
69 return SizeField::maxLength() + BaseImpl::maxLength();
74 if ((!BaseImpl::valid()) || (!canWrite())) {
78 sizeField.setValue(BaseImpl::getValue().size());
79 return sizeField.valid() && BaseImpl::valid();
82 template <
typename TIter>
87 auto es = sizeField.read(iter, len);
92 auto diff =
static_cast<std::size_t
>(std::distance(fromIter, iter));
96 auto count =
static_cast<std::size_t
>(sizeField.getValue());
97 return BaseImpl::readN(count, iter, len);
100 template <
typename TIter>
101 void readNoStatus(TIter& iter)
104 sizeField.readNoStatus(iter);
105 auto count =
static_cast<std::size_t
>(sizeField.getValue());
106 BaseImpl::readNoStatusN(count, iter);
109 bool canWrite()
const
111 if (!BaseImpl::canWrite()) {
115 if (MaxAllowedSize < BaseImpl::getValue().size()) {
120 sizeField.setValue(BaseImpl::getValue().size());
121 return sizeField.canWrite();
124 template <
typename TIter>
132 sizeField.setValue(BaseImpl::getValue().size());
133 auto es = sizeField.write(iter, len);
139 return BaseImpl::write(iter, len - sizeField.length());
142 static constexpr bool hasWriteNoStatus()
147 template <
typename TIter>
148 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::SequenceSizeFieldPrefix< TField > SequenceSizeFieldPrefix
Same as comms::option::def::SequenceSizeFieldPrefix.
Definition options.h:1508
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.