OnixS ICE iMpact Multicast Price Feed Handler C++ library 8.18.0
Users' manual and API documentation
Loading...
Searching...
No Matches
Message Deserialization

API

Each message class has a constructor and a deserialize() method which accepts a pointer to a raw data buffer and its size. This buffer should contain all message data, including the message type and body length (i.e., header).

Under the hood, the constructor calls the deserialize() method, so you can use the same object to deserialize from different data samples.

Note
It is important to pass a buffer with the message header because the deserialize() method uses absolute offsets, i.e., the first field should be located after three bytes of the message header.

Example

std::ifstream ifs("FuturesProductDefinition.bin");
char msgType = 0;
ifs.read(&msgType, sizeof(msgType));
unsigned short bodyLen = 0;
ifs.read((char*)&bodyLen, sizeof(bodyLen));
bodyLen = (bodyLen >> 8) | (bodyLen << 8);
const std::size_t offset = sizeof(msgType) + sizeof(bodyLen);
const std::size_t msgSize = offset + bodyLen;
std::vector<char> data(msgSize);
ifs.read(&data[offset], bodyLen);
FuturesProductDefinition msg(&data[0], data.size());