Midnight Sun Firmware
|
Serialization helper library. More...
Functions | |
template<typename T > | |
void | serializeInteger (std::string &target, T value) |
Serialize an integer value. More... | |
void | serializeString (std::string &target, const std::string &str) |
Serialize a string value. More... | |
template<typename T > | |
T | deserializeInteger (const std::string &source, size_t &offset) |
Deserialize an integer value. More... | |
std::string | deserializeString (std::string &source, size_t &offset) |
Deserialize a string value. More... | |
Serialization helper library.
T deserializeInteger | ( | const std::string & | source, |
size_t & | offset | ||
) |
Deserialize an integer value.
The offset will automatically be incremented in this function
source | Message payload to be decoded |
offset | Byte offset from the start of the message payload |
std::string deserializeString | ( | std::string & | source, |
size_t & | offset | ||
) |
Deserialize a string value.
This will fetch the string value based on the stored length The offset will automatically be incremented in this function
source | Message payload to be decoded |
offset | Byte offset from the start of the message payload |
void serializeInteger | ( | std::string & | target, |
T | value | ||
) |
Serialize an integer value.
The integer will be converted to a string of size T. Size T is dependent on the type of integer. The stringified-integer is appended to the target.
target | Existing message payload |
value | Value to be appended |
void serializeString | ( | std::string & | target, |
const std::string & | str | ||
) |
Serialize a string value.
The string will be pre-fixed with a 16-bit size to indicate the size The string is appended to the target. The final packet follows as such: | target | 16-bit length | str |
target | Existing message payload |
str | String to be appended |