Inner Contents | |
FIX Repeating Groups | |
In general, FIX message represents a sequence of the fields whose values are associated with unique numbers (tags).
A common way of presenting a FIX message is called the tag-value
FIX message format. In such a format, all fields are presented as tag=value pairs and are delimited by special <SOH> symbol.
The following image depicts the structure of the FIX message in the tag-value format:
OnixS C++ FIX Engine exposes OnixS::FIX::Message class to encapsulate all services related to handling FIX messages.
To create a blank FIX Message object, the OnixS::FIX::Message constructor must be used. It initializes a message of the specified type and FIX protocol version with no fields, presented except a couple of service fields, like those which identify a type and version of the FIX protocol which this constructed message belongs to.
The OnixS::FIX::Message constructor is available to construct a message instance from its raw (tag-value) representation.
The OnixS::FIX::Message::toRaw method can be used to build a FIX-compliant tag-value
presentation of the message. The output OnixS::FIX::RawMessage object contains the serialized FIX message in the same representation as it will be sent to the wire.
Several overloads of the OnixS::FIX::Message::toString method are available to build the pretty print tag-value presentation of a message instance. The delimiter
parameter is used as a field delimiter. The flags
parameter affects the resulting representation of the message. It can include field tag numbers, field names, and value descriptions. These overloads also simplify debugging and monitoring. Also, there is an ability to build the XML and JSON presentation of a message. The OnixS::FIX::Message::toXml and OnixS::FIX::Message::toJson methods can be used for this purpose.
In addition to the presence of a particular field in the message of a certain type, the FIX protocol also defines whether the presence of fields are strictly required in the message, whether they are required under certain conditions, or whether they are optional. To check for the presence of all required fields, the OnixS::FIX::Message::validate method must be used. This process is called "message validation" in the C++ FIX Engine terminology.
The following example demonstrates how messages can be created and parsed from the raw representation.
The OnixS::FIX::Message::userData() method can attach a user data pointer to the message object. This way can be used to associate some data with the given message object or pass user data with a message object through sending or receiving call stack. The user data is available in OnixS::FIX::ISessionListener, and OnixS::FIX::ISessionStorage callbacks are called for this particular message object.