Deserialization
The following function prototypes can be found in the deserialization.h
header file.
#include <flashfix/deserialization.h>
These functions only verify the structural integrity of messages in terms of format, checksum, and body length. They do not validate the correctness of the messages (e.g. duplicate tags, invalid values, etc.).
ff_deserialize
uint16_t ff_deserialize(char *restrict buffer, const uint16_t buffer_size, fix_message_t *restrict message);
Description
deserializes a fix message by tokenizing the buffer in place: replacing '='
and '\x01'
delimiters with '\0'
and store pointers to the beginning of each field and value in the message struct.
Parameters
buffer
- the buffer which contains the full serialized messagebuffer_size
- the size of the buffer in bytesmessage
- the message struct where to store the deserialized fields, with the following conditions:fields
already allocated with the maximum number of fields that you expect to receivefield_count
set to the size of thefields
array (i.e. the maximum number of fields that can be stored)- everything else should be zeroed (
0
' orNULL
)
Returns
- length of the deserialized message in bytes
0
in case of error (see Errors)
Undefined Behavior
buffer
isNULL
message
isNULL
message->fields
isNULL
message->fields
is not allocatedmessage->field_count
is different from the actual size of thefields
arraybuffer_size
is different from the actual size of the bufferbuffer
does not contain a full message
Errors
- wrong beginstring
- no body length
- checksum mismatch
- body length mismatch
- too many fields
ff_is_complete
bool ff_is_complete(const char *buffer, const uint16_t len);
Description
checks if a buffer contains a full fix message (i.e. it ends with a checksum followed by a '\x01'
delimiter)
Parameters
buffer
- the buffer which contains the full serialized messagelen
- the length of the filled part of the buffer in bytes
Returns
true
if the buffer contains a full messagefalse
otherwise
Undefined Behavior
buffer
isNULL
len
is0