Serialization
The following function prototypes can be found in the serialization.h
header file.
#include <flashfix/serialization.h>
These functions don't check the validity of messages, they assume that the message struct is correctly filled with the right values.
ff_serialize
uint16_t ff_serialize(char *restrict buffer, const fix_message_t *restrict message);
Description
serializes a fix message into a buffer by concatenating the fields with '=' and '\x01' delimiters and adding the mandatory beginstring, bodylength, and checksum fields.
Parameters
buffer
- the buffer where to store the serialized messagemessage
- the message struct containing the fields to serialize
Returns
- length of the serialized message in bytes
Undefined Behavior
buffer
isNULL
message
isNULL
message
doesn't fit in the buffer- value_len and
tag_len
are different from the actual length of the value and tag field_count
is different from the actual number of fields in the messagemessage
withNULL
fieldsmessage
with empty{}
fields arraymessage
with empty""
field stringsmessage
withvalue_len == 0
ortag_len == 0
message
withfield_count == 0
ff_serialize_raw
uint16_t ff_serialize_raw(char *restrict buffer, const fix_message_t *restrict message);
Description
serializes a fix message into a buffer by concatenating the fields with '=' and '\x01' delimiters.
Parameters
buffer
- the buffer where to store the serialized messagemessage
- the message struct containing the fields to serialize.
Returns
- length of the serialized message in bytes
Undefined Behavior
buffer
isNULL
message
isNULL
message
doesn't fit in the buffermessage->fields
isNULL
value_len
ortag_len
are different from the actual lengths of the stringsvalue
ortag
isNULL
field_count
is different from the actual number of fields in the message