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);
std::cout << "Field " << TagName << "(" << TagNumber << ") has";
std::cout << " type "
<< " and";
std::cout << " the following valid values:" << std::endl;
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.
{
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)
{
for(const auto & msgType : messageTypes)
{
std::cout <<
"Traversing " << dictionary.
messageName(msgType) <<
"(msgType=" << msgType <<
")" << std::endl;
}
}