![]() |
Imt.Base C++ API V4.1.1.0
|
Serializes various data types into the given byte buffer. More...
#include <Imt.Base.Core.Serialization/inc/Imt.Base.Core.Serialization/Serializer.h>
Public Types | |
using | AssertDebugFunctionPtr = void(*)(bool const condition, char_t const *const pMessage) |
Alias for ASSERT_DEBUG function pointer type (as raw function pointer) | |
Public Member Functions | |
Serializer ()=delete | |
Serializer (uint8_t buffer[], uint32_t const bufferSize) noexcept | |
Constructor. | |
uint32_t | getBufferPos () const |
Returns the write position within the byte buffer. | |
void | setBufferPos (uint32_t const newPos) |
Sets the write position to the given position. | |
uint32_t | getBufferSize () const |
Returns the size of the byte buffer in number of bytes. | |
uint8_t const * | getBuffer () const |
Returns the pointer to the byte buffer. | |
uint32_t | getUnusedBufferSize () const |
Returns the remaining data to write from the current position until the buffer is full. | |
bool | isReset () const |
States if the serializer is reset (getBufferPos == 0). | |
uint8_t const & | getBufferByte (uint32_t const indexOfByte) const |
Returns the byte of the byte buffer at the given index. | |
void | reset () |
Resets the Serializer. | |
bool | hasOverflow () const |
Query if an overflow happend during serialization. | |
Serializer & | operator<< (bool const data) |
Puts a bool into the Serializer. | |
Serializer & | operator<< (uint8_t const data) |
Puts a uint8_t into the Serializer. | |
Serializer & | operator<< (char_t const data) |
Puts a character into the Serializer. | |
Serializer & | operator<< (char_t const *pData) |
Puts a null terminated string into the Serializer. | |
Serializer & | operator<< (int8_t const data) |
Puts a int8_t into the Serializer. | |
Serializer & | operator<< (uint16_t const data) |
Puts a uint16_t into the Serializer. | |
Serializer & | operator<< (int16_t const data) |
Puts a int16_t into the Serializer. | |
Serializer & | operator<< (uint32_t const data) |
Puts a uint32_t into the Serializer. | |
Serializer & | operator<< (int32_t const data) |
Puts a int32_t into the Serializer. | |
Serializer & | operator<< (uint64_t const data) |
Puts a uint64_t into the Serializer. | |
Serializer & | operator<< (int64_t const data) |
Puts a int64_t into the Serializer. | |
Serializer & | operator<< (float32_t const data) |
Puts a float into the Serializer. | |
Serializer & | operator<< (float64_t const data) |
Puts a double into the Serializer. | |
Serializer & | pushData (void const *const pDataSrc, uint32_t const bytes) |
Puts data into the Serializer. | |
Serializer & | operator<< (SerializableIfc const &data) |
Puts data into the Serializer. | |
Static Public Member Functions | |
static void | setAssertDebugFunction (AssertDebugFunctionPtr const funcPtr) |
Set and replace the default assert-debug function. | |
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.
Definition at line 58 of file Serializer.h.
using imt::base::core::serialization::Serializer::AssertDebugFunctionPtr = void (*)(bool const condition, char_t const* const pMessage) |
Alias for ASSERT_DEBUG function pointer type (as raw function pointer)
Definition at line 262 of file Serializer.h.
|
delete |
|
noexcept |
Constructor.
buffer[] | Byte buffer array to where the data should be written. Must be valid (!= nullptr)! |
bufferSize | Size of the byte buffer in number of bytes. |
uint8_t const * imt::base::core::serialization::Serializer::getBuffer | ( | ) | const |
Returns the pointer to the byte buffer.
uint8_t const & imt::base::core::serialization::Serializer::getBufferByte | ( | uint32_t const | indexOfByte | ) | const |
Returns the byte of the byte buffer at the given index.
indexOfByte | Index of the byte to return. |
uint32_t imt::base::core::serialization::Serializer::getBufferPos | ( | ) | const |
Returns the write position within the byte buffer.
uint32_t imt::base::core::serialization::Serializer::getBufferSize | ( | ) | const |
Returns the size of the byte buffer in number of bytes.
uint32_t imt::base::core::serialization::Serializer::getUnusedBufferSize | ( | ) | const |
Returns the remaining data to write from the current position until the buffer is full.
bool imt::base::core::serialization::Serializer::hasOverflow | ( | ) | const |
Query if an overflow happend during serialization.
Methods reset and setBufferPos (called with valid arguments) will reset the the overflow state to false.
bool imt::base::core::serialization::Serializer::isReset | ( | ) | const |
States if the serializer is reset (getBufferPos == 0).
Serializer & imt::base::core::serialization::Serializer::operator<< | ( | bool const | data | ) |
Puts a bool into the Serializer.
data | Data to put into the serializer. |
Serializer & imt::base::core::serialization::Serializer::operator<< | ( | char_t const * | pData | ) |
Puts a null terminated string into the Serializer.
pData | Data to put into the serializer. |
Serializer & imt::base::core::serialization::Serializer::operator<< | ( | char_t const | data | ) |
Puts a character into the Serializer.
data | Data to put into the serializer. |
Serializer & imt::base::core::serialization::Serializer::operator<< | ( | float32_t const | data | ) |
Puts a float into the Serializer.
data | Data to put into the serializer. |
Serializer & imt::base::core::serialization::Serializer::operator<< | ( | float64_t const | data | ) |
Puts a double into the Serializer.
data | Data to put into the serializer. |
Serializer & imt::base::core::serialization::Serializer::operator<< | ( | int16_t const | data | ) |
Puts a int16_t into the Serializer.
data | Data to put into the serializer. |
Serializer & imt::base::core::serialization::Serializer::operator<< | ( | int32_t const | data | ) |
Puts a int32_t into the Serializer.
data | Data to put into the serializer. |
Serializer & imt::base::core::serialization::Serializer::operator<< | ( | int64_t const | data | ) |
Puts a int64_t into the Serializer.
data | Data to put into the serializer. |
Serializer & imt::base::core::serialization::Serializer::operator<< | ( | int8_t const | data | ) |
Puts a int8_t into the Serializer.
data | Data to put into the serializer. |
Serializer & imt::base::core::serialization::Serializer::operator<< | ( | SerializableIfc const & | data | ) |
Puts data into the Serializer.
data | Data to put into the serializer. |
Serializer & imt::base::core::serialization::Serializer::operator<< | ( | uint16_t const | data | ) |
Puts a uint16_t into the Serializer.
data | Data to put into the serializer. |
Serializer & imt::base::core::serialization::Serializer::operator<< | ( | uint32_t const | data | ) |
Puts a uint32_t into the Serializer.
data | Data to put into the serializer. |
Serializer & imt::base::core::serialization::Serializer::operator<< | ( | uint64_t const | data | ) |
Puts a uint64_t into the Serializer.
data | Data to put into the serializer. |
Serializer & imt::base::core::serialization::Serializer::operator<< | ( | uint8_t const | data | ) |
Puts a uint8_t into the Serializer.
data | Data to put into the serializer. |
Serializer & imt::base::core::serialization::Serializer::pushData | ( | void const *const | pDataSrc, |
uint32_t const | bytes | ||
) |
Puts data into the Serializer.
pDataSrc | Pointer to the data source. |
bytes | Number of bytes to put into the serializer. |
void imt::base::core::serialization::Serializer::reset | ( | ) |
Resets the Serializer.
|
static |
Set and replace the default assert-debug function.
funcPtr | The function pointer to use for assert-debug checks |
void imt::base::core::serialization::Serializer::setBufferPos | ( | uint32_t const | newPos | ) |
Sets the write position to the given position.
newPos | New write position. |