![]() |
Represents a data dictionary for a version of FIX. More...
#include <DataDictionary.h>
Public Member Functions | |
DataDictionary () | |
DataDictionary (const DataDictionary ©) | |
DataDictionary (std::istream &stream) throw ( ConfigError ) | |
DataDictionary (const std::string &url) throw ( ConfigError ) | |
virtual | ~DataDictionary () |
void | readFromURL (const std::string &url) throw ( ConfigError ) |
void | readFromDocument (DOMDocumentPtr pDoc) throw ( ConfigError ) |
void | readFromStream (std::istream &stream) throw ( ConfigError ) |
int * | getOrderedFields () const |
void | setVersion (const std::string &beginString) |
std::string | getVersion () const |
void | addField (int field) |
void | addFieldName (int field, const std::string &name) |
bool | getFieldName (int field, std::string &name) const |
bool | getFieldTag (std::string name, int &field) const |
void | addValueName (int field, const std::string &value, const std::string &name) |
bool | getValueName (int field, const std::string &value, std::string &name) const |
bool | isField (int field) const |
void | addMsgType (const std::string &msgType) |
bool | isMsgType (const std::string &msgType) const |
void | addMsgField (const std::string &msgType, int field) |
bool | isMsgField (const std::string &msgType, int field) const |
void | addHeaderField (int field, bool required) |
bool | isHeaderField (int field) const |
void | addTrailerField (int field, bool required) |
bool | isTrailerField (int field) const |
void | addFieldType (int field, FIX::TYPE::Type type) |
bool | getFieldType (int field, FIX::TYPE::Type &type) const |
void | addRequiredField (const std::string &msgType, int field) |
bool | isRequiredField (const std::string &msgType, int field) const |
void | addFieldValue (int field, const std::string &value) |
bool | hasFieldValue (int field) const |
bool | isFieldValue (int field, const std::string &value) const |
void | addGroup (const std::string &msg, int field, int delim, const DataDictionary &dataDictionary) |
bool | isGroup (const std::string &msg, int field) const |
bool | getGroup (const std::string &msg, int field, int &delim, const DataDictionary *&pDataDictionary) const |
bool | isDataField (int field) const |
bool | isMultipleValueField (int field) const |
void | checkFieldsOutOfOrder (bool value) |
void | checkFieldsHaveValues (bool value) |
void | checkUserDefinedFields (bool value) |
void | validate (const Message &message) const throw ( FIX::Exception ) |
void | validate (const Message &message, bool bodyOnly) const throw ( FIX::Exception ) |
DataDictionary & | operator= (const DataDictionary &rhs) |
Static Public Member Functions | |
static void | validate (const Message &message, const DataDictionary *const pSessionDD, const DataDictionary *const pAppID) throw ( FIX::Exception ) |
Validate a message. | |
Private Types | |
typedef std::set< int > | MsgFields |
typedef std::map< std::string, MsgFields > | MsgTypeToField |
typedef std::set< std::string > | MsgTypes |
typedef std::set< int > | Fields |
typedef std::map< int, bool > | NonBodyFields |
typedef std::vector< int > | OrderedFields |
typedef int * | OrderedFieldsArray |
typedef std::map< int, TYPE::Type > | FieldTypes |
typedef std::set< std::string > | Values |
typedef std::map< int, Values > | FieldToValue |
typedef std::map< int, std::string > | FieldToName |
typedef std::map< std::string, int > | NameToField |
typedef std::map< std::pair < int, std::string > , std::string > | ValueToName |
typedef std::map< std::pair < std::string, int > , std::pair< int, DataDictionary * > > | FieldToGroup |
Private Member Functions | |
void | iterate (const FieldMap &map, const MsgType &msgType) const |
Iterate through fields while applying checks. | |
void | checkMsgType (const MsgType &msgType) const |
Check if message type is defined in spec. | |
bool | shouldCheckTag (const FieldBase &field) const |
If we need to check for the tag in the dictionary. | |
void | checkValidTagNumber (const FieldBase &field) const throw ( InvalidTagNumber ) |
Check if field tag number is defined in spec. | |
void | checkValidFormat (const FieldBase &field) const throw ( IncorrectDataFormat ) |
void | checkValue (const FieldBase &field) const throw ( IncorrectTagValue ) |
void | checkHasValue (const FieldBase &field) const throw ( NoTagValue ) |
Check if a field has a value. | |
void | checkIsInMessage (const FieldBase &field, const MsgType &msgType) const throw ( TagNotDefinedForMessage ) |
Check if a field is in this message type. | |
void | checkGroupCount (const FieldBase &field, const FieldMap &fieldMap, const MsgType &msgType) const throw ( RepeatingGroupCountMismatch ) |
Check if group count matches number of groups in. | |
void | checkHasRequired (const FieldMap &header, const FieldMap &body, const FieldMap &trailer, const MsgType &msgType) const throw ( RequiredTagMissing ) |
Check if a message has all required fields. | |
void | readMSXMLDOM (const std::string &) |
Read XML file using MSXML. | |
void | readMSXML (const std::string &) |
void | readLibXml (const std::string &) |
Read XML file using libXML. | |
int | lookupXMLFieldNumber (DOMDocument *, DOMNode *) const |
int | lookupXMLFieldNumber (DOMDocument *, const std::string &name) const |
int | addXMLComponentFields (DOMDocument *, DOMNode *, const std::string &msgtype, DataDictionary &, bool) |
void | addXMLGroup (DOMDocument *, DOMNode *, const std::string &msgtype, DataDictionary &, bool) |
TYPE::Type | XMLTypeToType (const std::string &xmlType) const |
Private Attributes | |
bool | m_hasVersion |
bool | m_checkFieldsOutOfOrder |
bool | m_checkFieldsHaveValues |
bool | m_checkUserDefinedFields |
BeginString | m_beginString |
MsgTypeToField | m_messageFields |
MsgTypeToField | m_requiredFields |
MsgTypes | m_messages |
Fields | m_fields |
OrderedFields | m_orderedFields |
OrderedFieldsArray | m_orderedFieldsArray |
NonBodyFields | m_headerFields |
NonBodyFields | m_trailerFields |
FieldTypes | m_fieldTypes |
FieldToValue | m_fieldValues |
FieldToName | m_fieldNames |
NameToField | m_names |
ValueToName | m_valueNames |
FieldToGroup | m_groups |
Represents a data dictionary for a version of FIX.
Generally loaded from an XML document. The DataDictionary is also responsible for validation beyond the basic structure of a message.
Definition at line 49 of file DataDictionary.h.
typedef std::set< int > FIX::DataDictionary::Fields [private] |
Definition at line 54 of file DataDictionary.h.
typedef std::map< std::pair < std::string, int > , std::pair < int, DataDictionary* > > FIX::DataDictionary::FieldToGroup [private] |
Definition at line 66 of file DataDictionary.h.
typedef std::map< int, std::string > FIX::DataDictionary::FieldToName [private] |
Definition at line 61 of file DataDictionary.h.
typedef std::map< int, Values > FIX::DataDictionary::FieldToValue [private] |
Definition at line 60 of file DataDictionary.h.
typedef std::map< int, TYPE::Type > FIX::DataDictionary::FieldTypes [private] |
Definition at line 58 of file DataDictionary.h.
typedef std::set< int > FIX::DataDictionary::MsgFields [private] |
Definition at line 51 of file DataDictionary.h.
typedef std::set< std::string > FIX::DataDictionary::MsgTypes [private] |
Definition at line 53 of file DataDictionary.h.
typedef std::map< std::string, MsgFields > FIX::DataDictionary::MsgTypeToField [private] |
Definition at line 52 of file DataDictionary.h.
typedef std::map< std::string, int > FIX::DataDictionary::NameToField [private] |
Definition at line 62 of file DataDictionary.h.
typedef std::map< int, bool > FIX::DataDictionary::NonBodyFields [private] |
Definition at line 55 of file DataDictionary.h.
typedef std::vector< int > FIX::DataDictionary::OrderedFields [private] |
Definition at line 56 of file DataDictionary.h.
typedef int* FIX::DataDictionary::OrderedFieldsArray [private] |
Definition at line 57 of file DataDictionary.h.
typedef std::set< std::string > FIX::DataDictionary::Values [private] |
Definition at line 59 of file DataDictionary.h.
typedef std::map< std::pair < int, std::string > , std::string > FIX::DataDictionary::ValueToName [private] |
Definition at line 64 of file DataDictionary.h.
FIX::DataDictionary::DataDictionary | ( | ) |
Definition at line 48 of file DataDictionary.cpp.
00049 : m_hasVersion( false ), m_checkFieldsOutOfOrder( true ), 00050 m_checkFieldsHaveValues( true ), m_checkUserDefinedFields( true ), 00051 m_orderedFieldsArray(0) {}
FIX::DataDictionary::DataDictionary | ( | const DataDictionary & | copy | ) |
Definition at line 71 of file DataDictionary.cpp.
FIX::DataDictionary::DataDictionary | ( | std::istream & | stream | ) | throw ( ConfigError ) |
Definition at line 53 of file DataDictionary.cpp.
00055 : m_hasVersion( false ), m_checkFieldsOutOfOrder( true ), 00056 m_checkFieldsHaveValues( true ), m_checkUserDefinedFields( true ), 00057 m_orderedFieldsArray(0) 00058 { 00059 readFromStream( stream ); 00060 }
FIX::DataDictionary::DataDictionary | ( | const std::string & | url | ) | throw ( ConfigError ) |
Definition at line 62 of file DataDictionary.cpp.
00064 : m_hasVersion( false ), m_checkFieldsOutOfOrder( true ), 00065 m_checkFieldsHaveValues( true ), m_checkUserDefinedFields( true ), 00066 m_orderedFieldsArray(0) 00067 { 00068 readFromURL( url ); 00069 }
FIX::DataDictionary::~DataDictionary | ( | ) | [virtual] |
Definition at line 76 of file DataDictionary.cpp.
References m_groups, and m_orderedFieldsArray.
00077 { 00078 FieldToGroup::iterator i; 00079 for ( i = m_groups.begin(); i != m_groups.end(); ++i ) 00080 delete i->second.second; 00081 if( m_orderedFieldsArray ) 00082 delete [] m_orderedFieldsArray; 00083 }
void FIX::DataDictionary::addField | ( | int | field | ) | [inline] |
Definition at line 92 of file DataDictionary.h.
References m_fields, and m_orderedFields.
Referenced by addXMLComponentFields(), and addXMLGroup().
00093 { 00094 m_fields.insert( field ); 00095 m_orderedFields.push_back( field ); 00096 }
void FIX::DataDictionary::addFieldName | ( | int | field, | |
const std::string & | name | |||
) | [inline] |
Definition at line 98 of file DataDictionary.h.
References m_fieldNames, and m_names.
00099 { 00100 if( m_names.insert( std::make_pair(name, field) ).second == false ) 00101 throw ConfigError( "Field named " + name + " defined multiple times" ); 00102 m_fieldNames[field] = name; 00103 }
void FIX::DataDictionary::addFieldType | ( | int | field, | |
FIX::TYPE::Type | type | |||
) | [inline] |
Definition at line 181 of file DataDictionary.h.
References m_fieldTypes.
00182 { 00183 m_fieldTypes[ field ] = type; 00184 }
void FIX::DataDictionary::addFieldValue | ( | int | field, | |
const std::string & | value | |||
) | [inline] |
Definition at line 206 of file DataDictionary.h.
References m_fieldValues.
00207 { 00208 m_fieldValues[ field ].insert( value ); 00209 }
void FIX::DataDictionary::addGroup | ( | const std::string & | msg, | |
int | field, | |||
int | delim, | |||
const DataDictionary & | dataDictionary | |||
) | [inline] |
Definition at line 240 of file DataDictionary.h.
References getVersion(), m_groups, and setVersion().
Referenced by addXMLGroup(), and operator=().
00242 { 00243 DataDictionary * pDD = new DataDictionary; 00244 *pDD = dataDictionary; 00245 pDD->setVersion( getVersion() ); 00246 m_groups[ std::make_pair( msg, field ) ] = std::make_pair( delim, pDD ); 00247 }
void FIX::DataDictionary::addHeaderField | ( | int | field, | |
bool | required | |||
) | [inline] |
Definition at line 161 of file DataDictionary.h.
References m_headerFields.
00162 { 00163 m_headerFields[ field ] = required; 00164 }
void FIX::DataDictionary::addMsgField | ( | const std::string & | msgType, | |
int | field | |||
) | [inline] |
Definition at line 149 of file DataDictionary.h.
References m_messageFields.
Referenced by addXMLComponentFields().
00150 { 00151 m_messageFields[ msgType ].insert( field ); 00152 }
void FIX::DataDictionary::addMsgType | ( | const std::string & | msgType | ) | [inline] |
Definition at line 139 of file DataDictionary.h.
References m_messages.
00140 { 00141 m_messages.insert( msgType ); 00142 }
void FIX::DataDictionary::addRequiredField | ( | const std::string & | msgType, | |
int | field | |||
) | [inline] |
Definition at line 194 of file DataDictionary.h.
References m_requiredFields.
Referenced by addXMLComponentFields(), and addXMLGroup().
00195 { 00196 m_requiredFields[ msgType ].insert( field ); 00197 }
void FIX::DataDictionary::addTrailerField | ( | int | field, | |
bool | required | |||
) | [inline] |
Definition at line 171 of file DataDictionary.h.
References m_trailerFields.
00172 { 00173 m_trailerFields[ field ] = required; 00174 }
void FIX::DataDictionary::addValueName | ( | int | field, | |
const std::string & | value, | |||
const std::string & | name | |||
) | [inline] |
Definition at line 121 of file DataDictionary.h.
References m_valueNames.
00122 { 00123 m_valueNames[std::make_pair(field, value)] = name; 00124 }
int FIX::DataDictionary::addXMLComponentFields | ( | DOMDocument * | pDoc, | |
DOMNode * | pNode, | |||
const std::string & | msgtype, | |||
DataDictionary & | DD, | |||
bool | componentRequired | |||
) | [private] |
Definition at line 494 of file DataDictionary.cpp.
References addField(), addMsgField(), addRequiredField(), addXMLGroup(), FIX::DOMNode::getAttributes(), FIX::DOMDocument::getNode(), lookupXMLFieldNumber(), QF_STACK_POP, QF_STACK_PUSH, and RESET_AUTO_PTR.
Referenced by addXMLGroup().
00498 { QF_STACK_PUSH(DataDictionary::addXMLComponentFields) 00499 00500 int firstField = 0; 00501 00502 DOMAttributesPtr attrs = pNode->getAttributes(); 00503 std::string name; 00504 if(!attrs->get("name", name)) 00505 throw ConfigError("No name given to component"); 00506 00507 DOMNodePtr pComponentNode = 00508 pDoc->getNode("/fix/components/component[@name='" + name + "']"); 00509 if(pComponentNode.get() == 0) 00510 throw ConfigError("Component not found"); 00511 00512 DOMNodePtr pComponentFieldNode = pComponentNode->getFirstChildNode(); 00513 while(pComponentFieldNode.get()) 00514 { 00515 if(pComponentFieldNode->getName() == "field" 00516 || pComponentFieldNode->getName() == "group") 00517 { 00518 DOMAttributesPtr attrs = pComponentFieldNode->getAttributes(); 00519 std::string name; 00520 if(!attrs->get("name", name)) 00521 throw ConfigError("No name given to field"); 00522 int field = lookupXMLFieldNumber(pDoc, name); 00523 if( firstField == 0 ) firstField = field; 00524 00525 std::string required; 00526 if(attrs->get("required", required) 00527 && (required == "Y" || required =="y") 00528 && componentRequired) 00529 { 00530 addRequiredField(msgtype, field); 00531 } 00532 00533 DD.addField(field); 00534 DD.addMsgField(msgtype, field); 00535 } 00536 if(pComponentFieldNode->getName() == "component") 00537 { 00538 DOMAttributesPtr attrs = pComponentFieldNode->getAttributes(); 00539 std::string required; 00540 attrs->get("required", required); 00541 bool isRequired = (required == "Y" || required == "y"); 00542 addXMLComponentFields(pDoc, pComponentFieldNode.get(), 00543 msgtype, *this, isRequired); 00544 } 00545 if(pComponentFieldNode->getName() == "group") 00546 { 00547 DOMAttributesPtr attrs = pComponentFieldNode->getAttributes(); 00548 std::string required; 00549 attrs->get("required", required); 00550 bool isRequired = (required == "Y" || required == "y"); 00551 addXMLGroup(pDoc, pComponentFieldNode.get(), msgtype, DD, isRequired); 00552 } 00553 RESET_AUTO_PTR(pComponentFieldNode, 00554 pComponentFieldNode->getNextSiblingNode()); 00555 } 00556 return firstField; 00557 00558 QF_STACK_POP 00559 }
void FIX::DataDictionary::addXMLGroup | ( | DOMDocument * | pDoc, | |
DOMNode * | pNode, | |||
const std::string & | msgtype, | |||
DataDictionary & | DD, | |||
bool | groupRequired | |||
) | [private] |
Definition at line 561 of file DataDictionary.cpp.
References addField(), addGroup(), addRequiredField(), addXMLComponentFields(), FIX::DOMNode::getAttributes(), FIX::DOMNode::getFirstChildNode(), lookupXMLFieldNumber(), QF_STACK_POP, QF_STACK_PUSH, and RESET_AUTO_PTR.
Referenced by addXMLComponentFields().
00564 { QF_STACK_PUSH(DataDictionary::addXMLGroup) 00565 00566 DOMAttributesPtr attrs = pNode->getAttributes(); 00567 std::string name; 00568 if(!attrs->get("name", name)) 00569 throw ConfigError("No name given to group"); 00570 int group = lookupXMLFieldNumber( pDoc, name ); 00571 int delim = 0; 00572 int field = 0; 00573 DataDictionary groupDD; 00574 DOMNodePtr node = pNode->getFirstChildNode(); 00575 while(node.get()) 00576 { 00577 if( node->getName() == "field" ) 00578 { 00579 field = lookupXMLFieldNumber( pDoc, node.get() ); 00580 groupDD.addField( field ); 00581 00582 DOMAttributesPtr attrs = node->getAttributes(); 00583 std::string required; 00584 if( attrs->get("required", required) 00585 && ( required == "Y" || required =="y" ) 00586 && groupRequired ) 00587 { 00588 groupDD.addRequiredField(msgtype, field); 00589 } 00590 } 00591 else if( node->getName() == "component" ) 00592 { 00593 field = addXMLComponentFields( pDoc, node.get(), msgtype, groupDD, false ); 00594 } 00595 else if( node->getName() == "group" ) 00596 { 00597 field = lookupXMLFieldNumber( pDoc, node.get() ); 00598 groupDD.addField( field ); 00599 DOMAttributesPtr attrs = node->getAttributes(); 00600 std::string required; 00601 if( attrs->get("required", required ) 00602 && ( required == "Y" || required =="y" ) 00603 && groupRequired) 00604 { 00605 groupDD.addRequiredField(msgtype, field); 00606 } 00607 bool isRequired = false; 00608 if( attrs->get("required", required) ) 00609 isRequired = (required == "Y" || required == "y"); 00610 addXMLGroup( pDoc, node.get(), msgtype, groupDD, isRequired ); 00611 } 00612 if( delim == 0 ) delim = field; 00613 RESET_AUTO_PTR(node, node->getNextSiblingNode()); 00614 } 00615 00616 if( delim ) DD.addGroup( msgtype, group, delim, groupDD ); 00617 00618 QF_STACK_POP 00619 }
void FIX::DataDictionary::checkFieldsHaveValues | ( | bool | value | ) | [inline] |
Definition at line 283 of file DataDictionary.h.
References m_checkFieldsHaveValues.
00284 { m_checkFieldsHaveValues = value; }
void FIX::DataDictionary::checkFieldsOutOfOrder | ( | bool | value | ) | [inline] |
Definition at line 281 of file DataDictionary.h.
References m_checkFieldsOutOfOrder.
00282 { m_checkFieldsOutOfOrder = value; }
void FIX::DataDictionary::checkGroupCount | ( | const FieldBase & | field, | |
const FieldMap & | fieldMap, | |||
const MsgType & | msgType | |||
) | const throw ( RepeatingGroupCountMismatch ) [inline, private] |
Check if group count matches number of groups in.
Definition at line 433 of file DataDictionary.h.
References FIX::IntConvertor::convert(), FIX::FieldBase::getField(), FIX::FieldBase::getString(), FIX::FieldMap::groupCount(), and isGroup().
Referenced by iterate().
00435 { 00436 int fieldNum = field.getField(); 00437 if( isGroup(msgType, fieldNum) ) 00438 { 00439 if( fieldMap.groupCount(fieldNum) 00440 != IntConvertor::convert(field.getString()) ) 00441 throw RepeatingGroupCountMismatch(fieldNum); 00442 } 00443 }
void FIX::DataDictionary::checkHasRequired | ( | const FieldMap & | header, | |
const FieldMap & | body, | |||
const FieldMap & | trailer, | |||
const MsgType & | msgType | |||
) | const throw ( RequiredTagMissing ) [inline, private] |
Check if a message has all required fields.
Definition at line 447 of file DataDictionary.h.
References checkHasRequired(), FIX::FieldMap::g_begin(), FIX::FieldMap::g_end(), getGroup(), FIX::FieldMap::isSetField(), m_headerFields, m_requiredFields, and m_trailerFields.
Referenced by checkHasRequired().
00450 { 00451 NonBodyFields::const_iterator iNBF; 00452 for( iNBF = m_headerFields.begin(); iNBF != m_headerFields.end(); ++iNBF ) 00453 { 00454 if( iNBF->second == true && !header.isSetField(iNBF->first) ) 00455 throw RequiredTagMissing( iNBF->first ); 00456 } 00457 00458 for( iNBF = m_trailerFields.begin(); iNBF != m_trailerFields.end(); ++iNBF ) 00459 { 00460 if( iNBF->second == true && !trailer.isSetField(iNBF->first) ) 00461 throw RequiredTagMissing( iNBF->first ); 00462 } 00463 00464 MsgTypeToField::const_iterator iM 00465 = m_requiredFields.find( msgType.getString() ); 00466 if ( iM == m_requiredFields.end() ) return ; 00467 00468 const MsgFields& fields = iM->second; 00469 MsgFields::const_iterator iF; 00470 for( iF = fields.begin(); iF != fields.end(); ++iF ) 00471 { 00472 if( !body.isSetField(*iF) ) 00473 throw RequiredTagMissing( *iF ); 00474 } 00475 00476 FieldMap::g_iterator groups; 00477 for( groups = body.g_begin(); groups != body.g_end(); ++groups ) 00478 { 00479 int delim; 00480 const DataDictionary* DD = 0; 00481 int field = groups->first; 00482 if( getGroup( msgType.getValue(), field, delim, DD ) ) 00483 { 00484 std::vector<FieldMap*>::const_iterator group; 00485 for( group = groups->second.begin(); group != groups->second.end(); ++group ) 00486 DD->checkHasRequired( **group, **group, **group, msgType ); 00487 } 00488 } 00489 }
void FIX::DataDictionary::checkHasValue | ( | const FieldBase & | field | ) | const throw ( NoTagValue ) [inline, private] |
Check if a field has a value.
Definition at line 415 of file DataDictionary.h.
References m_checkFieldsHaveValues.
Referenced by iterate().
00417 { 00418 if ( m_checkFieldsHaveValues && !field.getString().length() ) 00419 throw NoTagValue( field.getField() ); 00420 }
void FIX::DataDictionary::checkIsInMessage | ( | const FieldBase & | field, | |
const MsgType & | msgType | |||
) | const throw ( TagNotDefinedForMessage ) [inline, private] |
Check if a field is in this message type.
Definition at line 424 of file DataDictionary.h.
References FIX::FieldBase::getField(), and isMsgField().
Referenced by iterate().
00426 { 00427 if ( !isMsgField( msgType, field.getField() ) ) 00428 throw TagNotDefinedForMessage( field.getField() ); 00429 }
void FIX::DataDictionary::checkMsgType | ( | const MsgType & | msgType | ) | const [inline, private] |
Check if message type is defined in spec.
Definition at line 305 of file DataDictionary.h.
References isMsgType().
00306 { 00307 if ( !isMsgType( msgType.getValue() ) ) 00308 throw InvalidMessageType(); 00309 }
void FIX::DataDictionary::checkUserDefinedFields | ( | bool | value | ) | [inline] |
Definition at line 285 of file DataDictionary.h.
References m_checkUserDefinedFields.
00286 { m_checkUserDefinedFields = value; }
void FIX::DataDictionary::checkValidFormat | ( | const FieldBase & | field | ) | const throw ( IncorrectDataFormat ) [inline, private] |
Definition at line 328 of file DataDictionary.h.
References FIX::TYPE::Amt, FIX::TYPE::Boolean, FIX::TYPE::Char, FIX::UtcTimeOnlyConvertor::convert(), FIX::UtcDateConvertor::convert(), FIX::BoolConvertor::convert(), FIX::UtcTimeStampConvertor::convert(), FIX::IntConvertor::convert(), FIX::DoubleConvertor::convert(), FIX::CharConvertor::convert(), FIX::EmptyConvertor::convert(), FIX::TYPE::Country, FIX::TYPE::Currency, FIX::TYPE::Data, FIX::TYPE::DayOfMonth, FIX::TYPE::Exchange, FIX::TYPE::Float, getFieldType(), FIX::TYPE::Int, FIX::TYPE::Language, FIX::TYPE::Length, FIX::TYPE::LocalMktDate, FIX::TYPE::MonthYear, FIX::TYPE::MultipleCharValue, FIX::TYPE::MultipleStringValue, FIX::TYPE::MultipleValueString, FIX::TYPE::NumInGroup, FIX::TYPE::Percentage, FIX::TYPE::Price, FIX::TYPE::PriceOffset, FIX::TYPE::Qty, FIX::TYPE::SeqNum, FIX::TYPE::String, FIX::TYPE::TzTimeOnly, FIX::TYPE::TzTimeStamp, FIX::TYPE::Unknown, FIX::TYPE::UtcDate, FIX::TYPE::UtcTimeOnly, FIX::TYPE::UtcTimeStamp, and FIX::TYPE::XmlData.
Referenced by iterate().
00330 { 00331 try 00332 { 00333 TYPE::Type type = TYPE::Unknown; 00334 getFieldType( field.getField(), type ); 00335 switch ( type ) 00336 { 00337 case TYPE::String: 00338 STRING_CONVERTOR::convert( field.getString() ); break; 00339 case TYPE::Char: 00340 CHAR_CONVERTOR::convert( field.getString() ); break; 00341 case TYPE::Price: 00342 PRICE_CONVERTOR::convert( field.getString() ); break; 00343 case TYPE::Int: 00344 INT_CONVERTOR::convert( field.getString() ); break; 00345 case TYPE::Amt: 00346 AMT_CONVERTOR::convert( field.getString() ); break; 00347 case TYPE::Qty: 00348 QTY_CONVERTOR::convert( field.getString() ); break; 00349 case TYPE::Currency: 00350 CURRENCY_CONVERTOR::convert( field.getString() ); break; 00351 case TYPE::MultipleValueString: 00352 MULTIPLEVALUESTRING_CONVERTOR::convert( field.getString() ); break; 00353 case TYPE::MultipleStringValue: 00354 MULTIPLESTRINGVALUE_CONVERTOR::convert( field.getString() ); break; 00355 case TYPE::MultipleCharValue: 00356 MULTIPLECHARVALUE_CONVERTOR::convert( field.getString() ); break; 00357 case TYPE::Exchange: 00358 EXCHANGE_CONVERTOR::convert( field.getString() ); break; 00359 case TYPE::UtcTimeStamp: 00360 UTCTIMESTAMP_CONVERTOR::convert( field.getString() ); break; 00361 case TYPE::Boolean: 00362 BOOLEAN_CONVERTOR::convert( field.getString() ); break; 00363 case TYPE::LocalMktDate: 00364 LOCALMKTDATE_CONVERTOR::convert( field.getString() ); break; 00365 case TYPE::Data: 00366 DATA_CONVERTOR::convert( field.getString() ); break; 00367 case TYPE::Float: 00368 FLOAT_CONVERTOR::convert( field.getString() ); break; 00369 case TYPE::PriceOffset: 00370 PRICEOFFSET_CONVERTOR::convert( field.getString() ); break; 00371 case TYPE::MonthYear: 00372 MONTHYEAR_CONVERTOR::convert( field.getString() ); break; 00373 case TYPE::DayOfMonth: 00374 DAYOFMONTH_CONVERTOR::convert( field.getString() ); break; 00375 case TYPE::UtcDate: 00376 UTCDATE_CONVERTOR::convert( field.getString() ); break; 00377 case TYPE::UtcTimeOnly: 00378 UTCTIMEONLY_CONVERTOR::convert( field.getString() ); break; 00379 case TYPE::NumInGroup: 00380 NUMINGROUP_CONVERTOR::convert( field.getString() ); break; 00381 case TYPE::Percentage: 00382 PERCENTAGE_CONVERTOR::convert( field.getString() ); break; 00383 case TYPE::SeqNum: 00384 SEQNUM_CONVERTOR::convert( field.getString() ); break; 00385 case TYPE::Length: 00386 LENGTH_CONVERTOR::convert( field.getString() ); break; 00387 case TYPE::Country: 00388 COUNTRY_CONVERTOR::convert( field.getString() ); break; 00389 case TYPE::TzTimeOnly: 00390 TZTIMEONLY_CONVERTOR::convert( field.getString() ); break; 00391 case TYPE::TzTimeStamp: 00392 TZTIMESTAMP_CONVERTOR::convert( field.getString() ); break; 00393 case TYPE::XmlData: 00394 XMLDATA_CONVERTOR::convert( field.getString() ); break; 00395 case TYPE::Language: 00396 LANGUAGE_CONVERTOR::convert( field.getString() ); break; 00397 case TYPE::Unknown: break; 00398 } 00399 } 00400 catch ( FieldConvertError& ) 00401 { throw IncorrectDataFormat( field.getField(), field.getString() ); } 00402 }
void FIX::DataDictionary::checkValidTagNumber | ( | const FieldBase & | field | ) | const throw ( InvalidTagNumber ) [inline, private] |
void FIX::DataDictionary::checkValue | ( | const FieldBase & | field | ) | const throw ( IncorrectTagValue ) [inline, private] |
Definition at line 404 of file DataDictionary.h.
References hasFieldValue(), and isFieldValue().
Referenced by iterate().
00406 { 00407 if ( !hasFieldValue( field.getField() ) ) return ; 00408 00409 const std::string& value = field.getString(); 00410 if ( !isFieldValue( field.getField(), value ) ) 00411 throw IncorrectTagValue( field.getField() ); 00412 }
bool FIX::DataDictionary::getFieldName | ( | int | field, | |
std::string & | name | |||
) | const [inline] |
Definition at line 105 of file DataDictionary.h.
References m_fieldNames.
00106 { 00107 FieldToName::const_iterator i = m_fieldNames.find( field ); 00108 if(i == m_fieldNames.end()) return false; 00109 name = i->second; 00110 return true; 00111 }
bool FIX::DataDictionary::getFieldTag | ( | std::string | name, | |
int & | field | |||
) | const [inline] |
Definition at line 113 of file DataDictionary.h.
References m_names.
bool FIX::DataDictionary::getFieldType | ( | int | field, | |
FIX::TYPE::Type & | type | |||
) | const [inline] |
Definition at line 186 of file DataDictionary.h.
References m_fieldTypes.
Referenced by checkValidFormat().
00187 { 00188 FieldTypes::const_iterator i = m_fieldTypes.find( field ); 00189 if ( i == m_fieldTypes.end() ) return false; 00190 type = i->second; 00191 return true; 00192 }
bool FIX::DataDictionary::getGroup | ( | const std::string & | msg, | |
int | field, | |||
int & | delim, | |||
const DataDictionary *& | pDataDictionary | |||
) | const [inline] |
Definition at line 254 of file DataDictionary.h.
References m_groups.
Referenced by checkHasRequired(), and FIX::Message::setGroup().
int * FIX::DataDictionary::getOrderedFields | ( | ) | const |
Definition at line 455 of file DataDictionary.cpp.
References m_orderedFields, m_orderedFieldsArray, QF_STACK_POP, and QF_STACK_PUSH.
Referenced by FIX::Message::setGroup().
00456 { QF_STACK_PUSH(DataDictionary::getOrderedFields) 00457 00458 if( m_orderedFieldsArray ) return m_orderedFieldsArray; 00459 m_orderedFieldsArray = new int[m_orderedFields.size() + 1]; 00460 00461 int* i = m_orderedFieldsArray; 00462 OrderedFields::const_iterator iter; 00463 for( iter = m_orderedFields.begin(); iter != m_orderedFields.end(); *(i++) = *(iter++) ) {} 00464 *i = 0; 00465 return m_orderedFieldsArray; 00466 00467 QF_STACK_POP 00468 }
bool FIX::DataDictionary::getValueName | ( | int | field, | |
const std::string & | value, | |||
std::string & | name | |||
) | const [inline] |
Definition at line 126 of file DataDictionary.h.
References m_valueNames.
00127 { 00128 ValueToName::const_iterator i = m_valueNames.find( std::make_pair(field, value) ); 00129 if(i == m_valueNames.end()) return false; 00130 name = i->second; 00131 return true; 00132 }
std::string FIX::DataDictionary::getVersion | ( | ) | const [inline] |
Definition at line 87 of file DataDictionary.h.
References m_beginString.
Referenced by addGroup().
00088 { 00089 return m_beginString.getString(); 00090 }
bool FIX::DataDictionary::hasFieldValue | ( | int | field | ) | const [inline] |
Definition at line 211 of file DataDictionary.h.
References m_fieldValues.
Referenced by checkValue().
00212 { 00213 FieldToValue::const_iterator i = m_fieldValues.find( field ); 00214 return i != m_fieldValues.end(); 00215 }
bool FIX::DataDictionary::isDataField | ( | int | field | ) | const [inline] |
Definition at line 266 of file DataDictionary.h.
References FIX::TYPE::Data, and m_fieldTypes.
00267 { 00268 FieldTypes::const_iterator i = m_fieldTypes.find( field ); 00269 return i != m_fieldTypes.end() && i->second == TYPE::Data; 00270 }
bool FIX::DataDictionary::isField | ( | int | field | ) | const [inline] |
Definition at line 134 of file DataDictionary.h.
References m_fields.
Referenced by FIX::Message::setGroup().
bool FIX::DataDictionary::isFieldValue | ( | int | field, | |
const std::string & | value | |||
) | const [inline] |
Definition at line 217 of file DataDictionary.h.
References isMultipleValueField(), and m_fieldValues.
Referenced by checkValue().
00218 { 00219 FieldToValue::const_iterator i = m_fieldValues.find( field ); 00220 if ( i == m_fieldValues.end() ) 00221 return false; 00222 if( !isMultipleValueField( field ) ) 00223 return i->second.find( value ) != i->second.end(); 00224 00225 // MultipleValue 00226 std::string::size_type startPos = 0; 00227 std::string::size_type endPos = 0; 00228 do 00229 { 00230 endPos = value.find_first_of(' ', startPos); 00231 std::string singleValue = 00232 value.substr( startPos, endPos - startPos ); 00233 if( i->second.find( singleValue ) == i->second.end() ) 00234 return false; 00235 startPos = endPos + 1; 00236 } while( endPos != std::string::npos ); 00237 return true; 00238 }
bool FIX::DataDictionary::isGroup | ( | const std::string & | msg, | |
int | field | |||
) | const [inline] |
Definition at line 249 of file DataDictionary.h.
References m_groups.
Referenced by checkGroupCount().
bool FIX::DataDictionary::isHeaderField | ( | int | field | ) | const [inline] |
Definition at line 166 of file DataDictionary.h.
References m_headerFields.
Referenced by FIX::Message::isHeaderField().
00167 { 00168 return m_headerFields.find( field ) != m_headerFields.end(); 00169 }
bool FIX::DataDictionary::isMsgField | ( | const std::string & | msgType, | |
int | field | |||
) | const [inline] |
Definition at line 154 of file DataDictionary.h.
References m_messageFields.
Referenced by checkIsInMessage().
00155 { 00156 MsgTypeToField::const_iterator i = m_messageFields.find( msgType ); 00157 if ( i == m_messageFields.end() ) return false; 00158 return i->second.find( field ) != i->second.end(); 00159 }
bool FIX::DataDictionary::isMsgType | ( | const std::string & | msgType | ) | const [inline] |
Definition at line 144 of file DataDictionary.h.
References m_messages.
Referenced by checkMsgType().
00145 { 00146 return m_messages.find( msgType ) != m_messages.end(); 00147 }
bool FIX::DataDictionary::isMultipleValueField | ( | int | field | ) | const [inline] |
Definition at line 272 of file DataDictionary.h.
References m_fieldTypes, FIX::TYPE::MultipleCharValue, FIX::TYPE::MultipleStringValue, and FIX::TYPE::MultipleValueString.
Referenced by isFieldValue().
00273 { 00274 FieldTypes::const_iterator i = m_fieldTypes.find( field ); 00275 return i != m_fieldTypes.end() 00276 && (i->second == TYPE::MultipleValueString 00277 || i->second == TYPE::MultipleCharValue 00278 || i->second == TYPE::MultipleStringValue ); 00279 }
bool FIX::DataDictionary::isRequiredField | ( | const std::string & | msgType, | |
int | field | |||
) | const [inline] |
Definition at line 199 of file DataDictionary.h.
References m_requiredFields.
00200 { 00201 MsgTypeToField::const_iterator i = m_requiredFields.find( msgType ); 00202 if ( i == m_requiredFields.end() ) return false; 00203 return i->second.find( field ) != i->second.end(); 00204 }
bool FIX::DataDictionary::isTrailerField | ( | int | field | ) | const [inline] |
Definition at line 176 of file DataDictionary.h.
References m_trailerFields.
Referenced by FIX::Message::isTrailerField().
00177 { 00178 return m_trailerFields.find( field ) != m_trailerFields.end(); 00179 }
void FIX::DataDictionary::iterate | ( | const FieldMap & | map, | |
const MsgType & | msgType | |||
) | const [private] |
Iterate through fields while applying checks.
Definition at line 161 of file DataDictionary.cpp.
References FIX::FieldMap::begin(), checkGroupCount(), checkHasValue(), checkIsInMessage(), checkValidFormat(), checkValidTagNumber(), checkValue(), FIX::FieldMap::end(), FIX::FieldBase::getField(), FIX::Message::isHeaderField(), FIX::Message::isTrailerField(), m_beginString, m_hasVersion, QF_STACK_POP, QF_STACK_PUSH, and shouldCheckTag().
00162 { QF_STACK_PUSH(DataDictionary::iterate) 00163 00164 int lastField = 0; 00165 00166 FieldMap::iterator i; 00167 for ( i = map.begin(); i != map.end(); ++i ) 00168 { 00169 const FieldBase& field = i->second; 00170 if( i != map.begin() && (field.getField() == lastField) ) 00171 throw RepeatedTag( lastField ); 00172 checkHasValue( field ); 00173 00174 if ( m_hasVersion ) 00175 { 00176 checkValidFormat( field ); 00177 checkValue( field ); 00178 } 00179 00180 if ( m_beginString.getValue().length() && shouldCheckTag(field) ) 00181 { 00182 checkValidTagNumber( field ); 00183 if ( !Message::isHeaderField( field, this ) 00184 && !Message::isTrailerField( field, this ) ) 00185 { 00186 checkIsInMessage( field, msgType ); 00187 checkGroupCount( field, map, msgType ); 00188 } 00189 } 00190 lastField = field.getField(); 00191 } 00192 00193 QF_STACK_POP 00194 }
int FIX::DataDictionary::lookupXMLFieldNumber | ( | DOMDocument * | pDoc, | |
const std::string & | name | |||
) | const [private] |
Definition at line 483 of file DataDictionary.cpp.
References lookupXMLFieldNumber(), QF_STACK_POP, and QF_STACK_PUSH.
00484 { QF_STACK_PUSH(DataDictionary::lookupXMLFieldNumber) 00485 00486 NameToField::const_iterator i = m_names.find(name); 00487 if( i == m_names.end() ) 00488 throw ConfigError("Field " + name + " not defined in fields section"); 00489 return i->second; 00490 00491 QF_STACK_POP 00492 }
int FIX::DataDictionary::lookupXMLFieldNumber | ( | DOMDocument * | pDoc, | |
DOMNode * | pNode | |||
) | const [private] |
Definition at line 470 of file DataDictionary.cpp.
References FIX::DOMNode::getAttributes(), QF_STACK_POP, and QF_STACK_PUSH.
Referenced by addXMLComponentFields(), addXMLGroup(), and lookupXMLFieldNumber().
00471 { QF_STACK_PUSH(DataDictionary::lookupXMLFieldNumber) 00472 00473 DOMAttributesPtr attrs = pNode->getAttributes(); 00474 std::string name; 00475 if(!attrs->get("name", name)) 00476 throw ConfigError("No name given to field"); 00477 return lookupXMLFieldNumber( pDoc, name ); 00478 00479 QF_STACK_POP 00480 }
DataDictionary & FIX::DataDictionary::operator= | ( | const DataDictionary & | rhs | ) |
Definition at line 85 of file DataDictionary.cpp.
References addGroup(), m_beginString, m_checkFieldsHaveValues, m_checkFieldsOutOfOrder, m_checkUserDefinedFields, m_fieldNames, m_fields, m_fieldTypes, m_fieldValues, m_groups, m_hasVersion, m_headerFields, m_messageFields, m_messages, m_names, m_orderedFields, m_orderedFieldsArray, m_requiredFields, m_trailerFields, m_valueNames, QF_STACK_POP, and QF_STACK_PUSH.
00086 { QF_STACK_PUSH(DataDictionary::operator=) 00087 00088 m_hasVersion = rhs.m_hasVersion; 00089 m_checkFieldsOutOfOrder = rhs.m_checkFieldsOutOfOrder; 00090 m_checkFieldsHaveValues = rhs.m_checkFieldsHaveValues; 00091 m_checkUserDefinedFields = rhs.m_checkUserDefinedFields; 00092 m_beginString = rhs.m_beginString; 00093 m_messageFields = rhs.m_messageFields; 00094 m_requiredFields = rhs.m_requiredFields; 00095 m_messages = rhs.m_messages; 00096 m_fields = rhs.m_fields; 00097 m_orderedFields = rhs.m_orderedFields; 00098 m_orderedFieldsArray = 0; 00099 m_headerFields = rhs.m_headerFields; 00100 m_trailerFields = rhs.m_trailerFields; 00101 m_fieldTypes = rhs.m_fieldTypes; 00102 m_fieldValues = rhs.m_fieldValues; 00103 m_fieldNames = rhs.m_fieldNames; 00104 m_names = rhs.m_names; 00105 m_valueNames = rhs.m_valueNames; 00106 00107 FieldToGroup::const_iterator i = rhs.m_groups.begin(); 00108 for ( ; i != rhs.m_groups.end(); ++i ) 00109 { 00110 addGroup( i->first.first, i->first.second, 00111 i->second.first, *i->second.second ); 00112 } 00113 return *this; 00114 00115 QF_STACK_POP 00116 }
void FIX::DataDictionary::readFromDocument | ( | DOMDocumentPtr | pDoc | ) | throw ( ConfigError ) |
Definition at line 243 of file DataDictionary.cpp.
References QF_STACK_POP, QF_STACK_PUSH, and RESET_AUTO_PTR.
00245 { QF_STACK_PUSH(DataDictionary::readFromDocument) 00246 00247 // VERSION 00248 DOMNodePtr pFixNode = pDoc->getNode("/fix"); 00249 if(!pFixNode.get()) 00250 throw ConfigError("Could not parse data dictionary file" 00251 ", or no <fix> node found at root"); 00252 DOMAttributesPtr attrs = pFixNode->getAttributes(); 00253 std::string type = "FIX"; 00254 if(attrs->get("type", type)) 00255 { 00256 if(type != "FIX" && type != "FIXT") 00257 throw ConfigError("type attribute must be FIX or FIXT"); 00258 } 00259 std::string major; 00260 if(!attrs->get("major", major)) 00261 throw ConfigError("major attribute not found on <fix>"); 00262 std::string minor; 00263 if(!attrs->get("minor", minor)) 00264 throw ConfigError("minor attribute not found on <fix>"); 00265 setVersion(type + "." + major + "." + minor); 00266 00267 // FIELDS 00268 DOMNodePtr pFieldsNode = pDoc->getNode("/fix/fields"); 00269 if(!pFieldsNode.get()) 00270 throw ConfigError("<fields> section not found in data dictionary"); 00271 00272 DOMNodePtr pFieldNode = pFieldsNode->getFirstChildNode(); 00273 if(!pFieldNode.get()) throw ConfigError("No fields defined"); 00274 00275 while(pFieldNode.get()) 00276 { 00277 if(pFieldNode->getName() == "field") 00278 { 00279 DOMAttributesPtr attrs = pFieldNode->getAttributes(); 00280 std::string name; 00281 if(!attrs->get("name", name)) 00282 throw ConfigError("<field> does not have a name attribute"); 00283 std::string number; 00284 if(!attrs->get("number", number)) 00285 throw ConfigError("<field> " + name + " does not have a number attribute"); 00286 int num = atol(number.c_str()); 00287 std::string type; 00288 if(!attrs->get("type", type)) 00289 throw ConfigError("<field> " + name + " does not have a type attribute"); 00290 addField(num); 00291 addFieldType(num, XMLTypeToType(type)); 00292 addFieldName(num, name); 00293 00294 DOMNodePtr pFieldValueNode = pFieldNode->getFirstChildNode(); 00295 while(pFieldValueNode.get()) 00296 { 00297 if(pFieldValueNode->getName() == "value") 00298 { 00299 DOMAttributesPtr attrs = pFieldValueNode->getAttributes(); 00300 std::string enumeration; 00301 if(!attrs->get("enum", enumeration)) 00302 throw ConfigError("<value> does not have enum attribute in field " + name); 00303 addFieldValue(num, enumeration); 00304 std::string description; 00305 if(attrs->get("description", description)) 00306 addValueName(num, enumeration, description); 00307 } 00308 RESET_AUTO_PTR(pFieldValueNode, pFieldValueNode->getNextSiblingNode()); 00309 } 00310 } 00311 RESET_AUTO_PTR(pFieldNode, pFieldNode->getNextSiblingNode()); 00312 } 00313 00314 // HEADER 00315 if( type == "FIXT" || (type == "FIX" && major < "5") ) 00316 { 00317 DOMNodePtr pHeaderNode = pDoc->getNode("/fix/header"); 00318 if(!pHeaderNode.get()) 00319 throw ConfigError("<header> section not found in data dictionary"); 00320 00321 DOMNodePtr pHeaderFieldNode = pHeaderNode->getFirstChildNode(); 00322 if(!pHeaderFieldNode.get()) throw ConfigError("No header fields defined"); 00323 00324 while(pHeaderFieldNode.get()) 00325 { 00326 if(pHeaderFieldNode->getName() == "field" || pHeaderFieldNode->getName() == "group" ) 00327 { 00328 DOMAttributesPtr attrs = pHeaderFieldNode->getAttributes(); 00329 std::string name; 00330 if(!attrs->get("name", name)) 00331 throw ConfigError("<field> does not have a name attribute"); 00332 std::string required = "false"; 00333 attrs->get("required", required); 00334 addHeaderField(lookupXMLFieldNumber(pDoc.get(), name), required == "true"); 00335 } 00336 if(pHeaderFieldNode->getName() == "group") 00337 { 00338 DOMAttributesPtr attrs = pHeaderFieldNode->getAttributes(); 00339 std::string required; 00340 attrs->get("required", required); 00341 bool isRequired = (required == "Y" || required == "y"); 00342 addXMLGroup(pDoc.get(), pHeaderFieldNode.get(), "_header_", *this, isRequired); 00343 } 00344 00345 RESET_AUTO_PTR(pHeaderFieldNode, pHeaderFieldNode->getNextSiblingNode()); 00346 } 00347 } 00348 00349 // TRAILER 00350 if( type == "FIXT" || (type == "FIX" && major < "5") ) 00351 { 00352 DOMNodePtr pTrailerNode = pDoc->getNode("/fix/trailer"); 00353 if(!pTrailerNode.get()) 00354 throw ConfigError("<trailer> section not found in data dictionary"); 00355 00356 DOMNodePtr pTrailerFieldNode = pTrailerNode->getFirstChildNode(); 00357 if(!pTrailerFieldNode.get()) throw ConfigError("No trailer fields defined"); 00358 00359 while(pTrailerFieldNode.get()) 00360 { 00361 if(pTrailerFieldNode->getName() == "field" || pTrailerFieldNode->getName() == "group" ) 00362 { 00363 DOMAttributesPtr attrs = pTrailerFieldNode->getAttributes(); 00364 std::string name; 00365 if(!attrs->get("name", name)) 00366 throw ConfigError("<field> does not have a name attribute"); 00367 std::string required = "false"; 00368 attrs->get("required", required); 00369 addTrailerField(lookupXMLFieldNumber(pDoc.get(), name), required == "true"); 00370 } 00371 if(pTrailerFieldNode->getName() == "group") 00372 { 00373 DOMAttributesPtr attrs = pTrailerFieldNode->getAttributes(); 00374 std::string required; 00375 attrs->get("required", required); 00376 bool isRequired = (required == "Y" || required == "y"); 00377 addXMLGroup(pDoc.get(), pTrailerFieldNode.get(), "_trailer_", *this, isRequired); 00378 } 00379 00380 RESET_AUTO_PTR(pTrailerFieldNode, pTrailerFieldNode->getNextSiblingNode()); 00381 } 00382 } 00383 00384 // MSGTYPE 00385 DOMNodePtr pMessagesNode = pDoc->getNode("/fix/messages"); 00386 if(!pMessagesNode.get()) 00387 throw ConfigError("<messages> section not found in data dictionary"); 00388 00389 DOMNodePtr pMessageNode = pMessagesNode->getFirstChildNode(); 00390 if(!pMessageNode.get()) throw ConfigError("No messages defined"); 00391 00392 while(pMessageNode.get()) 00393 { 00394 if(pMessageNode->getName() == "message") 00395 { 00396 DOMAttributesPtr attrs = pMessageNode->getAttributes(); 00397 std::string msgtype; 00398 if(!attrs->get("msgtype", msgtype)) 00399 throw ConfigError("<field> does not have a name attribute"); 00400 addMsgType(msgtype); 00401 00402 std::string name; 00403 if(attrs->get("name", name)) 00404 addValueName( 35, msgtype, name ); 00405 00406 DOMNodePtr pMessageFieldNode = pMessageNode->getFirstChildNode(); 00407 if( !pMessageFieldNode.get() ) 00408 throw ConfigError("<message> contains no fields"); 00409 while( pMessageFieldNode.get() ) 00410 { 00411 if(pMessageFieldNode->getName() == "field" 00412 || pMessageFieldNode->getName() == "group") 00413 { 00414 DOMAttributesPtr attrs = pMessageFieldNode->getAttributes(); 00415 std::string name; 00416 if(!attrs->get("name", name)) 00417 throw ConfigError("<field> does not have a name attribute"); 00418 int num = lookupXMLFieldNumber(pDoc.get(), name); 00419 addMsgField(msgtype, num); 00420 00421 std::string required; 00422 if(attrs->get("required", required) 00423 && (required == "Y" || required == "y")) 00424 { 00425 addRequiredField(msgtype, num); 00426 } 00427 } 00428 else if(pMessageFieldNode->getName() == "component") 00429 { 00430 DOMAttributesPtr attrs = pMessageFieldNode->getAttributes(); 00431 std::string required; 00432 attrs->get("required", required); 00433 bool isRequired = (required == "Y" || required == "y"); 00434 addXMLComponentFields(pDoc.get(), pMessageFieldNode.get(), 00435 msgtype, *this, isRequired); 00436 } 00437 if(pMessageFieldNode->getName() == "group") 00438 { 00439 DOMAttributesPtr attrs = pMessageFieldNode->getAttributes(); 00440 std::string required; 00441 attrs->get("required", required); 00442 bool isRequired = (required == "Y" || required == "y"); 00443 addXMLGroup(pDoc.get(), pMessageFieldNode.get(), msgtype, *this, isRequired); 00444 } 00445 RESET_AUTO_PTR(pMessageFieldNode, 00446 pMessageFieldNode->getNextSiblingNode()); 00447 } 00448 } 00449 RESET_AUTO_PTR(pMessageNode, pMessageNode->getNextSiblingNode()); 00450 } 00451 00452 QF_STACK_POP 00453 }
void FIX::DataDictionary::readFromStream | ( | std::istream & | stream | ) | throw ( ConfigError ) |
Definition at line 223 of file DataDictionary.cpp.
References QF_STACK_POP, and QF_STACK_PUSH.
00225 { QF_STACK_PUSH(DataDictionary::readFromStream) 00226 00227 #ifdef HAVE_LIBXML 00228 DOMDocumentPtr pDoc = DOMDocumentPtr(new LIBXML_DOMDocument()); 00229 #elif _MSC_VER 00230 DOMDocumentPtr pDoc = DOMDocumentPtr(new MSXML_DOMDocument()); 00231 #else 00232 DOMDocumentPtr pDoc = DOMDocumentPtr(new LIBXML_DOMDocument()); 00233 #endif 00234 00235 if(!pDoc->load(stream)) 00236 throw ConfigError("Could not parse data dictionary stream"); 00237 00238 readFromDocument( pDoc ); 00239 00240 QF_STACK_POP 00241 }
void FIX::DataDictionary::readFromURL | ( | const std::string & | url | ) | throw ( ConfigError ) |
Definition at line 196 of file DataDictionary.cpp.
References QF_STACK_POP, and QF_STACK_PUSH.
00198 { QF_STACK_PUSH(DataDictionary::readFromURL) 00199 00200 #ifdef HAVE_LIBXML 00201 DOMDocumentPtr pDoc = DOMDocumentPtr(new LIBXML_DOMDocument()); 00202 #elif _MSC_VER 00203 DOMDocumentPtr pDoc = DOMDocumentPtr(new MSXML_DOMDocument()); 00204 #else 00205 DOMDocumentPtr pDoc = DOMDocumentPtr(new LIBXML_DOMDocument()); 00206 #endif 00207 00208 if(!pDoc->load(url)) 00209 throw ConfigError(url + ": Could not parse data dictionary file"); 00210 00211 try 00212 { 00213 readFromDocument( pDoc ); 00214 } 00215 catch( ConfigError& e ) 00216 { 00217 throw ConfigError( url + ": " + e.what() ); 00218 } 00219 00220 QF_STACK_POP 00221 }
void FIX::DataDictionary::readLibXml | ( | const std::string & | ) | [private] |
Read XML file using libXML.
void FIX::DataDictionary::readMSXML | ( | const std::string & | ) | [private] |
void FIX::DataDictionary::readMSXMLDOM | ( | const std::string & | ) | [private] |
Read XML file using MSXML.
void FIX::DataDictionary::setVersion | ( | const std::string & | beginString | ) | [inline] |
Definition at line 82 of file DataDictionary.h.
References m_beginString, and m_hasVersion.
Referenced by addGroup().
00083 { 00084 m_beginString = beginString; 00085 m_hasVersion = true; 00086 }
bool FIX::DataDictionary::shouldCheckTag | ( | const FieldBase & | field | ) | const [inline, private] |
If we need to check for the tag in the dictionary.
Definition at line 312 of file DataDictionary.h.
References FIX::FieldBase::getField(), m_checkUserDefinedFields, and FIX::FIELD::UserMin.
Referenced by iterate().
00313 { 00314 if( !m_checkUserDefinedFields && field.getField() >= FIELD::UserMin ) 00315 return false; 00316 else 00317 return true; 00318 }
void FIX::DataDictionary::validate | ( | const Message & | message, | |
bool | bodyOnly | |||
) | const throw ( FIX::Exception ) [inline] |
Definition at line 295 of file DataDictionary.h.
References validate().
Referenced by validate().
00296 { validate( message, bodyOnly ? (DataDictionary*)0 : this, this ); }
void FIX::DataDictionary::validate | ( | const Message & | message | ) | const throw ( FIX::Exception ) [inline] |
Definition at line 293 of file DataDictionary.h.
References validate().
Referenced by validate().
00294 { validate( message, false ); }
void FIX::DataDictionary::validate | ( | const Message & | message, | |
const DataDictionary *const | pSessionDD, | |||
const DataDictionary *const | pAppID | |||
) | throw ( FIX::Exception ) [static] |
Validate a message.
Definition at line 118 of file DataDictionary.cpp.
References FIX::FIELD::BeginString, FIELD_GET_REF, FIX::FIELD::MsgType, QF_STACK_POP, and QF_STACK_PUSH.
Referenced by FIX::Session::next().
00122 { QF_STACK_PUSH( DataDictionary::validate ) 00123 00124 const bool bodyOnly = pSessionDD == 0; 00125 const Header& header = message.getHeader(); 00126 const BeginString& beginString = FIELD_GET_REF( header, BeginString ); 00127 const MsgType& msgType = FIELD_GET_REF( header, MsgType ); 00128 if ( pSessionDD != 0 && pSessionDD->m_hasVersion ) 00129 { 00130 if( pSessionDD->getVersion() != beginString ) 00131 { 00132 throw UnsupportedVersion(); 00133 } 00134 } 00135 00136 int field = 0; 00137 if( (pSessionDD !=0 && pSessionDD->m_checkFieldsOutOfOrder) 00138 || (pAppDD != 0 && pAppDD->m_checkFieldsOutOfOrder) ) 00139 { 00140 if ( !message.hasValidStructure(field) ) 00141 throw TagOutOfOrder(field); 00142 } 00143 00144 if ( pAppDD != 0 && pAppDD->m_hasVersion ) 00145 { 00146 pAppDD->checkMsgType( msgType ); 00147 pAppDD->checkHasRequired( message.getHeader(), message, message.getTrailer(), msgType ); 00148 } 00149 00150 if( !bodyOnly ) 00151 { 00152 pSessionDD->iterate( message.getHeader(), msgType ); 00153 pSessionDD->iterate( message.getTrailer(), msgType ); 00154 } 00155 00156 pAppDD->iterate( message, msgType ); 00157 00158 QF_STACK_POP 00159 }
TYPE::Type FIX::DataDictionary::XMLTypeToType | ( | const std::string & | xmlType | ) | const [private] |
Definition at line 621 of file DataDictionary.cpp.
References FIX::TYPE::Amt, FIX::TYPE::Boolean, FIX::TYPE::Char, FIX::TYPE::Country, FIX::TYPE::Currency, FIX::TYPE::Data, FIX::TYPE::DayOfMonth, FIX::TYPE::Exchange, FIX::TYPE::Float, FIX::TYPE::Int, FIX::TYPE::Length, FIX::TYPE::LocalMktDate, m_beginString, FIX::TYPE::MonthYear, FIX::TYPE::MultipleCharValue, FIX::TYPE::MultipleStringValue, FIX::TYPE::MultipleValueString, FIX::TYPE::NumInGroup, FIX::TYPE::Percentage, FIX::TYPE::Price, FIX::TYPE::PriceOffset, QF_STACK_POP, QF_STACK_PUSH, FIX::TYPE::Qty, FIX::TYPE::SeqNum, FIX::TYPE::String, FIX::TYPE::Unknown, FIX::TYPE::UtcDate, FIX::TYPE::UtcDateOnly, FIX::TYPE::UtcTimeOnly, and FIX::TYPE::UtcTimeStamp.
00622 { QF_STACK_PUSH(DataDictionary::XMLTypeToType) 00623 00624 if ( m_beginString < "FIX.4.2" && type == "CHAR" ) 00625 return TYPE::String; 00626 00627 if ( type == "STRING" ) return TYPE::String; 00628 if ( type == "CHAR" ) return TYPE::Char; 00629 if ( type == "PRICE" ) return TYPE::Price; 00630 if ( type == "INT" ) return TYPE::Int; 00631 if ( type == "AMT" ) return TYPE::Amt; 00632 if ( type == "QTY" ) return TYPE::Qty; 00633 if ( type == "CURRENCY" ) return TYPE::Currency; 00634 if ( type == "MULTIPLEVALUESTRING" ) return TYPE::MultipleValueString; 00635 if ( type == "MULTIPLESTRINGVALUE" ) return TYPE::MultipleStringValue; 00636 if ( type == "MULTIPLECHARVALUE" ) return TYPE::MultipleCharValue; 00637 if ( type == "EXCHANGE" ) return TYPE::Exchange; 00638 if ( type == "UTCTIMESTAMP" ) return TYPE::UtcTimeStamp; 00639 if ( type == "BOOLEAN" ) return TYPE::Boolean; 00640 if ( type == "LOCALMKTDATE" ) return TYPE::LocalMktDate; 00641 if ( type == "DATA" ) return TYPE::Data; 00642 if ( type == "FLOAT" ) return TYPE::Float; 00643 if ( type == "PRICEOFFSET" ) return TYPE::PriceOffset; 00644 if ( type == "MONTHYEAR" ) return TYPE::MonthYear; 00645 if ( type == "DAYOFMONTH" ) return TYPE::DayOfMonth; 00646 if ( type == "UTCDATE" ) return TYPE::UtcDate; 00647 if ( type == "UTCDATEONLY" ) return TYPE::UtcDateOnly; 00648 if ( type == "UTCTIMEONLY" ) return TYPE::UtcTimeOnly; 00649 if ( type == "NUMINGROUP" ) return TYPE::NumInGroup; 00650 if ( type == "PERCENTAGE" ) return TYPE::Percentage; 00651 if ( type == "SEQNUM" ) return TYPE::SeqNum; 00652 if ( type == "LENGTH" ) return TYPE::Length; 00653 if ( type == "COUNTRY" ) return TYPE::Country; 00654 if ( type == "TIME" ) return TYPE::UtcTimeStamp; 00655 return TYPE::Unknown; 00656 00657 QF_STACK_POP 00658 }
BeginString FIX::DataDictionary::m_beginString [private] |
Definition at line 507 of file DataDictionary.h.
Referenced by getVersion(), iterate(), operator=(), setVersion(), and XMLTypeToType().
bool FIX::DataDictionary::m_checkFieldsHaveValues [private] |
Definition at line 505 of file DataDictionary.h.
Referenced by checkFieldsHaveValues(), checkHasValue(), and operator=().
bool FIX::DataDictionary::m_checkFieldsOutOfOrder [private] |
Definition at line 504 of file DataDictionary.h.
Referenced by checkFieldsOutOfOrder(), and operator=().
bool FIX::DataDictionary::m_checkUserDefinedFields [private] |
Definition at line 506 of file DataDictionary.h.
Referenced by checkUserDefinedFields(), operator=(), and shouldCheckTag().
FieldToName FIX::DataDictionary::m_fieldNames [private] |
Definition at line 518 of file DataDictionary.h.
Referenced by addFieldName(), getFieldName(), and operator=().
Fields FIX::DataDictionary::m_fields [private] |
Definition at line 511 of file DataDictionary.h.
Referenced by addField(), checkValidTagNumber(), isField(), and operator=().
FieldTypes FIX::DataDictionary::m_fieldTypes [private] |
Definition at line 516 of file DataDictionary.h.
Referenced by addFieldType(), getFieldType(), isDataField(), isMultipleValueField(), and operator=().
Definition at line 517 of file DataDictionary.h.
Referenced by addFieldValue(), hasFieldValue(), isFieldValue(), and operator=().
FieldToGroup FIX::DataDictionary::m_groups [private] |
Definition at line 521 of file DataDictionary.h.
Referenced by addGroup(), getGroup(), isGroup(), operator=(), and ~DataDictionary().
bool FIX::DataDictionary::m_hasVersion [private] |
Definition at line 503 of file DataDictionary.h.
Referenced by iterate(), operator=(), and setVersion().
Definition at line 514 of file DataDictionary.h.
Referenced by addHeaderField(), checkHasRequired(), isHeaderField(), and operator=().
Definition at line 508 of file DataDictionary.h.
Referenced by addMsgField(), isMsgField(), and operator=().
MsgTypes FIX::DataDictionary::m_messages [private] |
Definition at line 510 of file DataDictionary.h.
Referenced by addMsgType(), isMsgType(), and operator=().
NameToField FIX::DataDictionary::m_names [private] |
Definition at line 519 of file DataDictionary.h.
Referenced by addFieldName(), getFieldTag(), and operator=().
Definition at line 512 of file DataDictionary.h.
Referenced by addField(), getOrderedFields(), and operator=().
OrderedFieldsArray FIX::DataDictionary::m_orderedFieldsArray [mutable, private] |
Definition at line 513 of file DataDictionary.h.
Referenced by getOrderedFields(), operator=(), and ~DataDictionary().
Definition at line 509 of file DataDictionary.h.
Referenced by addRequiredField(), checkHasRequired(), isRequiredField(), and operator=().
Definition at line 515 of file DataDictionary.h.
Referenced by addTrailerField(), checkHasRequired(), isTrailerField(), and operator=().
ValueToName FIX::DataDictionary::m_valueNames [private] |
Definition at line 520 of file DataDictionary.h.
Referenced by addValueName(), getValueName(), and operator=().