Public Member Functions | Static Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
FIX::DataDictionary Class Reference

Represents a data dictionary for a version of FIX. More...

#include <DataDictionary.h>

Collaboration diagram for FIX::DataDictionary:
Collaboration graph
[legend]

Public Member Functions

 DataDictionary ()
 
 DataDictionary (const DataDictionary &copy)
 
 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 )
 
message_order const & 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 (const 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 )
 
DataDictionaryoperator= (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. More...
 

Private Types

typedef std::set< int > MsgFields
 
typedef std::map< std::string, MsgFieldsMsgTypeToField
 
typedef std::set< std::string > MsgTypes
 
typedef std::set< int > Fields
 
typedef std::map< int, bool > NonBodyFields
 
typedef std::vector< int > OrderedFields
 
typedef message_order OrderedFieldsArray
 
typedef std::map< int, TYPE::TypeFieldTypes
 
typedef std::set< std::string > Values
 
typedef std::map< int, ValuesFieldToValue
 
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::string, std::pair< int, DataDictionary *> > FieldPresenceMap
 
typedef std::map< int, FieldPresenceMapFieldToGroup
 

Private Member Functions

void iterate (const FieldMap &map, const MsgType &msgType) const
 Iterate through fields while applying checks. More...
 
void checkMsgType (const MsgType &msgType) const
 Check if message type is defined in spec. More...
 
bool shouldCheckTag (const FieldBase &field) const
 If we need to check for the tag in the dictionary. More...
 
void checkValidTagNumber (const FieldBase &field) const throw ( InvalidTagNumber )
 Check if field tag number is defined in spec. More...
 
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. More...
 
void checkIsInMessage (const FieldBase &field, const MsgType &msgType) const throw ( TagNotDefinedForMessage )
 Check if a field is in this message type. More...
 
void checkGroupCount (const FieldBase &field, const FieldMap &fieldMap, const MsgType &msgType) const throw ( RepeatingGroupCountMismatch )
 Check if group count matches number of groups in. More...
 
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. More...
 
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
 
MsgFields m_dataFields
 

Detailed Description

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.

Member Typedef Documentation

◆ FieldPresenceMap

typedef std::map< std::string, std::pair < int, DataDictionary* > > FIX::DataDictionary::FieldPresenceMap
private

Definition at line 69 of file DataDictionary.h.

◆ Fields

typedef std::set< int > FIX::DataDictionary::Fields
private

Definition at line 54 of file DataDictionary.h.

◆ FieldToGroup

typedef std::map< int, FieldPresenceMap > FIX::DataDictionary::FieldToGroup
private

Definition at line 70 of file DataDictionary.h.

◆ FieldToName

typedef std::map< int, std::string > FIX::DataDictionary::FieldToName
private

Definition at line 61 of file DataDictionary.h.

◆ FieldToValue

typedef std::map< int, Values > FIX::DataDictionary::FieldToValue
private

Definition at line 60 of file DataDictionary.h.

◆ FieldTypes

typedef std::map< int, TYPE::Type > FIX::DataDictionary::FieldTypes
private

Definition at line 58 of file DataDictionary.h.

◆ MsgFields

typedef std::set< int > FIX::DataDictionary::MsgFields
private

Definition at line 51 of file DataDictionary.h.

◆ MsgTypes

typedef std::set< std::string > FIX::DataDictionary::MsgTypes
private

Definition at line 53 of file DataDictionary.h.

◆ MsgTypeToField

typedef std::map< std::string, MsgFields > FIX::DataDictionary::MsgTypeToField
private

Definition at line 52 of file DataDictionary.h.

◆ NameToField

typedef std::map< std::string, int > FIX::DataDictionary::NameToField
private

Definition at line 62 of file DataDictionary.h.

◆ NonBodyFields

typedef std::map< int, bool > FIX::DataDictionary::NonBodyFields
private

Definition at line 55 of file DataDictionary.h.

◆ OrderedFields

typedef std::vector< int > FIX::DataDictionary::OrderedFields
private

Definition at line 56 of file DataDictionary.h.

◆ OrderedFieldsArray

Definition at line 57 of file DataDictionary.h.

◆ Values

typedef std::set< std::string > FIX::DataDictionary::Values
private

Definition at line 59 of file DataDictionary.h.

◆ ValueToName

typedef std::map< std::pair < int, std::string > , std::string > FIX::DataDictionary::ValueToName
private

Definition at line 63 of file DataDictionary.h.

Constructor & Destructor Documentation

◆ DataDictionary() [1/4]

FIX::DataDictionary::DataDictionary ( )

Definition at line 41 of file DataDictionary.cpp.

Referenced by addGroup().

◆ DataDictionary() [2/4]

FIX::DataDictionary::DataDictionary ( const DataDictionary copy)

Definition at line 63 of file DataDictionary.cpp.

64 {
65  *this = copy;
66 }

◆ DataDictionary() [3/4]

FIX::DataDictionary::DataDictionary ( std::istream &  stream)
throw (ConfigError
)

Definition at line 46 of file DataDictionary.cpp.

References readFromStream().

48 : m_hasVersion( false ), m_checkFieldsOutOfOrder( true ),
50 {
51  readFromStream( stream );
52 }
void readFromStream(std::istream &stream)

◆ DataDictionary() [4/4]

FIX::DataDictionary::DataDictionary ( const std::string &  url)
throw (ConfigError
)

Definition at line 54 of file DataDictionary.cpp.

References readFromURL().

56 : m_hasVersion( false ), m_checkFieldsOutOfOrder( true ),
59 {
60  readFromURL( url );
61 }
void readFromURL(const std::string &url)
OrderedFieldsArray m_orderedFieldsArray

◆ ~DataDictionary()

FIX::DataDictionary::~DataDictionary ( )
virtual

Definition at line 68 of file DataDictionary.cpp.

References m_groups.

69 {
70  FieldToGroup::iterator i;
71  for ( i = m_groups.begin(); i != m_groups.end(); ++i )
72  {
73  const FieldPresenceMap& presenceMap = i->second;
74 
75  FieldPresenceMap::const_iterator iter = presenceMap.begin();
76  for ( ; iter != presenceMap.end(); ++iter )
77  delete iter->second.second;
78  }
79 }
FieldToGroup m_groups
std::map< std::string, std::pair< int, DataDictionary *> > FieldPresenceMap

Member Function Documentation

◆ addField()

void FIX::DataDictionary::addField ( int  field)
inline

Definition at line 96 of file DataDictionary.h.

References m_fields, and m_orderedFields.

Referenced by addXMLComponentFields(), addXMLGroup(), and readFromDocument().

97  {
98  m_fields.insert( field );
99  m_orderedFields.push_back( field );
100  }
OrderedFields m_orderedFields

◆ addFieldName()

void FIX::DataDictionary::addFieldName ( int  field,
const std::string &  name 
)
inline

Definition at line 102 of file DataDictionary.h.

References m_fieldNames, and m_names.

Referenced by readFromDocument().

103  {
104  if( m_names.insert( std::make_pair(name, field) ).second == false )
105  throw ConfigError( "Field named " + name + " defined multiple times" );
106  m_fieldNames[field] = name;
107  }
FieldToName m_fieldNames

◆ addFieldType()

void FIX::DataDictionary::addFieldType ( int  field,
FIX::TYPE::Type  type 
)
inline

Definition at line 185 of file DataDictionary.h.

References FIX::TYPE::Data, m_dataFields, and m_fieldTypes.

Referenced by readFromDocument().

186  {
187  m_fieldTypes[ field ] = type;
188 
189  if( type == FIX::TYPE::Data )
190  m_dataFields.insert( field );
191  }

◆ addFieldValue()

void FIX::DataDictionary::addFieldValue ( int  field,
const std::string &  value 
)
inline

Definition at line 213 of file DataDictionary.h.

References m_fieldValues.

Referenced by readFromDocument().

214  {
215  m_fieldValues[ field ].insert( value );
216  }
FieldToValue m_fieldValues

◆ addGroup()

void FIX::DataDictionary::addGroup ( const std::string &  msg,
int  field,
int  delim,
const DataDictionary dataDictionary 
)
inline

Definition at line 247 of file DataDictionary.h.

References DataDictionary(), getVersion(), m_groups, and setVersion().

Referenced by addXMLGroup(), and operator=().

249  {
250  DataDictionary * pDD = new DataDictionary( dataDictionary );
251  pDD->setVersion( getVersion() );
252 
253  FieldPresenceMap& presenceMap = m_groups[ field ];
254  presenceMap[ msg ] = std::make_pair( delim, pDD );
255  }
std::string getVersion() const
FieldToGroup m_groups
std::map< std::string, std::pair< int, DataDictionary *> > FieldPresenceMap

◆ addHeaderField()

void FIX::DataDictionary::addHeaderField ( int  field,
bool  required 
)
inline

Definition at line 165 of file DataDictionary.h.

References m_headerFields.

Referenced by readFromDocument().

166  {
167  m_headerFields[ field ] = required;
168  }
NonBodyFields m_headerFields

◆ addMsgField()

void FIX::DataDictionary::addMsgField ( const std::string &  msgType,
int  field 
)
inline

Definition at line 153 of file DataDictionary.h.

References m_messageFields.

Referenced by addXMLComponentFields(), and readFromDocument().

154  {
155  m_messageFields[ msgType ].insert( field );
156  }
MsgTypeToField m_messageFields

◆ addMsgType()

void FIX::DataDictionary::addMsgType ( const std::string &  msgType)
inline

Definition at line 143 of file DataDictionary.h.

References m_messages.

Referenced by readFromDocument().

144  {
145  m_messages.insert( msgType );
146  }

◆ addRequiredField()

void FIX::DataDictionary::addRequiredField ( const std::string &  msgType,
int  field 
)
inline

Definition at line 201 of file DataDictionary.h.

References m_requiredFields.

Referenced by addXMLComponentFields(), addXMLGroup(), and readFromDocument().

202  {
203  m_requiredFields[ msgType ].insert( field );
204  }
MsgTypeToField m_requiredFields

◆ addTrailerField()

void FIX::DataDictionary::addTrailerField ( int  field,
bool  required 
)
inline

Definition at line 175 of file DataDictionary.h.

References m_trailerFields.

Referenced by readFromDocument().

176  {
177  m_trailerFields[ field ] = required;
178  }
NonBodyFields m_trailerFields

◆ addValueName()

void FIX::DataDictionary::addValueName ( int  field,
const std::string &  value,
const std::string &  name 
)
inline

Definition at line 125 of file DataDictionary.h.

References m_valueNames.

Referenced by readFromDocument().

126  {
127  m_valueNames[std::make_pair(field, value)] = name;
128  }
ValueToName m_valueNames

◆ addXMLComponentFields()

int FIX::DataDictionary::addXMLComponentFields ( DOMDocument pDoc,
DOMNode pNode,
const std::string &  msgtype,
DataDictionary DD,
bool  componentRequired 
)
private

Definition at line 462 of file DataDictionary.cpp.

References addField(), addMsgField(), addRequiredField(), addXMLGroup(), FIX::DOMNode::getAttributes(), FIX::DOMDocument::getNode(), lookupXMLFieldNumber(), and RESET_AUTO_PTR.

Referenced by addXMLGroup(), checkHasRequired(), and readFromDocument().

466 {
467  int firstField = 0;
468 
469  DOMAttributesPtr attrs = pNode->getAttributes();
470  std::string name;
471  if(!attrs->get("name", name))
472  throw ConfigError("No name given to component");
473 
474  DOMNodePtr pComponentNode =
475  pDoc->getNode("/fix/components/component[@name='" + name + "']");
476  if(pComponentNode.get() == 0)
477  throw ConfigError("Component not found");
478 
479  DOMNodePtr pComponentFieldNode = pComponentNode->getFirstChildNode();
480  while(pComponentFieldNode.get())
481  {
482  if(pComponentFieldNode->getName() == "field"
483  || pComponentFieldNode->getName() == "group")
484  {
485  DOMAttributesPtr attrs = pComponentFieldNode->getAttributes();
486  std::string name;
487  if(!attrs->get("name", name))
488  throw ConfigError("No name given to field");
489  int field = lookupXMLFieldNumber(pDoc, name);
490  if( firstField == 0 ) firstField = field;
491 
492  std::string required;
493  if(attrs->get("required", required)
494  && (required == "Y" || required =="y")
495  && componentRequired)
496  {
497  addRequiredField(msgtype, field);
498  }
499 
500  DD.addField(field);
501  DD.addMsgField(msgtype, field);
502  }
503  if(pComponentFieldNode->getName() == "component")
504  {
505  DOMAttributesPtr attrs = pComponentFieldNode->getAttributes();
506  std::string required;
507  attrs->get("required", required);
508  bool isRequired = (required == "Y" || required == "y");
509  addXMLComponentFields(pDoc, pComponentFieldNode.get(),
510  msgtype, DD, isRequired);
511  }
512  if(pComponentFieldNode->getName() == "group")
513  {
514  DOMAttributesPtr attrs = pComponentFieldNode->getAttributes();
515  std::string required;
516  attrs->get("required", required);
517  bool isRequired = (required == "Y" || required == "y");
518  addXMLGroup(pDoc, pComponentFieldNode.get(), msgtype, DD, isRequired);
519  }
520  RESET_AUTO_PTR(pComponentFieldNode,
521  pComponentFieldNode->getNextSiblingNode());
522  }
523  return firstField;
524 }
std::auto_ptr< DOMAttributes > DOMAttributesPtr
Definition: DOMDocument.h:43
void addXMLGroup(DOMDocument *, DOMNode *, const std::string &msgtype, DataDictionary &, bool)
#define RESET_AUTO_PTR(OLD, NEW)
int addXMLComponentFields(DOMDocument *, DOMNode *, const std::string &msgtype, DataDictionary &, bool)
std::auto_ptr< DOMNode > DOMNodePtr
Definition: DOMDocument.h:57
int lookupXMLFieldNumber(DOMDocument *, DOMNode *) const
void addRequiredField(const std::string &msgType, int field)

◆ addXMLGroup()

void FIX::DataDictionary::addXMLGroup ( DOMDocument pDoc,
DOMNode pNode,
const std::string &  msgtype,
DataDictionary DD,
bool  groupRequired 
)
private

Definition at line 526 of file DataDictionary.cpp.

References addField(), addGroup(), addRequiredField(), addXMLComponentFields(), FIX::DOMNode::getAttributes(), FIX::DOMNode::getFirstChildNode(), lookupXMLFieldNumber(), and RESET_AUTO_PTR.

Referenced by addXMLComponentFields(), checkHasRequired(), and readFromDocument().

529 {
530  DOMAttributesPtr attrs = pNode->getAttributes();
531  std::string name;
532  if(!attrs->get("name", name))
533  throw ConfigError("No name given to group");
534  int group = lookupXMLFieldNumber( pDoc, name );
535  int delim = 0;
536  int field = 0;
537  DataDictionary groupDD;
538  DOMNodePtr node = pNode->getFirstChildNode();
539  while(node.get())
540  {
541  if( node->getName() == "field" )
542  {
543  field = lookupXMLFieldNumber( pDoc, node.get() );
544  groupDD.addField( field );
545 
546  DOMAttributesPtr attrs = node->getAttributes();
547  std::string required;
548  if( attrs->get("required", required)
549  && ( required == "Y" || required =="y" )
550  && groupRequired )
551  {
552  groupDD.addRequiredField(msgtype, field);
553  }
554  }
555  else if( node->getName() == "component" )
556  {
557  field = addXMLComponentFields( pDoc, node.get(), msgtype, groupDD, false );
558  }
559  else if( node->getName() == "group" )
560  {
561  field = lookupXMLFieldNumber( pDoc, node.get() );
562  groupDD.addField( field );
563  DOMAttributesPtr attrs = node->getAttributes();
564  std::string required;
565  if( attrs->get("required", required )
566  && ( required == "Y" || required =="y" )
567  && groupRequired)
568  {
569  groupDD.addRequiredField(msgtype, field);
570  }
571  bool isRequired = false;
572  if( attrs->get("required", required) )
573  isRequired = (required == "Y" || required == "y");
574  addXMLGroup( pDoc, node.get(), msgtype, groupDD, isRequired );
575  }
576  if( delim == 0 ) delim = field;
577  RESET_AUTO_PTR(node, node->getNextSiblingNode());
578  }
579 
580  if( delim ) DD.addGroup( msgtype, group, delim, groupDD );
581 }
std::auto_ptr< DOMAttributes > DOMAttributesPtr
Definition: DOMDocument.h:43
void addXMLGroup(DOMDocument *, DOMNode *, const std::string &msgtype, DataDictionary &, bool)
#define RESET_AUTO_PTR(OLD, NEW)
int addXMLComponentFields(DOMDocument *, DOMNode *, const std::string &msgtype, DataDictionary &, bool)
std::auto_ptr< DOMNode > DOMNodePtr
Definition: DOMDocument.h:57
int lookupXMLFieldNumber(DOMDocument *, DOMNode *) const

◆ checkFieldsHaveValues()

void FIX::DataDictionary::checkFieldsHaveValues ( bool  value)
inline

Definition at line 302 of file DataDictionary.h.

References m_checkFieldsHaveValues.

303  { m_checkFieldsHaveValues = value; }

◆ checkFieldsOutOfOrder()

void FIX::DataDictionary::checkFieldsOutOfOrder ( bool  value)
inline

Definition at line 300 of file DataDictionary.h.

References m_checkFieldsOutOfOrder.

301  { m_checkFieldsOutOfOrder = value; }

◆ checkGroupCount()

void FIX::DataDictionary::checkGroupCount ( const FieldBase field,
const FieldMap fieldMap,
const MsgType &  msgType 
) const
throw (RepeatingGroupCountMismatch
)
inlineprivate

Check if group count matches number of groups in.

Definition at line 452 of file DataDictionary.h.

References checkHasRequired(), FIX::IntConvertor::convert(), FIX::FieldBase::getField(), FIX::FieldBase::getString(), FIX::FieldMap::groupCount(), and isGroup().

Referenced by checkIsInMessage(), and iterate().

454  {
455  int fieldNum = field.getField();
456  if( isGroup(msgType, fieldNum) )
457  {
458  if( (int)fieldMap.groupCount(fieldNum)
459  != IntConvertor::convert(field.getString()) )
460  throw RepeatingGroupCountMismatch(fieldNum);
461  }
462  }
static std::string convert(signed_int value)
bool isGroup(const std::string &msg, int field) const

◆ checkHasRequired()

void FIX::DataDictionary::checkHasRequired ( const FieldMap header,
const FieldMap body,
const FieldMap trailer,
const MsgType &  msgType 
) const
throw (RequiredTagMissing
)
inlineprivate

Check if a message has all required fields.

Definition at line 466 of file DataDictionary.h.

References addXMLComponentFields(), addXMLGroup(), checkHasRequired(), FIX::FieldMap::g_begin(), FIX::FieldMap::g_end(), getGroup(), FIX::FieldMap::isSetField(), lookupXMLFieldNumber(), m_headerFields, m_requiredFields, m_trailerFields, and XMLTypeToType().

Referenced by checkGroupCount(), and checkHasRequired().

469  {
470  NonBodyFields::const_iterator iNBF;
471  for( iNBF = m_headerFields.begin(); iNBF != m_headerFields.end(); ++iNBF )
472  {
473  if( iNBF->second == true && !header.isSetField(iNBF->first) )
474  throw RequiredTagMissing( iNBF->first );
475  }
476 
477  for( iNBF = m_trailerFields.begin(); iNBF != m_trailerFields.end(); ++iNBF )
478  {
479  if( iNBF->second == true && !trailer.isSetField(iNBF->first) )
480  throw RequiredTagMissing( iNBF->first );
481  }
482 
483  MsgTypeToField::const_iterator iM
484  = m_requiredFields.find( msgType.getString() );
485  if ( iM == m_requiredFields.end() ) return ;
486 
487  const MsgFields& fields = iM->second;
488  MsgFields::const_iterator iF;
489  for( iF = fields.begin(); iF != fields.end(); ++iF )
490  {
491  if( !body.isSetField(*iF) )
492  throw RequiredTagMissing( *iF );
493  }
494 
495  FieldMap::g_iterator groups;
496  for( groups = body.g_begin(); groups != body.g_end(); ++groups )
497  {
498  int delim;
499  const DataDictionary* DD = 0;
500  int field = groups->first;
501  if( getGroup( msgType.getValue(), field, delim, DD ) )
502  {
503  std::vector<FieldMap*>::const_iterator group;
504  for( group = groups->second.begin(); group != groups->second.end(); ++group )
505  DD->checkHasRequired( **group, **group, **group, msgType );
506  }
507  }
508  }
MsgTypeToField m_requiredFields
Groups::const_iterator g_iterator
Definition: FieldMap.h:61
bool getGroup(const std::string &msg, int field, int &delim, const DataDictionary *&pDataDictionary) const
NonBodyFields m_headerFields
std::set< int > MsgFields
NonBodyFields m_trailerFields

◆ checkHasValue()

void FIX::DataDictionary::checkHasValue ( const FieldBase field) const
throw (NoTagValue
)
inlineprivate

Check if a field has a value.

Definition at line 434 of file DataDictionary.h.

References checkIsInMessage(), and m_checkFieldsHaveValues.

Referenced by iterate().

436  {
437  if ( m_checkFieldsHaveValues && !field.getString().length() )
438  throw NoTagValue( field.getField() );
439  }

◆ checkIsInMessage()

void FIX::DataDictionary::checkIsInMessage ( const FieldBase field,
const MsgType &  msgType 
) const
throw (TagNotDefinedForMessage
)
inlineprivate

Check if a field is in this message type.

Definition at line 443 of file DataDictionary.h.

References checkGroupCount(), FIX::FieldBase::getField(), and isMsgField().

Referenced by checkHasValue(), and iterate().

445  {
446  if ( !isMsgField( msgType, field.getField() ) )
447  throw TagNotDefinedForMessage( field.getField() );
448  }
bool isMsgField(const std::string &msgType, int field) const

◆ checkMsgType()

void FIX::DataDictionary::checkMsgType ( const MsgType &  msgType) const
inlineprivate

Check if message type is defined in spec.

Definition at line 324 of file DataDictionary.h.

References isMsgType().

325  {
326  if ( !isMsgType( msgType.getValue() ) )
327  throw InvalidMessageType();
328  }
bool isMsgType(const std::string &msgType) const

◆ checkUserDefinedFields()

void FIX::DataDictionary::checkUserDefinedFields ( bool  value)
inline

Definition at line 304 of file DataDictionary.h.

References m_checkUserDefinedFields, and validate().

305  { m_checkUserDefinedFields = value; }

◆ checkValidFormat()

void FIX::DataDictionary::checkValidFormat ( const FieldBase field) const
throw (IncorrectDataFormat
)
inlineprivate

Definition at line 347 of file DataDictionary.h.

References FIX::TYPE::Amt, FIX::TYPE::Boolean, FIX::TYPE::Char, FIX::EmptyConvertor::convert(), FIX::IntConvertor::convert(), FIX::DoubleConvertor::convert(), FIX::CharConvertor::convert(), FIX::BoolConvertor::convert(), FIX::UtcTimeStampConvertor::convert(), FIX::UtcTimeOnlyConvertor::convert(), FIX::UtcDateConvertor::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().

349  {
350  try
351  {
352  TYPE::Type type = TYPE::Unknown;
353  getFieldType( field.getField(), type );
354  switch ( type )
355  {
356  case TYPE::String:
357  STRING_CONVERTOR::convert( field.getString() ); break;
358  case TYPE::Char:
359  CHAR_CONVERTOR::convert( field.getString() ); break;
360  case TYPE::Price:
361  PRICE_CONVERTOR::convert( field.getString() ); break;
362  case TYPE::Int:
363  INT_CONVERTOR::convert( field.getString() ); break;
364  case TYPE::Amt:
365  AMT_CONVERTOR::convert( field.getString() ); break;
366  case TYPE::Qty:
367  QTY_CONVERTOR::convert( field.getString() ); break;
368  case TYPE::Currency:
369  CURRENCY_CONVERTOR::convert( field.getString() ); break;
371  MULTIPLEVALUESTRING_CONVERTOR::convert( field.getString() ); break;
373  MULTIPLESTRINGVALUE_CONVERTOR::convert( field.getString() ); break;
375  MULTIPLECHARVALUE_CONVERTOR::convert( field.getString() ); break;
376  case TYPE::Exchange:
377  EXCHANGE_CONVERTOR::convert( field.getString() ); break;
378  case TYPE::UtcTimeStamp:
379  UTCTIMESTAMP_CONVERTOR::convert( field.getString() ); break;
380  case TYPE::Boolean:
381  BOOLEAN_CONVERTOR::convert( field.getString() ); break;
382  case TYPE::LocalMktDate:
383  LOCALMKTDATE_CONVERTOR::convert( field.getString() ); break;
384  case TYPE::Data:
385  DATA_CONVERTOR::convert( field.getString() ); break;
386  case TYPE::Float:
387  FLOAT_CONVERTOR::convert( field.getString() ); break;
388  case TYPE::PriceOffset:
389  PRICEOFFSET_CONVERTOR::convert( field.getString() ); break;
390  case TYPE::MonthYear:
391  MONTHYEAR_CONVERTOR::convert( field.getString() ); break;
392  case TYPE::DayOfMonth:
393  DAYOFMONTH_CONVERTOR::convert( field.getString() ); break;
394  case TYPE::UtcDate:
395  UTCDATE_CONVERTOR::convert( field.getString() ); break;
396  case TYPE::UtcTimeOnly:
397  UTCTIMEONLY_CONVERTOR::convert( field.getString() ); break;
398  case TYPE::NumInGroup:
399  NUMINGROUP_CONVERTOR::convert( field.getString() ); break;
400  case TYPE::Percentage:
401  PERCENTAGE_CONVERTOR::convert( field.getString() ); break;
402  case TYPE::SeqNum:
403  SEQNUM_CONVERTOR::convert( field.getString() ); break;
404  case TYPE::Length:
405  LENGTH_CONVERTOR::convert( field.getString() ); break;
406  case TYPE::Country:
407  COUNTRY_CONVERTOR::convert( field.getString() ); break;
408  case TYPE::TzTimeOnly:
409  TZTIMEONLY_CONVERTOR::convert( field.getString() ); break;
410  case TYPE::TzTimeStamp:
411  TZTIMESTAMP_CONVERTOR::convert( field.getString() ); break;
412  case TYPE::XmlData:
413  XMLDATA_CONVERTOR::convert( field.getString() ); break;
414  case TYPE::Language:
415  LANGUAGE_CONVERTOR::convert( field.getString() ); break;
416  case TYPE::Unknown: break;
417  }
418  }
419  catch ( FieldConvertError& )
420  { throw IncorrectDataFormat( field.getField(), field.getString() ); }
421  }
static std::string convert(const UtcTimeOnly &value, bool showMilliseconds=false)
static std::string convert(char value)
static std::string convert(const UtcTimeStamp &value, bool showMilliseconds=false)
bool getFieldType(int field, FIX::TYPE::Type &type) const
static std::string convert(signed_int value)
static std::string convert(double value, int padding=0)
static std::string convert(const UtcDate &value)
static std::string convert(bool value)
static const std::string & convert(const std::string &value)

◆ checkValidTagNumber()

void FIX::DataDictionary::checkValidTagNumber ( const FieldBase field) const
throw (InvalidTagNumber
)
inlineprivate

Check if field tag number is defined in spec.

Definition at line 340 of file DataDictionary.h.

References m_fields.

Referenced by iterate().

342  {
343  if( m_fields.find( field.getField() ) == m_fields.end() )
344  throw InvalidTagNumber( field.getField() );
345  }

◆ checkValue()

void FIX::DataDictionary::checkValue ( const FieldBase field) const
throw (IncorrectTagValue
)
inlineprivate

Definition at line 423 of file DataDictionary.h.

References hasFieldValue(), and isFieldValue().

Referenced by iterate().

425  {
426  if ( !hasFieldValue( field.getField() ) ) return ;
427 
428  const std::string& value = field.getString();
429  if ( !isFieldValue( field.getField(), value ) )
430  throw IncorrectTagValue( field.getField() );
431  }
bool hasFieldValue(int field) const
bool isFieldValue(int field, const std::string &value) const

◆ getFieldName()

bool FIX::DataDictionary::getFieldName ( int  field,
std::string &  name 
) const
inline

Definition at line 109 of file DataDictionary.h.

References m_fieldNames.

110  {
111  FieldToName::const_iterator i = m_fieldNames.find( field );
112  if(i == m_fieldNames.end()) return false;
113  name = i->second;
114  return true;
115  }
FieldToName m_fieldNames

◆ getFieldTag()

bool FIX::DataDictionary::getFieldTag ( const std::string &  name,
int &  field 
) const
inline

Definition at line 117 of file DataDictionary.h.

References m_names.

118  {
119  NameToField::const_iterator i = m_names.find( name );
120  if(i == m_names.end()) return false;
121  field = i->second;
122  return true;
123  }

◆ getFieldType()

bool FIX::DataDictionary::getFieldType ( int  field,
FIX::TYPE::Type type 
) const
inline

Definition at line 193 of file DataDictionary.h.

References m_fieldTypes.

Referenced by checkValidFormat().

194  {
195  FieldTypes::const_iterator i = m_fieldTypes.find( field );
196  if ( i == m_fieldTypes.end() ) return false;
197  type = i->second;
198  return true;
199  }

◆ getGroup()

bool FIX::DataDictionary::getGroup ( const std::string &  msg,
int  field,
int &  delim,
const DataDictionary *&  pDataDictionary 
) const
inline

Definition at line 268 of file DataDictionary.h.

References m_groups.

Referenced by checkHasRequired(), and FIX::Message::setGroup().

270  {
271  FieldToGroup::const_iterator i = m_groups.find( field );
272  if ( i == m_groups.end() ) return false;
273 
274  const FieldPresenceMap& presenceMap = i->second;
275 
276  FieldPresenceMap::const_iterator iter = presenceMap.find( msg );
277  if( iter == presenceMap.end() ) return false;
278 
279  std::pair < int, DataDictionary* > pair = iter->second;
280  delim = pair.first;
281  pDataDictionary = pair.second;
282  return true;
283  }
FieldToGroup m_groups
std::map< std::string, std::pair< int, DataDictionary *> > FieldPresenceMap

◆ getOrderedFields()

message_order const & FIX::DataDictionary::getOrderedFields ( ) const

Definition at line 427 of file DataDictionary.cpp.

References m_orderedFields, and m_orderedFieldsArray.

Referenced by FIX::Message::setGroup().

428 {
430 
431  int * tmp = new int[m_orderedFields.size() + 1];
432  int * i = tmp;
433 
434  OrderedFields::const_iterator iter;
435  for( iter = m_orderedFields.begin(); iter != m_orderedFields.end(); *(i++) = *(iter++) ) {}
436  *i = 0;
437 
438  m_orderedFieldsArray = message_order(tmp);
439  delete [] tmp;
440 
441  return m_orderedFieldsArray;
442 }
OrderedFields m_orderedFields
OrderedFieldsArray m_orderedFieldsArray

◆ getValueName()

bool FIX::DataDictionary::getValueName ( int  field,
const std::string &  value,
std::string &  name 
) const
inline

Definition at line 130 of file DataDictionary.h.

References m_valueNames.

131  {
132  ValueToName::const_iterator i = m_valueNames.find( std::make_pair(field, value) );
133  if(i == m_valueNames.end()) return false;
134  name = i->second;
135  return true;
136  }
ValueToName m_valueNames

◆ getVersion()

std::string FIX::DataDictionary::getVersion ( ) const
inline

Definition at line 91 of file DataDictionary.h.

References m_beginString.

Referenced by addGroup().

92  {
93  return m_beginString.getString();
94  }
BeginString m_beginString

◆ hasFieldValue()

bool FIX::DataDictionary::hasFieldValue ( int  field) const
inline

Definition at line 218 of file DataDictionary.h.

References m_fieldValues.

Referenced by checkValue().

219  {
220  FieldToValue::const_iterator i = m_fieldValues.find( field );
221  return i != m_fieldValues.end();
222  }
FieldToValue m_fieldValues

◆ isDataField()

bool FIX::DataDictionary::isDataField ( int  field) const
inline

Definition at line 285 of file DataDictionary.h.

References m_dataFields.

Referenced by FIX::Message::IsDataField().

286  {
287  MsgFields::const_iterator iter = m_dataFields.find( field );
288  return iter != m_dataFields.end();
289  }

◆ isField()

bool FIX::DataDictionary::isField ( int  field) const
inline

Definition at line 138 of file DataDictionary.h.

References m_fields.

Referenced by FIX::Message::setGroup().

139  {
140  return m_fields.find( field ) != m_fields.end();
141  }

◆ isFieldValue()

bool FIX::DataDictionary::isFieldValue ( int  field,
const std::string &  value 
) const
inline

Definition at line 224 of file DataDictionary.h.

References isMultipleValueField(), and m_fieldValues.

Referenced by checkValue().

225  {
226  FieldToValue::const_iterator i = m_fieldValues.find( field );
227  if ( i == m_fieldValues.end() )
228  return false;
229  if( !isMultipleValueField( field ) )
230  return i->second.find( value ) != i->second.end();
231 
232  // MultipleValue
233  std::string::size_type startPos = 0;
234  std::string::size_type endPos = 0;
235  do
236  {
237  endPos = value.find_first_of(' ', startPos);
238  std::string singleValue =
239  value.substr( startPos, endPos - startPos );
240  if( i->second.find( singleValue ) == i->second.end() )
241  return false;
242  startPos = endPos + 1;
243  } while( endPos != std::string::npos );
244  return true;
245  }
bool isMultipleValueField(int field) const
FieldToValue m_fieldValues

◆ isGroup()

bool FIX::DataDictionary::isGroup ( const std::string &  msg,
int  field 
) const
inline

Definition at line 257 of file DataDictionary.h.

References m_groups.

Referenced by checkGroupCount().

258  {
259  FieldToGroup::const_iterator i = m_groups.find( field );
260  if ( i == m_groups.end() ) return false;
261 
262  const FieldPresenceMap& presenceMap = i->second;
263 
264  FieldPresenceMap::const_iterator iter = presenceMap.find( msg );
265  return ( iter != presenceMap.end() );
266  }
FieldToGroup m_groups
std::map< std::string, std::pair< int, DataDictionary *> > FieldPresenceMap

◆ isHeaderField()

bool FIX::DataDictionary::isHeaderField ( int  field) const
inline

Definition at line 170 of file DataDictionary.h.

References m_headerFields.

Referenced by FIX::Message::isHeaderField().

171  {
172  return m_headerFields.find( field ) != m_headerFields.end();
173  }
NonBodyFields m_headerFields

◆ isMsgField()

bool FIX::DataDictionary::isMsgField ( const std::string &  msgType,
int  field 
) const
inline

Definition at line 158 of file DataDictionary.h.

References m_messageFields.

Referenced by checkIsInMessage().

159  {
160  MsgTypeToField::const_iterator i = m_messageFields.find( msgType );
161  if ( i == m_messageFields.end() ) return false;
162  return i->second.find( field ) != i->second.end();
163  }
MsgTypeToField m_messageFields

◆ isMsgType()

bool FIX::DataDictionary::isMsgType ( const std::string &  msgType) const
inline

Definition at line 148 of file DataDictionary.h.

References m_messages.

Referenced by checkMsgType().

149  {
150  return m_messages.find( msgType ) != m_messages.end();
151  }

◆ isMultipleValueField()

bool FIX::DataDictionary::isMultipleValueField ( int  field) const
inline

Definition at line 291 of file DataDictionary.h.

References m_fieldTypes, FIX::TYPE::MultipleCharValue, FIX::TYPE::MultipleStringValue, and FIX::TYPE::MultipleValueString.

Referenced by isFieldValue().

292  {
293  FieldTypes::const_iterator i = m_fieldTypes.find( field );
294  return i != m_fieldTypes.end()
295  && (i->second == TYPE::MultipleValueString
296  || i->second == TYPE::MultipleCharValue
297  || i->second == TYPE::MultipleStringValue );
298  }

◆ isRequiredField()

bool FIX::DataDictionary::isRequiredField ( const std::string &  msgType,
int  field 
) const
inline

Definition at line 206 of file DataDictionary.h.

References m_requiredFields.

207  {
208  MsgTypeToField::const_iterator i = m_requiredFields.find( msgType );
209  if ( i == m_requiredFields.end() ) return false;
210  return i->second.find( field ) != i->second.end();
211  }
MsgTypeToField m_requiredFields

◆ isTrailerField()

bool FIX::DataDictionary::isTrailerField ( int  field) const
inline

Definition at line 180 of file DataDictionary.h.

References m_trailerFields.

Referenced by FIX::Message::isTrailerField().

181  {
182  return m_trailerFields.find( field ) != m_trailerFields.end();
183  }
NonBodyFields m_trailerFields

◆ iterate()

void FIX::DataDictionary::iterate ( const FieldMap map,
const MsgType &  msgType 
) const
private

Iterate through fields while applying checks.

Definition at line 159 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, and shouldCheckTag().

Referenced by validate().

160 {
161  int lastField = 0;
162 
164  for ( i = map.begin(); i != map.end(); ++i )
165  {
166  const FieldBase& field = i->second;
167  if( i != map.begin() && (field.getField() == lastField) )
168  throw RepeatedTag( lastField );
169  checkHasValue( field );
170 
171  if ( m_hasVersion )
172  {
173  checkValidFormat( field );
174  checkValue( field );
175  }
176 
177  if ( m_beginString.getValue().length() && shouldCheckTag(field) )
178  {
179  checkValidTagNumber( field );
180  if ( !Message::isHeaderField( field, this )
181  && !Message::isTrailerField( field, this ) )
182  {
183  checkIsInMessage( field, msgType );
184  checkGroupCount( field, map, msgType );
185  }
186  }
187  lastField = field.getField();
188  }
189 }
Fields::const_iterator iterator
Definition: FieldMap.h:59
void checkGroupCount(const FieldBase &field, const FieldMap &fieldMap, const MsgType &msgType) const
Check if group count matches number of groups in.
void checkValidFormat(const FieldBase &field) const
BeginString m_beginString
void checkIsInMessage(const FieldBase &field, const MsgType &msgType) const
Check if a field is in this message type.
void checkValue(const FieldBase &field) const
bool shouldCheckTag(const FieldBase &field) const
If we need to check for the tag in the dictionary.
void checkValidTagNumber(const FieldBase &field) const
Check if field tag number is defined in spec.
void checkHasValue(const FieldBase &field) const
Check if a field has a value.
static bool isHeaderField(int field)
Definition: Message.cpp:400
static bool isTrailerField(int field)
Definition: Message.cpp:447

◆ lookupXMLFieldNumber() [1/2]

int FIX::DataDictionary::lookupXMLFieldNumber ( DOMDocument pDoc,
DOMNode pNode 
) const
private

Definition at line 444 of file DataDictionary.cpp.

References FIX::DOMNode::getAttributes().

Referenced by addXMLComponentFields(), addXMLGroup(), checkHasRequired(), and readFromDocument().

445 {
446  DOMAttributesPtr attrs = pNode->getAttributes();
447  std::string name;
448  if(!attrs->get("name", name))
449  throw ConfigError("No name given to field");
450  return lookupXMLFieldNumber( pDoc, name );
451 }
std::auto_ptr< DOMAttributes > DOMAttributesPtr
Definition: DOMDocument.h:43
int lookupXMLFieldNumber(DOMDocument *, DOMNode *) const

◆ lookupXMLFieldNumber() [2/2]

int FIX::DataDictionary::lookupXMLFieldNumber ( DOMDocument pDoc,
const std::string &  name 
) const
private

Definition at line 454 of file DataDictionary.cpp.

References m_names.

455 {
456  NameToField::const_iterator i = m_names.find(name);
457  if( i == m_names.end() )
458  throw ConfigError("Field " + name + " not defined in fields section");
459  return i->second;
460 }

◆ operator=()

DataDictionary & FIX::DataDictionary::operator= ( const DataDictionary rhs)

Definition at line 81 of file DataDictionary.cpp.

References addGroup(), m_beginString, m_checkFieldsHaveValues, m_checkFieldsOutOfOrder, m_checkUserDefinedFields, m_dataFields, 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, and m_valueNames.

Referenced by validate().

82 {
83  m_hasVersion = rhs.m_hasVersion;
84  m_checkFieldsOutOfOrder = rhs.m_checkFieldsOutOfOrder;
85  m_checkFieldsHaveValues = rhs.m_checkFieldsHaveValues;
86  m_checkUserDefinedFields = rhs.m_checkUserDefinedFields;
87  m_beginString = rhs.m_beginString;
88  m_messageFields = rhs.m_messageFields;
89  m_requiredFields = rhs.m_requiredFields;
90  m_messages = rhs.m_messages;
91  m_fields = rhs.m_fields;
92  m_orderedFields = rhs.m_orderedFields;
93  m_orderedFieldsArray = rhs.m_orderedFieldsArray;
94  m_headerFields = rhs.m_headerFields;
95  m_trailerFields = rhs.m_trailerFields;
96  m_fieldTypes = rhs.m_fieldTypes;
97  m_fieldValues = rhs.m_fieldValues;
98  m_fieldNames = rhs.m_fieldNames;
99  m_names = rhs.m_names;
100  m_valueNames = rhs.m_valueNames;
101  m_dataFields = rhs.m_dataFields;
102 
103  FieldToGroup::const_iterator i = rhs.m_groups.begin();
104  for ( ; i != rhs.m_groups.end(); ++i )
105  {
106  const FieldPresenceMap& presenceMap = i->second;
107 
108  FieldPresenceMap::const_iterator iter = presenceMap.begin();
109  for ( ; iter != presenceMap.end(); ++iter )
110  {
111  addGroup( iter->first, i->first, iter->second.first, *iter->second.second );
112  }
113  }
114  return *this;
115 }
MsgTypeToField m_requiredFields
OrderedFields m_orderedFields
void addGroup(const std::string &msg, int field, int delim, const DataDictionary &dataDictionary)
NonBodyFields m_headerFields
FieldToName m_fieldNames
BeginString m_beginString
MsgTypeToField m_messageFields
FieldToValue m_fieldValues
ValueToName m_valueNames
std::map< std::string, std::pair< int, DataDictionary *> > FieldPresenceMap
NonBodyFields m_trailerFields
OrderedFieldsArray m_orderedFieldsArray

◆ readFromDocument()

void FIX::DataDictionary::readFromDocument ( DOMDocumentPtr  pDoc)
throw (ConfigError
)

Definition at line 220 of file DataDictionary.cpp.

References addField(), addFieldName(), addFieldType(), addFieldValue(), addHeaderField(), addMsgField(), addMsgType(), addRequiredField(), addTrailerField(), addValueName(), addXMLComponentFields(), addXMLGroup(), lookupXMLFieldNumber(), RESET_AUTO_PTR, setVersion(), and XMLTypeToType().

Referenced by readFromStream(), and readFromURL().

222 {
223  // VERSION
224  DOMNodePtr pFixNode = pDoc->getNode("/fix");
225  if(!pFixNode.get())
226  throw ConfigError("Could not parse data dictionary file"
227  ", or no <fix> node found at root");
228  DOMAttributesPtr attrs = pFixNode->getAttributes();
229  std::string type = "FIX";
230  if(attrs->get("type", type))
231  {
232  if(type != "FIX" && type != "FIXT")
233  throw ConfigError("type attribute must be FIX or FIXT");
234  }
235  std::string major;
236  if(!attrs->get("major", major))
237  throw ConfigError("major attribute not found on <fix>");
238  std::string minor;
239  if(!attrs->get("minor", minor))
240  throw ConfigError("minor attribute not found on <fix>");
241  setVersion(type + "." + major + "." + minor);
242 
243  // FIELDS
244  DOMNodePtr pFieldsNode = pDoc->getNode("/fix/fields");
245  if(!pFieldsNode.get())
246  throw ConfigError("<fields> section not found in data dictionary");
247 
248  DOMNodePtr pFieldNode = pFieldsNode->getFirstChildNode();
249  if(!pFieldNode.get()) throw ConfigError("No fields defined");
250 
251  while(pFieldNode.get())
252  {
253  if(pFieldNode->getName() == "field")
254  {
255  DOMAttributesPtr attrs = pFieldNode->getAttributes();
256  std::string name;
257  if(!attrs->get("name", name))
258  throw ConfigError("<field> does not have a name attribute");
259  std::string number;
260  if(!attrs->get("number", number))
261  throw ConfigError("<field> " + name + " does not have a number attribute");
262  int num = atoi(number.c_str());
263  std::string type;
264  if(!attrs->get("type", type))
265  throw ConfigError("<field> " + name + " does not have a type attribute");
266  addField(num);
267  addFieldType(num, XMLTypeToType(type));
268  addFieldName(num, name);
269 
270  DOMNodePtr pFieldValueNode = pFieldNode->getFirstChildNode();
271  while(pFieldValueNode.get())
272  {
273  if(pFieldValueNode->getName() == "value")
274  {
275  DOMAttributesPtr attrs = pFieldValueNode->getAttributes();
276  std::string enumeration;
277  if(!attrs->get("enum", enumeration))
278  throw ConfigError("<value> does not have enum attribute in field " + name);
279  addFieldValue(num, enumeration);
280  std::string description;
281  if(attrs->get("description", description))
282  addValueName(num, enumeration, description);
283  }
284  RESET_AUTO_PTR(pFieldValueNode, pFieldValueNode->getNextSiblingNode());
285  }
286  }
287  RESET_AUTO_PTR(pFieldNode, pFieldNode->getNextSiblingNode());
288  }
289 
290  // HEADER
291  if( type == "FIXT" || (type == "FIX" && major < "5") )
292  {
293  DOMNodePtr pHeaderNode = pDoc->getNode("/fix/header");
294  if(!pHeaderNode.get())
295  throw ConfigError("<header> section not found in data dictionary");
296 
297  DOMNodePtr pHeaderFieldNode = pHeaderNode->getFirstChildNode();
298  if(!pHeaderFieldNode.get()) throw ConfigError("No header fields defined");
299 
300  while(pHeaderFieldNode.get())
301  {
302  if(pHeaderFieldNode->getName() == "field" || pHeaderFieldNode->getName() == "group" )
303  {
304  DOMAttributesPtr attrs = pHeaderFieldNode->getAttributes();
305  std::string name;
306  if(!attrs->get("name", name))
307  throw ConfigError("<field> does not have a name attribute");
308  std::string required = "false";
309  attrs->get("required", required);
310  addHeaderField(lookupXMLFieldNumber(pDoc.get(), name), required == "true");
311  }
312  if(pHeaderFieldNode->getName() == "group")
313  {
314  DOMAttributesPtr attrs = pHeaderFieldNode->getAttributes();
315  std::string required;
316  attrs->get("required", required);
317  bool isRequired = (required == "Y" || required == "y");
318  addXMLGroup(pDoc.get(), pHeaderFieldNode.get(), "_header_", *this, isRequired);
319  }
320 
321  RESET_AUTO_PTR(pHeaderFieldNode, pHeaderFieldNode->getNextSiblingNode());
322  }
323  }
324 
325  // TRAILER
326  if( type == "FIXT" || (type == "FIX" && major < "5") )
327  {
328  DOMNodePtr pTrailerNode = pDoc->getNode("/fix/trailer");
329  if(!pTrailerNode.get())
330  throw ConfigError("<trailer> section not found in data dictionary");
331 
332  DOMNodePtr pTrailerFieldNode = pTrailerNode->getFirstChildNode();
333  if(!pTrailerFieldNode.get()) throw ConfigError("No trailer fields defined");
334 
335  while(pTrailerFieldNode.get())
336  {
337  if(pTrailerFieldNode->getName() == "field" || pTrailerFieldNode->getName() == "group" )
338  {
339  DOMAttributesPtr attrs = pTrailerFieldNode->getAttributes();
340  std::string name;
341  if(!attrs->get("name", name))
342  throw ConfigError("<field> does not have a name attribute");
343  std::string required = "false";
344  attrs->get("required", required);
345  addTrailerField(lookupXMLFieldNumber(pDoc.get(), name), required == "true");
346  }
347  if(pTrailerFieldNode->getName() == "group")
348  {
349  DOMAttributesPtr attrs = pTrailerFieldNode->getAttributes();
350  std::string required;
351  attrs->get("required", required);
352  bool isRequired = (required == "Y" || required == "y");
353  addXMLGroup(pDoc.get(), pTrailerFieldNode.get(), "_trailer_", *this, isRequired);
354  }
355 
356  RESET_AUTO_PTR(pTrailerFieldNode, pTrailerFieldNode->getNextSiblingNode());
357  }
358  }
359 
360  // MSGTYPE
361  DOMNodePtr pMessagesNode = pDoc->getNode("/fix/messages");
362  if(!pMessagesNode.get())
363  throw ConfigError("<messages> section not found in data dictionary");
364 
365  DOMNodePtr pMessageNode = pMessagesNode->getFirstChildNode();
366  if(!pMessageNode.get()) throw ConfigError("No messages defined");
367 
368  while(pMessageNode.get())
369  {
370  if(pMessageNode->getName() == "message")
371  {
372  DOMAttributesPtr attrs = pMessageNode->getAttributes();
373  std::string msgtype;
374  if(!attrs->get("msgtype", msgtype))
375  throw ConfigError("<field> does not have a name attribute");
376  addMsgType(msgtype);
377 
378  std::string name;
379  if(attrs->get("name", name))
380  addValueName( 35, msgtype, name );
381 
382  DOMNodePtr pMessageFieldNode = pMessageNode->getFirstChildNode();
383  while( pMessageFieldNode.get() )
384  {
385  if(pMessageFieldNode->getName() == "field"
386  || pMessageFieldNode->getName() == "group")
387  {
388  DOMAttributesPtr attrs = pMessageFieldNode->getAttributes();
389  std::string name;
390  if(!attrs->get("name", name))
391  throw ConfigError("<field> does not have a name attribute");
392  int num = lookupXMLFieldNumber(pDoc.get(), name);
393  addMsgField(msgtype, num);
394 
395  std::string required;
396  if(attrs->get("required", required)
397  && (required == "Y" || required == "y"))
398  {
399  addRequiredField(msgtype, num);
400  }
401  }
402  else if(pMessageFieldNode->getName() == "component")
403  {
404  DOMAttributesPtr attrs = pMessageFieldNode->getAttributes();
405  std::string required;
406  attrs->get("required", required);
407  bool isRequired = (required == "Y" || required == "y");
408  addXMLComponentFields(pDoc.get(), pMessageFieldNode.get(),
409  msgtype, *this, isRequired);
410  }
411  if(pMessageFieldNode->getName() == "group")
412  {
413  DOMAttributesPtr attrs = pMessageFieldNode->getAttributes();
414  std::string required;
415  attrs->get("required", required);
416  bool isRequired = (required == "Y" || required == "y");
417  addXMLGroup(pDoc.get(), pMessageFieldNode.get(), msgtype, *this, isRequired);
418  }
419  RESET_AUTO_PTR(pMessageFieldNode,
420  pMessageFieldNode->getNextSiblingNode());
421  }
422  }
423  RESET_AUTO_PTR(pMessageNode, pMessageNode->getNextSiblingNode());
424  }
425 }
std::auto_ptr< DOMAttributes > DOMAttributesPtr
Definition: DOMDocument.h:43
void addMsgField(const std::string &msgType, int field)
void addTrailerField(int field, bool required)
void addXMLGroup(DOMDocument *, DOMNode *, const std::string &msgtype, DataDictionary &, bool)
#define RESET_AUTO_PTR(OLD, NEW)
int addXMLComponentFields(DOMDocument *, DOMNode *, const std::string &msgtype, DataDictionary &, bool)
void addHeaderField(int field, bool required)
void addValueName(int field, const std::string &value, const std::string &name)
std::auto_ptr< DOMNode > DOMNodePtr
Definition: DOMDocument.h:57
int lookupXMLFieldNumber(DOMDocument *, DOMNode *) const
void addField(int field)
void addFieldName(int field, const std::string &name)
void setVersion(const std::string &beginString)
void addFieldValue(int field, const std::string &value)
void addMsgType(const std::string &msgType)
void addFieldType(int field, FIX::TYPE::Type type)
TYPE::Type XMLTypeToType(const std::string &xmlType) const
void addRequiredField(const std::string &msgType, int field)

◆ readFromStream()

void FIX::DataDictionary::readFromStream ( std::istream &  stream)
throw (ConfigError
)

Definition at line 209 of file DataDictionary.cpp.

References readFromDocument().

Referenced by DataDictionary().

211 {
212  DOMDocumentPtr pDoc = DOMDocumentPtr(new PUGIXML_DOMDocument());
213 
214  if(!pDoc->load(stream))
215  throw ConfigError("Could not parse data dictionary stream");
216 
217  readFromDocument( pDoc );
218 }
void readFromDocument(DOMDocumentPtr pDoc)
std::auto_ptr< DOMDocument > DOMDocumentPtr
Definition: DOMDocument.h:71

◆ readFromURL()

void FIX::DataDictionary::readFromURL ( const std::string &  url)
throw (ConfigError
)

Definition at line 191 of file DataDictionary.cpp.

References readFromDocument().

Referenced by DataDictionary().

193 {
194  DOMDocumentPtr pDoc = DOMDocumentPtr(new PUGIXML_DOMDocument());
195 
196  if(!pDoc->load(url))
197  throw ConfigError(url + ": Could not parse data dictionary file");
198 
199  try
200  {
201  readFromDocument( pDoc );
202  }
203  catch( ConfigError& e )
204  {
205  throw ConfigError( url + ": " + e.what() );
206  }
207 }
void readFromDocument(DOMDocumentPtr pDoc)
std::auto_ptr< DOMDocument > DOMDocumentPtr
Definition: DOMDocument.h:71

◆ setVersion()

void FIX::DataDictionary::setVersion ( const std::string &  beginString)
inline

Definition at line 86 of file DataDictionary.h.

References m_beginString, and m_hasVersion.

Referenced by addGroup(), and readFromDocument().

87  {
88  m_beginString = beginString;
89  m_hasVersion = true;
90  }
BeginString m_beginString

◆ shouldCheckTag()

bool FIX::DataDictionary::shouldCheckTag ( const FieldBase field) const
inlineprivate

If we need to check for the tag in the dictionary.

Definition at line 331 of file DataDictionary.h.

References FIX::FieldBase::getField(), m_checkUserDefinedFields, and FIX::FIELD::UserMin.

Referenced by iterate().

332  {
333  if( !m_checkUserDefinedFields && field.getField() >= FIELD::UserMin )
334  return false;
335  else
336  return true;
337  }
const int UserMin
Definition: FieldNumbers.h:40

◆ validate() [1/3]

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 117 of file DataDictionary.cpp.

References FIX::FIELD::BeginString, FIELD_GET_REF, and FIX::FIELD::MsgType.

Referenced by checkUserDefinedFields(), FIX::Session::next(), and validate().

121 {
122  const Header& header = message.getHeader();
123  const BeginString& beginString = FIELD_GET_REF( header, BeginString );
124  const MsgType& msgType = FIELD_GET_REF( header, MsgType );
125  if ( pSessionDD != 0 && pSessionDD->m_hasVersion )
126  {
127  if( pSessionDD->getVersion() != beginString )
128  {
129  throw UnsupportedVersion();
130  }
131  }
132 
133  int field = 0;
134  if( (pSessionDD !=0 && pSessionDD->m_checkFieldsOutOfOrder) ||
135  (pAppDD != 0 && pAppDD->m_checkFieldsOutOfOrder) )
136  {
137  if ( !message.hasValidStructure(field) )
138  throw TagOutOfOrder(field);
139  }
140 
141  if ( pAppDD != 0 && pAppDD->m_hasVersion )
142  {
143  pAppDD->checkMsgType( msgType );
144  pAppDD->checkHasRequired( message.getHeader(), message, message.getTrailer(), msgType );
145  }
146 
147  if( pSessionDD != 0 )
148  {
149  pSessionDD->iterate( message.getHeader(), msgType );
150  pSessionDD->iterate( message.getTrailer(), msgType );
151  }
152 
153  if( pAppDD != 0 )
154  {
155  pAppDD->iterate( message, msgType );
156  }
157 }
const int BeginString
#define FIELD_GET_REF(MAP, FLD)
Definition: FieldMap.h:238
const int MsgType

◆ validate() [2/3]

void FIX::DataDictionary::validate ( const Message message) const
throw (FIX::Exception
)
inline

Definition at line 312 of file DataDictionary.h.

References validate().

313  { validate( message, false ); }
static void validate(const Message &message, const DataDictionary *const pSessionDD, const DataDictionary *const pAppID)
Validate a message.

◆ validate() [3/3]

void FIX::DataDictionary::validate ( const Message message,
bool  bodyOnly 
) const
throw (FIX::Exception
)
inline

Definition at line 314 of file DataDictionary.h.

References iterate(), FIX::FIELD::MsgType, operator=(), and validate().

315  { validate( message, bodyOnly ? (DataDictionary*)0 : this, this ); }
static void validate(const Message &message, const DataDictionary *const pSessionDD, const DataDictionary *const pAppID)
Validate a message.

◆ XMLTypeToType()

TYPE::Type FIX::DataDictionary::XMLTypeToType ( const std::string &  xmlType) const
private

Definition at line 583 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, 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.

Referenced by checkHasRequired(), and readFromDocument().

584 {
585  if ( m_beginString < "FIX.4.2" && type == "CHAR" )
586  return TYPE::String;
587 
588  if ( type == "STRING" ) return TYPE::String;
589  if ( type == "CHAR" ) return TYPE::Char;
590  if ( type == "PRICE" ) return TYPE::Price;
591  if ( type == "INT" ) return TYPE::Int;
592  if ( type == "AMT" ) return TYPE::Amt;
593  if ( type == "QTY" ) return TYPE::Qty;
594  if ( type == "CURRENCY" ) return TYPE::Currency;
595  if ( type == "MULTIPLEVALUESTRING" ) return TYPE::MultipleValueString;
596  if ( type == "MULTIPLESTRINGVALUE" ) return TYPE::MultipleStringValue;
597  if ( type == "MULTIPLECHARVALUE" ) return TYPE::MultipleCharValue;
598  if ( type == "EXCHANGE" ) return TYPE::Exchange;
599  if ( type == "UTCTIMESTAMP" ) return TYPE::UtcTimeStamp;
600  if ( type == "BOOLEAN" ) return TYPE::Boolean;
601  if ( type == "LOCALMKTDATE" ) return TYPE::LocalMktDate;
602  if ( type == "DATA" ) return TYPE::Data;
603  if ( type == "FLOAT" ) return TYPE::Float;
604  if ( type == "PRICEOFFSET" ) return TYPE::PriceOffset;
605  if ( type == "MONTHYEAR" ) return TYPE::MonthYear;
606  if ( type == "DAYOFMONTH" ) return TYPE::DayOfMonth;
607  if ( type == "UTCDATE" ) return TYPE::UtcDate;
608  if ( type == "UTCDATEONLY" ) return TYPE::UtcDateOnly;
609  if ( type == "UTCTIMEONLY" ) return TYPE::UtcTimeOnly;
610  if ( type == "NUMINGROUP" ) return TYPE::NumInGroup;
611  if ( type == "PERCENTAGE" ) return TYPE::Percentage;
612  if ( type == "SEQNUM" ) return TYPE::SeqNum;
613  if ( type == "LENGTH" ) return TYPE::Length;
614  if ( type == "COUNTRY" ) return TYPE::Country;
615  if ( type == "TIME" ) return TYPE::UtcTimeStamp;
616  return TYPE::Unknown;
617 }
BeginString m_beginString

Member Data Documentation

◆ m_beginString

BeginString FIX::DataDictionary::m_beginString
private

Definition at line 520 of file DataDictionary.h.

Referenced by getVersion(), iterate(), operator=(), setVersion(), and XMLTypeToType().

◆ m_checkFieldsHaveValues

bool FIX::DataDictionary::m_checkFieldsHaveValues
private

Definition at line 518 of file DataDictionary.h.

Referenced by checkFieldsHaveValues(), checkHasValue(), and operator=().

◆ m_checkFieldsOutOfOrder

bool FIX::DataDictionary::m_checkFieldsOutOfOrder
private

Definition at line 517 of file DataDictionary.h.

Referenced by checkFieldsOutOfOrder(), and operator=().

◆ m_checkUserDefinedFields

bool FIX::DataDictionary::m_checkUserDefinedFields
private

Definition at line 519 of file DataDictionary.h.

Referenced by checkUserDefinedFields(), operator=(), and shouldCheckTag().

◆ m_dataFields

MsgFields FIX::DataDictionary::m_dataFields
private

Definition at line 535 of file DataDictionary.h.

Referenced by addFieldType(), isDataField(), and operator=().

◆ m_fieldNames

FieldToName FIX::DataDictionary::m_fieldNames
private

Definition at line 531 of file DataDictionary.h.

Referenced by addFieldName(), getFieldName(), and operator=().

◆ m_fields

Fields FIX::DataDictionary::m_fields
private

Definition at line 524 of file DataDictionary.h.

Referenced by addField(), checkValidTagNumber(), isField(), and operator=().

◆ m_fieldTypes

FieldTypes FIX::DataDictionary::m_fieldTypes
private

Definition at line 529 of file DataDictionary.h.

Referenced by addFieldType(), getFieldType(), isMultipleValueField(), and operator=().

◆ m_fieldValues

FieldToValue FIX::DataDictionary::m_fieldValues
private

Definition at line 530 of file DataDictionary.h.

Referenced by addFieldValue(), hasFieldValue(), isFieldValue(), and operator=().

◆ m_groups

FieldToGroup FIX::DataDictionary::m_groups
private

Definition at line 534 of file DataDictionary.h.

Referenced by addGroup(), getGroup(), isGroup(), operator=(), and ~DataDictionary().

◆ m_hasVersion

bool FIX::DataDictionary::m_hasVersion
private

Definition at line 516 of file DataDictionary.h.

Referenced by iterate(), operator=(), and setVersion().

◆ m_headerFields

NonBodyFields FIX::DataDictionary::m_headerFields
private

Definition at line 527 of file DataDictionary.h.

Referenced by addHeaderField(), checkHasRequired(), isHeaderField(), and operator=().

◆ m_messageFields

MsgTypeToField FIX::DataDictionary::m_messageFields
private

Definition at line 521 of file DataDictionary.h.

Referenced by addMsgField(), isMsgField(), and operator=().

◆ m_messages

MsgTypes FIX::DataDictionary::m_messages
private

Definition at line 523 of file DataDictionary.h.

Referenced by addMsgType(), isMsgType(), and operator=().

◆ m_names

NameToField FIX::DataDictionary::m_names
private

Definition at line 532 of file DataDictionary.h.

Referenced by addFieldName(), getFieldTag(), lookupXMLFieldNumber(), and operator=().

◆ m_orderedFields

OrderedFields FIX::DataDictionary::m_orderedFields
private

Definition at line 525 of file DataDictionary.h.

Referenced by addField(), getOrderedFields(), and operator=().

◆ m_orderedFieldsArray

OrderedFieldsArray FIX::DataDictionary::m_orderedFieldsArray
mutableprivate

Definition at line 526 of file DataDictionary.h.

Referenced by getOrderedFields(), and operator=().

◆ m_requiredFields

MsgTypeToField FIX::DataDictionary::m_requiredFields
private

Definition at line 522 of file DataDictionary.h.

Referenced by addRequiredField(), checkHasRequired(), isRequiredField(), and operator=().

◆ m_trailerFields

NonBodyFields FIX::DataDictionary::m_trailerFields
private

Definition at line 528 of file DataDictionary.h.

Referenced by addTrailerField(), checkHasRequired(), isTrailerField(), and operator=().

◆ m_valueNames

ValueToName FIX::DataDictionary::m_valueNames
private

Definition at line 533 of file DataDictionary.h.

Referenced by addValueName(), getValueName(), and operator=().


The documentation for this class was generated from the following files:

Generated on Thu Sep 5 2019 11:07:58 for QuickFIX by doxygen 1.8.13 written by Dimitri van Heesch, © 1997-2001