OnixS C++ FIX Engine 2.79.1.0
Manipulating Message Fields

A FIX message represents a sequence of fields whose values are associated with unique numbers (tags). Such an interpretation treats a message as an collection of values associated with tag numbers. For this reason the primary approach in handling message fields is similar to managing associative collections.

Adding Field into Message

To associate a field with a value OnixS::FIX::Message::set method must be used. If there is no field of a given tag number available in the message, this member creates an association. If the field already exists, this member updates its value with the new value.

Accessing Field Value

To get a field value the OnixS::FIX::Message::get method must be used.

Removing Field from Message

To remove a field the OnixS::FIX::Message::remove method must be used.

Example

The following example demonstrates the basic operations on message fields.

#include <OnixS/FIXEngine.h>

using namespace OnixS::FIX;
using namespace OnixS::FIX::FIX40;

Message order(Values::MsgType::OrderSingle, FIX_40);

order.set(11, "Unique identifier of execution message");

string ClOrdID = order.get(11);

order.remove(11);

Named Tags Constants

In each sub-namespace which corresponds to certain FIX version (like OnixS::FIX::FIX42) there is a OnixS::FIX::FIX42::Tags class defined. This class contains the constants for all known tag numbers. Use of these constants makes the source code more readable.

#include <OnixS/FIXEngine.h>

using namespace OnixS::FIX;
using namespace OnixS::FIX::FIX40;

Message order(Values::MsgType::OrderSingle, FIX_40);

order.set(Tags::ClOrdID, "90001008");

order.set(Tags::Side, "1");

order.set(Tags::TimeInForce, "0");