22template <
long long int TOffset,
typename TBase>
23class SerOffset :
public TBase
25 using BaseImpl = TBase;
26 static const auto Offset = TOffset;
29 using ValueType =
typename BaseImpl::ValueType;
30 using SerialisedType =
typename BaseImpl::SerialisedType;
31 using Endian =
typename BaseImpl::Endian;
33 SerOffset() =
default;
35 explicit SerOffset(
const ValueType& val)
40 explicit SerOffset(ValueType&& val)
41 : BaseImpl(
std::move(val))
45 SerOffset(
const SerOffset&) =
default;
46 SerOffset(SerOffset&&) =
default;
47 SerOffset& operator=(
const SerOffset&) =
default;
48 SerOffset& operator=(SerOffset&&) =
default;
51 template <
typename TIter>
54 if (size < BaseImpl::length()) {
62 template <
typename TIter>
63 void readNoStatus(TIter& iter)
65 auto serialisedValue =
66 comms::util::readData<SerialisedType>(iter,
Endian());
67 BaseImpl::setValue(fromSerialised(serialisedValue));
70 template <
typename TIter>
71 ErrorStatus write(TIter& iter, std::size_t size)
const
73 if (size < BaseImpl::length()) {
81 template <
typename TIter>
82 void writeNoStatus(TIter& iter)
const
87 static constexpr SerialisedType toSerialised(ValueType val)
89 return adjustToSerialised(BaseImpl::toSerialised(val));
92 static constexpr ValueType fromSerialised(SerialisedType val)
94 return BaseImpl::fromSerialised(adjustFromSerialised(val));
98 static SerialisedType adjustToSerialised(SerialisedType val)
100 return static_cast<SerialisedType
>(Offset + val);
103 static SerialisedType adjustFromSerialised(SerialisedType val)
105 return static_cast<SerialisedType
>((-Offset) + val);
This file contain definition of error statuses used by comms module.
Contains functions for raw data access / (de)serialization.
comms::option::def::Endian< TEndian > Endian
Same as comms::option::def::Endian.
Definition options.h:1438
void writeData(T value, TIter &iter, const traits::endian::Big &endian)
Same as writeBig<T, TIter>()
Definition access.h:706
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.