binary-deserialization

Wire Protocol Serialization

早过忘川 提交于 2020-01-06 07:27:40
问题 I'm looking for what I'll call a 'binary serializer/deserializer code generator' for lack of a better term that specifically allows you to specify the on-the-wire format with arbitrary bit lengths and then generates the necessary C/C++ code to pack/unpack packets in that format. I started down the path of using a struct with bit fields but after reading this post I'm wondering if there's already something out there that handles all the messy problems. An example data structure I would need to

Reading an int through char* buffer behaves different whether it is positive or negative

淺唱寂寞╮ 提交于 2020-01-05 04:11:09
问题 Background: I was wondering how to (manually) deserialize binary data if we got them through a char * buffer. Assumptions: As a minimal example, we will consider here that: I have only one int serialized through a char* buffer. I want to get the original int back from the buffer. sizeof(int) == 4 on the target system/platform. The endianness of the target system/platform is little-endian . Note: This is out of purely general interest therefore I don't want to use anything alike to std::memcpy