Dataflow Runtime API  3.1.1.0
Public Member Functions | List of all members
imt::base::core::serialization::Serializer Class Reference

Serializes various data types into the given byte buffer. More...

#include <Imt.Base.Core.Serialization/Serializer.h>

Public Member Functions

 Serializer (uint8_t buffer[], const uint32_t bufferSize)
 Constructor. More...
 
virtual ~Serializer (void)
 Destructor. More...
 
uint32_t getBufferPos (void) const
 Returns the write position within the byte buffer. More...
 
void setBufferPos (const uint32_t newPos)
 Sets the write position to the given position. More...
 
uint32_t getBufferSize (void) const
 Returns the size of the byte buffer in number of bytes. More...
 
const uint8_tgetBuffer (void) const
 Returns the pointer to the byte buffer. More...
 
uint32_t getUnusedBufferSize (void) const
 Returns the remaining data to write from the current position until the buffer is full. More...
 
bool isReset (void) const
 States if the serializer is reset (getBufferPos == 0). More...
 
bool isFullySerialized (void) const
 States if the buffer is completely serialized. More...
 
const uint8_tgetBufferByte (const uint32_t indexOfByte) const
 Returns the byte of the byte buffer at the given index. More...
 
void reset (void)
 Resets the Serializer. More...
 
Serializeroperator<< (const bool data)
 Puts a bool into the Serializer. More...
 
Serializeroperator<< (const uint8_t data)
 Puts a uint8_t into the Serializer. More...
 
Serializeroperator<< (const char_t data)
 Puts a character into the Serializer. More...
 
Serializeroperator<< (const char_t *data)
 Puts a null terminated string into the Serializer. More...
 
Serializeroperator<< (const int8_t data)
 Puts a int8_t into the Serializer. More...
 
Serializeroperator<< (const uint16_t data)
 Puts a uint16_t into the Serializer. More...
 
Serializeroperator<< (const int16_t data)
 Puts a int16_t into the Serializer. More...
 
Serializeroperator<< (const uint32_t data)
 Puts a uint32_t into the Serializer. More...
 
Serializeroperator<< (const int32_t data)
 Puts a int32_t into the Serializer. More...
 
Serializeroperator<< (const uint64_t data)
 Puts a uint64_t into the Serializer. More...
 
Serializeroperator<< (const int64_t data)
 Puts a int64_t into the Serializer. More...
 
Serializeroperator<< (const float32_t data)
 Puts a float into the Serializer. More...
 
Serializeroperator<< (const float64_t data)
 Puts a double into the Serializer. More...
 
SerializerpushData (const void *const pDataSrc, const uint32_t bytes)
 Puts data into the Serializer. More...
 
Serializeroperator<< (const SerializableIfc &data)
 Puts data into the Serializer. More...
 

Detailed Description

Serializes various data types into the given byte buffer.

The read position can be set to the beginning by calling reset. Important: The byte buffer passed with the constructor is storing the actual result.

Constructor & Destructor Documentation

◆ Serializer()

imt::base::core::serialization::Serializer::Serializer ( uint8_t  buffer[],
const uint32_t  bufferSize 
)
explicit

Constructor.

Parameters
buffer[]Byte buffer array to where the data should be written. Must be valid (!= NULL)!
bufferSizeSize of the byte buffer in number of bytes.

◆ ~Serializer()

virtual imt::base::core::serialization::Serializer::~Serializer ( void  )
virtual

Destructor.

Member Function Documentation

◆ getBuffer()

const uint8_t* imt::base::core::serialization::Serializer::getBuffer ( void  ) const

Returns the pointer to the byte buffer.

Returns
Pointer to the write buffer.

◆ getBufferByte()

const uint8_t& imt::base::core::serialization::Serializer::getBufferByte ( const uint32_t  indexOfByte) const

Returns the byte of the byte buffer at the given index.

Note
If the given index is out of bounds, the value at the last position will be returned.
Parameters
indexOfByteIndex of the byte to return.
Returns
Byte at the given index of the buffer.

◆ getBufferPos()

uint32_t imt::base::core::serialization::Serializer::getBufferPos ( void  ) const

Returns the write position within the byte buffer.

Returns
Write position within the byte buffer.

◆ getBufferSize()

uint32_t imt::base::core::serialization::Serializer::getBufferSize ( void  ) const

Returns the size of the byte buffer in number of bytes.

Returns
Buffer size in bytes.

◆ getUnusedBufferSize()

uint32_t imt::base::core::serialization::Serializer::getUnusedBufferSize ( void  ) const

Returns the remaining data to write from the current position until the buffer is full.

Returns
Remaining buffer size in bytes.

◆ isFullySerialized()

bool imt::base::core::serialization::Serializer::isFullySerialized ( void  ) const

States if the buffer is completely serialized.

Returns
True if buffer is completely serialized.

◆ isReset()

bool imt::base::core::serialization::Serializer::isReset ( void  ) const

States if the serializer is reset (getBufferPos == 0).

Returns
True if the write position is at the beginning.

◆ operator<<() [1/14]

Serializer& imt::base::core::serialization::Serializer::operator<< ( const bool  data)

Puts a bool into the Serializer.

Parameters
dataData to put into the serializer.
Returns
Reference to this serializer.

◆ operator<<() [2/14]

Serializer& imt::base::core::serialization::Serializer::operator<< ( const char_t data)

Puts a null terminated string into the Serializer.

Parameters
dataData to put into the serializer.
Returns
Reference to this serializer.

◆ operator<<() [3/14]

Serializer& imt::base::core::serialization::Serializer::operator<< ( const char_t  data)

Puts a character into the Serializer.

Parameters
dataData to put into the serializer.
Returns
Reference to this serializer.

◆ operator<<() [4/14]

Serializer& imt::base::core::serialization::Serializer::operator<< ( const float32_t  data)

Puts a float into the Serializer.

Parameters
dataData to put into the serializer.
Returns
Reference to this serializer.

◆ operator<<() [5/14]

Serializer& imt::base::core::serialization::Serializer::operator<< ( const float64_t  data)

Puts a double into the Serializer.

Parameters
dataData to put into the serializer.
Returns
Reference to this serializer.

◆ operator<<() [6/14]

Serializer& imt::base::core::serialization::Serializer::operator<< ( const int16_t  data)

Puts a int16_t into the Serializer.

Parameters
dataData to put into the serializer.
Returns
Reference to this serializer.

◆ operator<<() [7/14]

Serializer& imt::base::core::serialization::Serializer::operator<< ( const int32_t  data)

Puts a int32_t into the Serializer.

Parameters
dataData to put into the serializer.
Returns
Reference to this serializer.

◆ operator<<() [8/14]

Serializer& imt::base::core::serialization::Serializer::operator<< ( const int64_t  data)

Puts a int64_t into the Serializer.

Parameters
dataData to put into the serializer.
Returns
Reference to this serializer.

◆ operator<<() [9/14]

Serializer& imt::base::core::serialization::Serializer::operator<< ( const int8_t  data)

Puts a int8_t into the Serializer.

Parameters
dataData to put into the serializer.
Returns
Reference to this serializer.

◆ operator<<() [10/14]

Serializer& imt::base::core::serialization::Serializer::operator<< ( const SerializableIfc data)

Puts data into the Serializer.

Parameters
dataData to put into the serializer.
Returns
Reference to this serializer.

◆ operator<<() [11/14]

Serializer& imt::base::core::serialization::Serializer::operator<< ( const uint16_t  data)

Puts a uint16_t into the Serializer.

Parameters
dataData to put into the serializer.
Returns
Reference to this serializer.

◆ operator<<() [12/14]

Serializer& imt::base::core::serialization::Serializer::operator<< ( const uint32_t  data)

Puts a uint32_t into the Serializer.

Parameters
dataData to put into the serializer.
Returns
Reference to this serializer.

◆ operator<<() [13/14]

Serializer& imt::base::core::serialization::Serializer::operator<< ( const uint64_t  data)

Puts a uint64_t into the Serializer.

Parameters
dataData to put into the serializer.
Returns
Reference to this serializer.

◆ operator<<() [14/14]

Serializer& imt::base::core::serialization::Serializer::operator<< ( const uint8_t  data)

Puts a uint8_t into the Serializer.

Parameters
dataData to put into the serializer.
Returns
Reference to this serializer.

◆ pushData()

Serializer& imt::base::core::serialization::Serializer::pushData ( const void *const  pDataSrc,
const uint32_t  bytes 
)

Puts data into the Serializer.

Parameters
pDataSrcPointer to the data source.
bytesNumber of bytes to put into the serializer.
Returns
Reference to this serializer.

◆ reset()

void imt::base::core::serialization::Serializer::reset ( void  )

Resets the Serializer.

◆ setBufferPos()

void imt::base::core::serialization::Serializer::setBufferPos ( const uint32_t  newPos)

Sets the write position to the given position.

Parameters
newPosNew write position.

The documentation for this class was generated from the following file: