Template Class deserializer#
Defined in File serdes.h
Class Documentation#
-
template<sdv::EEndian eSourceEndianess = GetPlatformEndianess(), typename TCRC = crcCCITT_FALSE>
class deserializer# Deserializer class implementing the deserialization of basic types.
The deserialization from the buffer is aligned to the size of the value that was stored. For example, bytes are stored at any position. 16-bit words are stored at 2 bytes aligned. 32-bits can be stored at 4 bytes aligned and 64-bits are stored at 8 bytes aligned.
- Template Parameters:
eSourceEndianess – The source endianness determines whether to swap the bytes after retrieving them from the buffer.
TCRC – The CRC type to use for the checksum calculation.
Public Functions
-
deserializer()#
Constructor.
-
template<typename T>
void pop_front(T &rtValue)# Pull the value from the deserializer.
- Template Parameters:
T – Type of the value. Only arithmic and boolean types can be deserialized. All other types need to be composed by deserialized arithmic and boolean types.
- Parameters:
rtValue – [out] Reference to the value to get.
-
template<typename T>
void peek_front(T &rtValue)# Peek for the value from the deserializer without popping the value from the deserializer.
- Template Parameters:
T – Type of the value. Only arithmic and boolean types can be deserialized.
- Parameters:
rtValue – [out] Reference to the value to get.
-
void assign(const uint8_t *pData, size_t nSize, typename TCRC::TCRCType uiChecksum = 0)#
Assign a buffer.
- Parameters:
pData – [in] Pointer to the data.
nSize – [in] Data size;
uiChecksum – [in] The checksum value that was calculated or 0 when no checksum checking should occur before deserialization.
-
void attach(const pointer<uint8_t> &rptrData, typename TCRC::TCRCType uiChecksum = 0)#
Attach a buffer.
Remark
Providing the checksum will result a check through the data in the supplied buffer for the fitting checksum.
- Parameters:
rptrData – [in] Reference to the data pointer.
uiChecksum – [in] The checksum value that was calculated or 0 when no checksum checking should occur.
-
TCRC::TCRCType checksum() const noexcept#
Return the calculated checksum value of the deserialized data.
- Returns:
Checksum value.
-
size_t size() const#
Return the size of the contained buffer.
- Returns:
The size of the buffer.
-
size_t offset() const#
Return the current offset.
- Returns:
The offset from the start of the stream.
-
size_t remaining() const#
Return the leftover space within the buffer (size - offset).
- Returns:
The leftover space of the buffer.
-
void jump(size_t nOffset, typename TCRC::TCRCType uiChecksum = 0)#
Skip to the supplied offset and start calculating the rest of the checksum with the supplied checksum.
This function allows navigating through the buffer or chunkwise deserialization. By supplying an offset, the deserialization can start from the supplied offset using the supplied checksum to check any further. It is also possible to do chunkwise deserialization, providing a small buffer covering only part of the large serialized package. Jumping to the beginning of the buffer (offset 0), but explicitly setting the checksum, allows processing the package as if part of a larger buffer.
- Parameters:
nOffset – [in] New offset to start processing from. Must be smaller than the buffer size.
uiChecksum – [in] Checksum to start calculating the checksum value over the following data with.