![]() |
B2BITS FIX Antenna C++
2.31.0
|
Please refer to the section Message description for more information about FIX Message.
FIX Message object can be created in two different ways:
To create a skeleton for a FIX application-level message, use the Engine::FIXMsgFactory::newSkel(...) method. Then set all required field for the newly created FIX message object.
For example:
Use the FIXMsgProcessor::parse(...) method to parse a string containing a raw FIX message into the FIXMessage class.
For example:
Use the bool Engine::FIXMessage::get(int tag, Engine::FIXFieldValue *value) method to get the FIX field value.
This method retrieves the field value by tag number and stores it into an instance of the Engine::FIXFieldValue class. The field can be:
In the 1st case the method throws Utils::Exception exception. In the 2nd case the method returns "false". In the 3rd case the method returns "true" and the value is returned in the inout parameter.
Use the bool Engine::FIXMessage::set(int tag, const Engine::FIXFieldValue &value) method to set a field value.
This method returns "true" if the given tag is found and the old value is replaced with the new one. Otherwise the method returns "false" (the given tag is inserted).
The method throws Utils::Exception exception if it cannot be executed (e.g. the given tag is not defined for this message type).
Use the bool Engine::FIXMessage::remove(int tag) method to remove a field by tag.
This method returns "true" if the given tag is found and the field is removed. Otherwise the method returns "false".
Please refer to the section Repeating Groups description for more information about repeating groups.
The Engine::FIXGroup class is designed to work with Repeating Groups. The access to the repeating groups is provided by the Engine::FIXMessage class. The common workflow when working with repeating groups is
In case of nested repeating groups the parent repeating group should be used to get pointer to the inner repeating group the same way it is done in FIX message. In theory the level of nesting is not limited by the FIX protocol standard.
To add repeating group to the message simply set value for the repeating group leading tag to the number of entries planned for the repeating group.
To resize repeating group simply modify the value of leading tag. When setting the new value for the leading tag, the group is re-created and old field values inside the group are erased.
The Engine::FIXGroup class contains methods to work with message fields, similar to those existing in the Engine::FIXMessage class, however in contrast to them, there is an additional argument defining index (a sequence number starting with 0) of the group entry, for example:
Use the Engine::FIXMessage::remove(int tag) method, where tag is a Repeating Group Leading Tag, to remove the Repeating Group. Setting the corresponding tag to zero is not allowed (Parser Exception is thrown).
If non-existing or invalid values are specified for the arguments in the methods above then exception is thrown.
Example below demonstrates how to work with repeating group.
User Defined Fields (the tag numbers 5000 to 9999) are operated the same way as standard fields.
For example:
To copy FIX message, use the Engine::FIXMsgProcessor::clone(const Engine::FIXMessage &inMsg) method. For example:
To de-allocate resources used by FIX message, use the Engine::FIXMessage::release(Engine::FIXMessage *apMsg) method.
For example:
Utils::AutoPtr helper can be used to automate cleanup procedure.
FIX Antenna supports message validation. Validation can be switched on/off. Following are available validation options:
By default validation is disabled. There are two ways to enable/configure it:
#Enable validation Session.Default.Validation.IsEnabled = true # Configure validation Session.Default.Validation.ProhibitTagsWithoutValue = true Session.Default.Validation.VerifyTagsValues = true Session.Default.Validation.ProhibitUnknownTags = true Session.Default.Validation.VerifyReperatingGroupBounds = true Session.Default.Validation.CheckRequiredGroupFields = true
Here is sample how to validate message: