Index  Source Files  Annotated Class List  Alphabetical Class List  Class Hierarchy  Graphical Class Hierarchy   
 

FIX::FieldMap Class Reference

Stores and organizes a collection of Fields. More...

#include <FieldMap.h>

Inheritance diagram for FIX::FieldMap:

Inheritance graph
[legend]
List of all members.

Public Types

typedef std::multimap< int,
FieldBase, message_order
Fields
typedef std::map< int, std::vector<
FieldMap * > > 
Groups
typedef Fields::const_iterator iterator
typedef iterator const_iterator
typedef Groups::const_iterator g_iterator
typedef Groups::const_iterator g_const_iterator

Public Member Functions

 FieldMap (const message_order &order=message_order(message_order::normal))
 FieldMap (const int order[])
 FieldMap (const FieldMap &copy)
virtual ~FieldMap ()
FieldMapoperator= (const FieldMap &rhs)
void setField (const FieldBase &field, bool overwrite=true) throw ( RepeatedTag )
 Set a field without type checking.

void setField (int field, const std::string &value) throw ( RepeatedTag, NoTagValue )
 Set a field without a field class.

FieldBasegetField (FieldBase &field) const throw ( FieldNotFound )
 Get a field without type checking.

std::string getField (int field) const throw ( FieldNotFound )
 Get a field without a field class.

bool isSetField (const FieldBase &field) const
 Check to see if a field is set.

bool isSetField (int field) const
 Check to see if a field is set by referencing its number.

void removeField (int field)
 Remove a field. If field is not present, this is a no-op.

void addGroup (int field, const FieldMap &group, bool setCount=true)
 Add a group.

void replaceGroup (int num, int field, FieldMap &group)
 Replace a specific instanct of a group.

FieldMapgetGroup (int num, int field, FieldMap &group) const throw ( FieldNotFound )
 Get a specific instance of a group.

void removeGroup (int num, int field)
 Remove a specific instance of a group.

void removeGroup (int field)
 Remove all instances of a group.

bool hasGroup (int field) const
 Check to see any instance of a group exists.

bool hasGroup (int num, int field) const
 Check to see if a specific instance of a group exists.

int groupCount (int field) const
 Count the number of instance of a group.

void clear ()
 Clear all fields from the map.

bool isEmpty ()
 Check if map contains any fields.

std::string & calculateString (std::string &, bool clear=true) const
int calculateLength (int beginStringField=FIELD::BeginString, int bodyLengthField=FIELD::BodyLength, int checkSumField=FIELD::CheckSum) const
int calculateTotal (int checkSumField=FIELD::CheckSum) const
iterator begin () const
iterator end () const
g_iterator g_begin () const
g_iterator g_end () const

Private Attributes

Fields m_fields
Groups m_groups

Detailed Description

Stores and organizes a collection of Fields.

This is the basis for a message, header, and trailer. This collection class uses a sorter to keep the fields in a particular order.

Definition at line 46 of file FieldMap.h.


Member Typedef Documentation

typedef iterator FIX::FieldMap::const_iterator
 

Definition at line 52 of file FieldMap.h.

typedef std::multimap< int, FieldBase, message_order > FIX::FieldMap::Fields
 

Definition at line 49 of file FieldMap.h.

typedef Groups::const_iterator FIX::FieldMap::g_const_iterator
 

Definition at line 54 of file FieldMap.h.

typedef Groups::const_iterator FIX::FieldMap::g_iterator
 

Definition at line 53 of file FieldMap.h.

Referenced by FIX::DataDictionary::checkHasRequired(), g_begin(), g_end(), and FIX::Message::toXMLFields().

typedef std::map< int, std::vector < FieldMap* > > FIX::FieldMap::Groups
 

Definition at line 50 of file FieldMap.h.

typedef Fields::const_iterator FIX::FieldMap::iterator
 

Definition at line 51 of file FieldMap.h.

Referenced by begin(), end(), FIX::DataDictionary::iterate(), and FIX::Message::toXMLFields().


Constructor & Destructor Documentation

FIX::FieldMap::FieldMap const message_order order = message_order( message_order::normal )  )  [inline]
 

Definition at line 56 of file FieldMap.h.

Referenced by addGroup().

00058   : m_fields( order ) {}

FIX::FieldMap::FieldMap const int  order[]  )  [inline]
 

Definition at line 60 of file FieldMap.h.

00061   : m_fields( message_order(order) ) {}

FIX::FieldMap::FieldMap const FieldMap copy  )  [inline]
 

Definition at line 63 of file FieldMap.h.

00064   { *this = copy; }

FIX::FieldMap::~FieldMap  )  [virtual]
 

Definition at line 33 of file FieldMap.cpp.

References clear(), QF_STACK_IGNORE_BEGIN, and QF_STACK_IGNORE_END.

00034 { QF_STACK_IGNORE_BEGIN
00035   clear();
00036   QF_STACK_IGNORE_END
00037 }


Member Function Documentation

void FIX::FieldMap::addGroup int  field,
const FieldMap group,
bool  setCount = true
 

Add a group.

Definition at line 60 of file FieldMap.cpp.

References FieldMap(), m_fields, QF_STACK_POP, QF_STACK_PUSH, and setField().

Referenced by operator=(), and FIX::Message::setGroup().

00061 { QF_STACK_PUSH(FieldMap::addGroup)
00062 
00063   FieldMap * pGroup = new FieldMap( group.m_fields.key_comp() );
00064   *pGroup = group;
00065   m_groups[ field ].push_back( pGroup );
00066   Groups::iterator i = m_groups.find( field );
00067   if( setCount )
00068     setField( IntField( field, i->second.size() ) );
00069 
00070   QF_STACK_POP
00071 }

iterator FIX::FieldMap::begin  )  const [inline]
 

Definition at line 157 of file FieldMap.h.

References iterator.

Referenced by FIX::DataDictionary::iterate(), and FIX::Message::toXMLFields().

00157 { return m_fields.begin(); }

int FIX::FieldMap::calculateLength int  beginStringField = FIELD::BeginString,
int  bodyLengthField = FIELD::BodyLength,
int  checkSumField = FIELD::CheckSum
const
 

Definition at line 226 of file FieldMap.cpp.

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

00229 {
00230   int result = 0;
00231   Fields::const_iterator i;
00232   for ( i = m_fields.begin(); i != m_fields.end(); ++i )
00233   {
00234     if ( i->first != beginStringField
00235          && i->first != bodyLengthField
00236          && i->first != checkSumField )
00237     { result += i->second.getLength(); }
00238   }
00239 
00240   Groups::const_iterator j;
00241   for ( j = m_groups.begin(); j != m_groups.end(); ++j )
00242   {
00243     std::vector < FieldMap* > ::const_iterator k;
00244     for ( k = j->second.begin(); k != j->second.end(); ++k )
00245       result += ( *k ) ->calculateLength();
00246   }
00247   return result;
00248 }

std::string & FIX::FieldMap::calculateString std::string &  ,
bool  clear = true
const
 

Definition at line 199 of file FieldMap.cpp.

References QF_STACK_POP, and QF_STACK_PUSH.

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

00200 { QF_STACK_PUSH(FieldMap::calculateString)
00201 
00202 #if defined(_MSC_VER) && _MSC_VER < 1300
00203   if( clear ) result = "";
00204 #else
00205   if( clear ) result.clear();
00206 #endif
00207 
00208   Fields::const_iterator i;
00209   for ( i = m_fields.begin(); i != m_fields.end(); ++i )
00210   {
00211     result += i->second.getValue();
00212 
00213     // add groups if they exist
00214     if( !m_groups.size() ) continue;
00215     Groups::const_iterator j = m_groups.find( i->first );
00216     if ( j == m_groups.end() ) continue;
00217     std::vector < FieldMap* > ::const_iterator k;
00218     for ( k = j->second.begin(); k != j->second.end(); ++k )
00219       ( *k ) ->calculateString( result, false );
00220   }
00221   return result;
00222 
00223   QF_STACK_POP
00224 }

int FIX::FieldMap::calculateTotal int  checkSumField = FIELD::CheckSum  )  const
 

Definition at line 250 of file FieldMap.cpp.

References QF_STACK_POP, and QF_STACK_PUSH.

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

00251 { QF_STACK_PUSH(FieldMap::calculateTotal)
00252 
00253   int result = 0;
00254   Fields::const_iterator i;
00255   for ( i = m_fields.begin(); i != m_fields.end(); ++i )
00256   {
00257     if ( i->first != checkSumField )
00258       result += i->second.getTotal();
00259   }
00260 
00261   Groups::const_iterator j;
00262   for ( j = m_groups.begin(); j != m_groups.end(); ++j )
00263   {
00264     std::vector < FieldMap* > ::const_iterator k;
00265     for ( k = j->second.begin(); k != j->second.end(); ++k )
00266       result += ( *k ) ->calculateTotal();
00267   }
00268   return result;
00269 
00270   QF_STACK_POP
00271 }

void FIX::FieldMap::clear  ) 
 

Clear all fields from the map.

Reimplemented in FIX::Message.

Definition at line 176 of file FieldMap.cpp.

References QF_STACK_POP, and QF_STACK_PUSH.

Referenced by FIX::Message::clear(), FIX::Message::getGroup(), operator=(), and ~FieldMap().

00177 { QF_STACK_PUSH(FieldMap::clear)
00178 
00179   m_fields.clear();
00180 
00181   Groups::iterator i;
00182   for ( i = m_groups.begin(); i != m_groups.end(); ++i )
00183   {
00184     std::vector < FieldMap* > ::iterator j;
00185     for ( j = i->second.begin(); j != i->second.end(); ++j )
00186       delete *j;
00187   }
00188   m_groups.clear();
00189 
00190   QF_STACK_POP
00191 }

iterator FIX::FieldMap::end  )  const [inline]
 

Definition at line 158 of file FieldMap.h.

References iterator.

Referenced by FIX::DataDictionary::iterate(), and FIX::Message::toXMLFields().

00158 { return m_fields.end(); }

g_iterator FIX::FieldMap::g_begin  )  const [inline]
 

Definition at line 159 of file FieldMap.h.

References g_iterator.

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

00159 { return m_groups.begin(); }

g_iterator FIX::FieldMap::g_end  )  const [inline]
 

Definition at line 160 of file FieldMap.h.

References g_iterator.

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

00160 { return m_groups.end(); }

std::string FIX::FieldMap::getField int  field  )  const throw ( FieldNotFound ) [inline]
 

Get a field without a field class.

Definition at line 104 of file FieldMap.h.

References getField(), and FIX::FieldBase::getString().

00106   {
00107     FieldBase fieldBase( field, "" );
00108     getField( fieldBase );
00109     return fieldBase.getString();
00110   }

FieldBase& FIX::FieldMap::getField FieldBase field  )  const throw ( FieldNotFound ) [inline]
 

Get a field without type checking.

Definition at line 94 of file FieldMap.h.

Referenced by FIX::MessageCracker::crack(), FIX::Session::doPossDup(), FIX::Session::doTargetTooHigh(), FIX::Session::doTargetTooLow(), FIX::Session::generateBusinessReject(), FIX::Session::generateHeartbeat(), FIX::Session::generateLogon(), FIX::Session::generateReject(), FIX::Session::generateSequenceReset(), getField(), FIX::Acceptor::getSession(), FIX::Message::isAdmin(), FIX::Message::isApp(), FIX::Session::lookupSession(), FIX::Message::Message::extractField(), FIX::Session::next(), FIX::Session::nextLogon(), FIX::Session::nextQueued(), FIX::Session::nextResendRequest(), FIX::Session::nextSequenceReset(), FIX::Session::resend(), FIX::Message::reverseRoute(), FIX::Session::sendRaw(), FIX::Message::validate(), and FIX::Session::verify().

00096   {
00097     Fields::const_iterator iter = m_fields.find( field.getField() );
00098     if ( iter == m_fields.end() )
00099       throw FieldNotFound( field.getField() );
00100     field = iter->second;
00101     return field;
00102   }

FieldMap & FIX::FieldMap::getGroup int  num,
int  field,
FieldMap group
const throw ( FieldNotFound )
 

Get a specific instance of a group.

Definition at line 85 of file FieldMap.cpp.

References QF_STACK_POP, and QF_STACK_PUSH.

00087 { QF_STACK_PUSH(FieldMap::getGroup)
00088 
00089   Groups::const_iterator i = m_groups.find( field );
00090   if ( i == m_groups.end() ) throw FieldNotFound( field );
00091   if ( num <= 0 ) throw FieldNotFound( field );
00092   if ( i->second.size() < ( unsigned ) num ) throw FieldNotFound( field );
00093   group = *( *( i->second.begin() + ( num - 1 ) ) );
00094   return group;
00095 
00096   QF_STACK_POP
00097 }

int FIX::FieldMap::groupCount int  field  )  const
 

Count the number of instance of a group.

Definition at line 165 of file FieldMap.cpp.

References QF_STACK_POP, and QF_STACK_PUSH.

Referenced by hasGroup(), and removeGroup().

00166 { QF_STACK_PUSH(FieldMap::groupCount)
00167 
00168   Groups::const_iterator i = m_groups.find( field );
00169   if( i == m_groups.end() )
00170     return 0;
00171   return i->second.size();
00172 
00173   QF_STACK_POP
00174 }

bool FIX::FieldMap::hasGroup int  num,
int  field
const
 

Check to see if a specific instance of a group exists.

Definition at line 148 of file FieldMap.cpp.

References groupCount(), QF_STACK_POP, and QF_STACK_PUSH.

00149 { QF_STACK_PUSH(FieldMap::hasGroup)
00150 
00151   return groupCount(field) >= num;
00152 
00153   QF_STACK_POP
00154 }

bool FIX::FieldMap::hasGroup int  field  )  const
 

Check to see any instance of a group exists.

Definition at line 156 of file FieldMap.cpp.

References QF_STACK_POP, and QF_STACK_PUSH.

00157 { QF_STACK_PUSH(FieldMap::hasGroup)
00158 
00159   Groups::const_iterator i = m_groups.find( field );
00160   return i != m_groups.end();
00161 
00162   QF_STACK_POP
00163 }

bool FIX::FieldMap::isEmpty  ) 
 

Check if map contains any fields.

Reimplemented in FIX::Message.

Definition at line 193 of file FieldMap.cpp.

References QF_STACK_POP, and QF_STACK_PUSH.

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

00194 { QF_STACK_PUSH(FieldMap::isEmpty)
00195   return m_fields.size() == 0;
00196   QF_STACK_POP
00197 }

bool FIX::FieldMap::isSetField int  field  )  const [inline]
 

Check to see if a field is set by referencing its number.

Definition at line 116 of file FieldMap.h.

00117   { return m_fields.find( field ) != m_fields.end(); }

bool FIX::FieldMap::isSetField const FieldBase field  )  const [inline]
 

Check to see if a field is set.

Definition at line 113 of file FieldMap.h.

References FIX::FieldBase::getField().

Referenced by FIX::Session::doPossDup(), FIX::Session::doTargetTooLow(), FIX::Session::generateReject(), FIX::Message::isAdmin(), FIX::Message::isApp(), FIX::Message::Message::extractField(), FIX::Session::nextLogon(), FIX::Session::nextSequenceReset(), FIX::Message::reverseRoute(), and FIX::Session::sendRaw().

00114   { return m_fields.find( field.getField() ) != m_fields.end(); }

FieldMap & FIX::FieldMap::operator= const FieldMap rhs  ) 
 

Definition at line 39 of file FieldMap.cpp.

References addGroup(), clear(), m_fields, m_groups, QF_STACK_POP, and QF_STACK_PUSH.

00040 { QF_STACK_PUSH(FieldMap::operator=)
00041 
00042   clear();
00043 
00044   std::copy( rhs.m_fields.begin (), rhs.m_fields.end(),
00045              std::inserter(m_fields, m_fields.begin()) );
00046 
00047   Groups::const_iterator i;
00048   for ( i = rhs.m_groups.begin(); i != rhs.m_groups.end(); ++i )
00049   {
00050     std::vector < FieldMap* > ::const_iterator j;
00051     for ( j = i->second.begin(); j != i->second.end(); ++j )
00052       addGroup( i->first, **j );
00053   }
00054 
00055   return *this;
00056 
00057   QF_STACK_POP
00058 }

void FIX::FieldMap::removeField int  field  ) 
 

Remove a field. If field is not present, this is a no-op.

Definition at line 138 of file FieldMap.cpp.

References QF_STACK_POP, and QF_STACK_PUSH.

Referenced by FIX::Message::reverseRoute(), and FIX::Session::send().

00139 { QF_STACK_PUSH(FieldMap::removeField)
00140 
00141   Fields::iterator i = m_fields.find( field );
00142   if ( i != m_fields.end() )
00143     m_fields.erase( i );
00144 
00145   QF_STACK_POP
00146 }

void FIX::FieldMap::removeGroup int  field  ) 
 

Remove all instances of a group.

Definition at line 132 of file FieldMap.cpp.

References groupCount(), QF_STACK_POP, QF_STACK_PUSH, and removeGroup().

00133 { QF_STACK_PUSH(FieldMap::removeGroup)
00134   removeGroup( groupCount(field), field );
00135   QF_STACK_POP
00136 }

void FIX::FieldMap::removeGroup int  num,
int  field
 

Remove a specific instance of a group.

Definition at line 99 of file FieldMap.cpp.

References groupCount(), and setField().

Referenced by removeGroup().

00100 {
00101   Groups::iterator i = m_groups.find( field );
00102   if ( i == m_groups.end() ) return;
00103   if ( num <= 0 ) return;
00104   std::vector< FieldMap* >& vector = i->second;
00105   if ( vector.size() < ( unsigned ) num ) return;
00106 
00107   std::deque< FieldMap* > queue;
00108   while( vector.size() > (unsigned)num )
00109   {
00110     queue.push_back( vector.back() );
00111     vector.pop_back();
00112   }
00113   delete vector.back();
00114   vector.pop_back();
00115   while( queue.size() )
00116   {
00117     vector.push_back( queue.front() );
00118     queue.pop_front();
00119   }
00120 
00121   if( vector.size() == 0 )
00122   {
00123     m_groups.erase( field );
00124   }
00125   else
00126   {
00127     IntField groupCount( field, vector.size() );
00128     setField( groupCount, true );
00129   }
00130 }

void FIX::FieldMap::replaceGroup int  num,
int  field,
FieldMap group
 

Replace a specific instanct of a group.

Definition at line 73 of file FieldMap.cpp.

References QF_STACK_POP, and QF_STACK_PUSH.

00074 { QF_STACK_PUSH(FieldMap::replaceGroup)
00075 
00076   Groups::const_iterator i = m_groups.find( field );
00077   if ( i == m_groups.end() ) return;
00078   if ( num <= 0 ) return;
00079   if ( i->second.size() < ( unsigned ) num ) return;
00080   *( *( i->second.begin() + ( num - 1 ) ) ) = group;
00081 
00082   QF_STACK_POP
00083 }

void FIX::FieldMap::setField int  field,
const std::string &  value
throw ( RepeatedTag, NoTagValue ) [inline]
 

Set a field without a field class.

Definition at line 86 of file FieldMap.h.

References setField().

00088   {
00089     FieldBase fieldBase( field, value );
00090     setField( fieldBase );
00091   }

void FIX::FieldMap::setField const FieldBase field,
bool  overwrite = true
throw ( RepeatedTag ) [inline]
 

Set a field without type checking.

Definition at line 71 of file FieldMap.h.

Referenced by addGroup(), FIX::Session::fill(), FIX::Session::generateBusinessReject(), FIX::Session::generateHeartbeat(), FIX::Session::generateLogon(), FIX::Session::generateLogout(), FIX::Session::generateReject(), FIX::Session::generateResendRequest(), FIX::Session::generateSequenceReset(), FIX::Session::generateTestRequest(), FIX::Session::insertOrigSendingTime(), FIX::Session::insertSendingTime(), FIX::Message::Message(), FIX::Session::populateRejectReason(), removeGroup(), FIX::Session::resend(), FIX::Message::reverseRoute(), FIX::Session::sendRaw(), setField(), FIX::Message::setGroup(), FIX::Message::setSessionID(), FIX::Message::setStringHeader(), and FIX::Message::toString().

00073   {
00074     Fields::iterator i = m_fields.find( field.getField() );
00075     if( i == m_fields.end() )
00076       m_fields.insert( Fields::value_type( field.getField(), field ) );
00077     else
00078     {
00079       if( overwrite )
00080         i->second = field;
00081       else
00082         m_fields.insert( Fields::value_type( field.getField(), field ) );
00083     }
00084   }


Member Data Documentation

Fields FIX::FieldMap::m_fields [private]
 

Definition at line 163 of file FieldMap.h.

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

Groups FIX::FieldMap::m_groups [private]
 

Definition at line 164 of file FieldMap.h.

Referenced by operator=().


The documentation for this class was generated from the following files:
Generated on Mon Jul 24 19:36:43 2006 for QuickFIX by doxygen 1.3.6-20040222 written by Dimitri van Heesch, © 1997-2001