OnixS C++ FIX Engine 4.14.0
Users' manual and API documentation
Loading...
Searching...
No Matches
Dictionary Exploration

The OnixS::FIX::Dictionary class exposes an interface to access information about the content of a specialized FIX dictionary or standard FIX messaging specification. This interface allows to obtain the types of a specific dictionary or standard FIX messages, and to explore the entire message structure, as well as to retrieve names of arbitrary fields by tag numbers.

Accessing Fields Information

The following members are present for basic field information manipulation:

const Tag TagNumber = FIX44::Tags::Side;
const std::string TagName = fix44.fieldName(TagNumber);
const FieldValueTypes::Enum FieldType = fix44.fieldType(TagNumber);
std::cout << "Field " << TagName << "(" << TagNumber << ") has";
// Standard dictionaries do not retain field types.
// Dictionaries must be overridden and the 'type' attribute must be added
// to the 'Field' node in the FIX Dictionary XML file.
if(FieldType != FieldValueTypes::Unknown)
std::cout << " type "
<< " and";
std::cout << " the following valid values:" << std::endl;
Dictionary::ValidFieldValues validFieldValues = fix44.validFieldValues(TagNumber);
for(const auto & validFieldValue : validFieldValues)
{
std::cout << validFieldValue.value() << "(" << validFieldValue.description() << ")" << std::endl;
}
Note
Standard dictionaries do not retain field types. They must be overridden and the 'type' attribute must be added to the 'Field' node in the FIX Dictionary XML file. See Field value validation.

Exploring Dictionary Messages Structure

To explore message-related information, the following members are present:

The following example demonstrates how fields, which make up a message, can be traversing.

void traverseFields(const Dictionary::FieldInfos& fields, int shift)
{
std::string spaces(shift, ' ');
for(const auto & fieldInfo : fields)
{
std::cout << spaces << fieldInfo.tag() << "(required=" << fieldInfo.isRequired() << ")" << std::endl;
traverseFields(fieldInfo.childFields(), 2 + shift);
}
}
void traverseMessages(const Dictionary& dictionary)
{
Dictionary::MessageTypes messageTypes = dictionary.messageTypes();
for(const auto & msgType : messageTypes)
{
std::cout << "Traversing " << dictionary.messageName(msgType) << "(msgType=" << msgType << ")" << std::endl;
traverseFields(dictionary.messageFields(msgType), 0);
}
}