Class cerializer::Deserializer
template <typename T>
ClassList > cerializer > Deserializer
A class for deserializing messages from a generic input stream. More...
#include <serializer.hpp>
Public Functions
| Type | Name |
|---|---|
| Deserializer (T & readStream) Constructs a Deserializer . |
|
| void | ParseStream (std::function< void(std::unique_ptr< Type > &)> callback) Parses the input stream and invokes a callback for each complete message found. |
Protected Attributes
| Type | Name |
|---|---|
| std::array< char, 128 > | buf |
| char * | end_offset = buf.begin() |
| ParseMode | fail = START |
| const std::array< char, 2 > | footer_bytes = [**toCharArray**](namespacecerializer.md#function-tochararray)([**magicFoot**](namespacecerializer.md#variable-magicfoot)) |
| const std::array< char, 2 > | header_bytes = [**toCharArray**](namespacecerializer.md#function-tochararray)([**magicHead**](namespacecerializer.md#variable-magichead)) |
| T & | input |
| char * | offset = buf.begin() |
| std::size_t | read_size = header\_bytes.size() |
| ParseMode | state = START |
| ParseMode | success = PRE\_END |
| std::array< char, 2 > | token = header\_bytes |
Protected Functions
| Type | Name |
|---|---|
| constexpr auto | findToken (const std::span< char > & buffer, const std::span< char > & value, const ParseMode & fail_state, const ParseMode & success_state) |
Detailed Description
This class implements a state machine to parse a stream of characters, identify message frames (delimited by magicHead and magicFoot), and deserialize the enclosed payload into a message object using the MessageMaker factory. It is designed to handle continuous, asynchronous data streams.
Template parameters:
TThe type of the input stream, which must satisfy theIOAbleconcept.
Public Functions Documentation
function Deserializer
Constructs a Deserializer .
inline cerializer::Deserializer::Deserializer (
T & readStream
)
Parameters:
readStreamThe input stream to read from.
function ParseStream
Parses the input stream and invokes a callback for each complete message found.
template<std::derived_from< BasePacket > Type>
inline void cerializer::Deserializer::ParseStream (
std::function< void(std::unique_ptr< Type > &)> callback
)
This method continuously reads from the stream, searches for message frames (delimited by magic numbers), and deserializes them.
Template parameters:
TypeThe base type of the messages to expect (e.g., BasePacket).
Parameters:
callbackA function to be called with each successfully parsed message.
Protected Attributes Documentation
variable buf
std::array<char, 128> cerializer::Deserializer< T >::buf;
variable end_offset
char* cerializer::Deserializer< T >::end_offset;
variable fail
ParseMode cerializer::Deserializer< T >::fail;
variable footer_bytes
const std::array<char, 2> cerializer::Deserializer< T >::footer_bytes;
variable header_bytes
const std::array<char, 2> cerializer::Deserializer< T >::header_bytes;
variable input
T& cerializer::Deserializer< T >::input;
variable offset
char* cerializer::Deserializer< T >::offset;
variable read_size
std::size_t cerializer::Deserializer< T >::read_size;
variable state
ParseMode cerializer::Deserializer< T >::state;
variable success
ParseMode cerializer::Deserializer< T >::success;
variable token
std::array<char, 2> cerializer::Deserializer< T >::token;
Protected Functions Documentation
function findToken
inline constexpr auto cerializer::Deserializer::findToken (
const std::span< char > & buffer,
const std::span< char > & value,
const ParseMode & fail_state,
const ParseMode & success_state
)
The documentation for this class was generated from the following file serializer.hpp