Both OnixS::FIX::FAST::Encoder and OnixS::FIX::FAST::Decoder constructors require the string that contains the XML-based descriptions of coding rules called FAST templates
.
A FAST template represents an XML-based description of encoding and decoding rules in accordance with the FAST specification.
Template identifier (Template ID) is assigned for each FAST template which uniquely identifies the encoding/decoding rules.
More than one FAST template can be used to encode the same FIX message type, so the Template ID is supplied as an argument of the OnixS::FIX::FAST::Encoder::Encode method.
The following example represents a typical FAST template structure:
<?xml version="1.0" encoding="utf-8"?> <templates> <template name="Market Data - Incremental Refresh (X)" id="88"> <uInt32 name="BodyLength" id="9"/> <string name="MessageType" id="35"> <constant value="X" /> </string> <string name="SenderCompID" id="49"> <copy/> </string> <string name="TargetCompID" id="56"> <copy/> </string> <uInt64 name="MsgSeqNum" id="34"> <increment value="1"/> </uInt64> <string name="SendingTime" id="52"> <tail/> </string> <string name="PosDupFlag" id="43" presence="optional"> <default/> </string> <sequence name="MDEntries"> <length name="NoMDEntries" id="268"/> <string name="MDUpdateAction" id="279"/> <string name="Symbol" id="55"/> </sequence> <string name="CheckSum" id="10"/> </template> </templates>
Following field types are supported:
The required name
attribute identifies the corresponding field in the current FIX message type by the field name.
The optional id
attribute identifies the corresponding field in the current FIX message type by the tag number.
The optional presence
attribute indicates whether the field is mandatory or optional. If the attribute is not specified, the field is mandatory.
A field that is not of Sequence
type can have a field operator. The Field Operator specifies an optimization operation for the field.
The following field operators are supported:
Field Operator | Example | Notes |
Constant |
<string name="MessageType" id="35"> |
Specifies that the value of a field will always be the same initial value. Is applicable to all field types. |
Default |
<string name="PosDupFlag" id="43" presence="optional"> |
Specifies that the value of a field is either present in the FAST stream or it will be the initial value. Is applicable to all field types. |
Copy |
<uInt32 name="MDUpdateAction" id="279"> |
If the value is present in the stream it becomes the new previous value, otherwise the value of the field is the previous value. Is applicable to all field types. |
Increment |
<uInt32 name="RptSeq" id="83"> |
If the value is present in the stream it becomes the new previous value, otherwise the value of the field is the previous value incremented by one. Is applicable to Integer field types only. |
Delta |
<int32 name="MDEntrySize" id="271"> |
Specifies that a delta value is present in the stream. The field is obtained by combining the delta value with the previous value. Is applicable to Integer, Decimal, String and Byte Vector field types. |
Tail |
<string name="SendingTime" id="52"> |
Specifies that a tail value is present in the stream. The value of the field is obtained by combining the tail value with the previous value. Is applicable to String and Byte Vector fields with constant or increasing value length. |
Field operators may rely on a previous value. Previous values are maintained in named dictionaries. To reset the states of dictionaries (set the state of the previous values to undefined) the OnixS::FIX::FAST::Encoder::reset and OnixS::FIX::FAST::Decoder::reset methods are used.