Classes | Public Types | Public Member Functions | Protected Member Functions | Private Types | Private Member Functions | Private Attributes | Friends | List of all members
FIX::FieldMap Class Reference

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

#include <FieldMap.h>

Inheritance diagram for FIX::FieldMap:
Inheritance graph
[legend]
Collaboration diagram for FIX::FieldMap:
Collaboration graph
[legend]

Classes

class  finder
 
class  sorter
 

Public Types

typedef std::vector< FieldBase, ALLOCATOR< FieldBase > > Fields
 
typedef std::map< int, std::vector< FieldMap * >, std::less< int >, ALLOCATOR< std::pair< const int, std::vector< FieldMap * > > > > Groups
 
typedef Fields::iterator iterator
 
typedef Fields::const_iterator const_iterator
 
typedef Groups::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. More...
 
void setField (int tag, const std::string &value) throw ( RepeatedTag, NoTagValue )
 Set a field without a field class. More...
 
bool getFieldIfSet (FieldBase &field) const
 Get a field if set. More...
 
FieldBasegetField (FieldBase &field) const throw ( FieldNotFound )
 Get a field without type checking. More...
 
const std::string & getField (int tag) const throw ( FieldNotFound )
 Get a field without a field class. More...
 
const FieldBasegetFieldRef (int tag) const throw ( FieldNotFound )
 Get direct access to a field through a reference. More...
 
const FieldBase *const getFieldPtr (int tag) const throw ( FieldNotFound )
 Get direct access to a field through a pointer. More...
 
bool isSetField (const FieldBase &field) const
 Check to see if a field is set. More...
 
bool isSetField (int tag) const
 Check to see if a field is set by referencing its number. More...
 
void removeField (int tag)
 Remove a field. If field is not present, this is a no-op. More...
 
void addGroup (int tag, const FieldMap &group, bool setCount=true)
 Add a group. More...
 
void addGroupPtr (int tag, FieldMap *group, bool setCount=true)
 Acquire ownership of Group object. More...
 
void replaceGroup (int num, int tag, const FieldMap &group)
 Replace a specific instance of a group. More...
 
FieldMapgetGroup (int num, int tag, FieldMap &group) const throw ( FieldNotFound )
 Get a specific instance of a group. More...
 
FieldMapgetGroupRef (int num, int tag) const throw ( FieldNotFound )
 Get direct access to a field through a reference. More...
 
FieldMapgetGroupPtr (int num, int tag) const throw ( FieldNotFound )
 Get direct access to a field through a pointer. More...
 
void removeGroup (int num, int tag)
 Remove a specific instance of a group. More...
 
void removeGroup (int tag)
 Remove all instances of a group. More...
 
bool hasGroup (int tag) const
 Check to see any instance of a group exists. More...
 
bool hasGroup (int num, int tag) const
 Check to see if a specific instance of a group exists. More...
 
size_t groupCount (int tag) const
 Count the number of instance of a group. More...
 
void clear ()
 Clear all fields from the map. More...
 
bool isEmpty ()
 Check if map contains any fields. More...
 
size_t totalFields () const
 
std::string & calculateString (std::string &) 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 ()
 
iterator end ()
 
const_iterator begin () const
 
const_iterator end () const
 
g_iterator g_begin ()
 
g_iterator g_end ()
 
g_const_iterator g_begin () const
 
g_const_iterator g_end () const
 

Protected Member Functions

 FieldMap (const message_order &order, int size)
 
void addField (const FieldBase &field)
 
const FieldBasereverse_find (int tag) const
 
void appendField (const FieldBase &field)
 
void sortFields ()
 

Private Types

enum  { DEFAULT_SIZE = 16 }
 

Private Member Functions

Fields::const_iterator findTag (int tag) const
 
Fields::iterator findTag (int tag)
 
template<typename Iterator >
Iterator lookup (Iterator begin, Iterator end, int tag) const
 
Fields::iterator findPositionFor (int tag)
 

Private Attributes

Fields m_fields
 
Groups m_groups
 
message_order m_order
 

Friends

class Message
 

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 61 of file FieldMap.h.

Member Typedef Documentation

◆ const_iterator

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

Definition at line 131 of file FieldMap.h.

◆ Fields

typedef std::vector< FieldBase, ALLOCATOR< FieldBase > > FIX::FieldMap::Fields

Definition at line 126 of file FieldMap.h.

◆ g_const_iterator

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

Definition at line 133 of file FieldMap.h.

◆ g_iterator

typedef Groups::iterator FIX::FieldMap::g_iterator

Definition at line 132 of file FieldMap.h.

◆ Groups

typedef std::map< int, std::vector < FieldMap* >, std::less<int>, ALLOCATOR<std::pair<const int, std::vector< FieldMap* > > > > FIX::FieldMap::Groups

Definition at line 128 of file FieldMap.h.

◆ iterator

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

Definition at line 130 of file FieldMap.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
private
Enumerator
DEFAULT_SIZE 

Definition at line 118 of file FieldMap.h.

118 {

Constructor & Destructor Documentation

◆ FieldMap() [1/4]

FIX::FieldMap::FieldMap ( const message_order order,
int  size 
)
protected

Definition at line 49 of file FieldMap.cpp.

53 {

◆ FieldMap() [2/4]

FIX::FieldMap::FieldMap ( const message_order order = message_ordermessage_order::normal ))

Definition at line 55 of file FieldMap.cpp.

58 {
59  clear();

◆ FieldMap() [3/4]

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

Definition at line 61 of file FieldMap.cpp.

63 {
64  clear();
65 

References m_fields.

◆ FieldMap() [4/4]

FIX::FieldMap::FieldMap ( const FieldMap copy)

Definition at line 67 of file FieldMap.cpp.

71  {

◆ ~FieldMap()

FIX::FieldMap::~FieldMap ( )
virtual

Definition at line 72 of file FieldMap.cpp.

74  {
75  FieldMap * pGroup = new FieldMap( **j );

Member Function Documentation

◆ addField()

void FIX::FieldMap::addField ( const FieldBase field)
inlineprotected

Definition at line 302 of file FieldMap.h.

304  {
305  std::sort( m_fields.begin(), m_fields.end(), sorter(m_order) );
306  }
307 
308 private:
309 
310  Fields::const_iterator findTag( int tag ) const
311  {
312  return lookup( m_fields.begin(), m_fields.end(), tag );
313  }

References m_fields, m_order, and sort().

◆ addGroup()

void FIX::FieldMap::addGroup ( int  tag,
const FieldMap group,
bool  setCount = true 
)

Add a group.

Definition at line 98 of file FieldMap.cpp.

103 {

Referenced by FIX::Header::replaceGroup().

◆ addGroupPtr()

void FIX::FieldMap::addGroupPtr ( int  tag,
FieldMap group,
bool  setCount = true 
)

Acquire ownership of Group object.

Definition at line 105 of file FieldMap.cpp.

112 {
113  Groups::iterator i = m_groups.find( field );
114  if ( i == m_groups.end() ) return;
115  if ( num <= 0 ) return;

◆ appendField()

void FIX::FieldMap::appendField ( const FieldBase field)
inlineprotected

Definition at line 328 of file FieldMap.h.

◆ begin() [1/2]

iterator FIX::FieldMap::begin ( )
inline

Definition at line 289 of file FieldMap.h.

298 {

Referenced by FIX::DataDictionary::iterate().

◆ begin() [2/2]

const_iterator FIX::FieldMap::begin ( ) const
inline

Definition at line 291 of file FieldMap.h.

298 {

◆ calculateLength()

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

Definition at line 248 of file FieldMap.cpp.

250  {
251  std::vector < FieldMap* > ::const_iterator k;
252  for ( k = j->second.begin(); k != j->second.end(); ++k )
253  result += ( *k ) ->calculateLength();
254  }
255  return result;
256 }
257 
258 int FieldMap::calculateTotal( int checkSumField ) const
259 {
260  int result = 0;
261  Fields::const_iterator i;
262  for ( i = m_fields.begin(); i != m_fields.end(); ++i )
263  {
264  if ( i->getTag() != checkSumField )
265  result += i->getTotal();
266  }
267 
268  Groups::const_iterator j;
269  for ( j = m_groups.begin(); j != m_groups.end(); ++j )
270  {
271  std::vector < FieldMap* > ::const_iterator k;

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

◆ calculateString()

std::string & FIX::FieldMap::calculateString ( std::string &  result) const

Definition at line 230 of file FieldMap.cpp.

236 {
237  int result = 0;
238  Fields::const_iterator i;
239  for ( i = m_fields.begin(); i != m_fields.end(); ++i )
240  {
241  int tag = i->getTag();
242  if ( tag != beginStringField
243  && tag != bodyLengthField
244  && tag != checkSumField )
245  { result += i->getLength(); }
246  }

◆ calculateTotal()

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

Definition at line 273 of file FieldMap.cpp.

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

◆ clear()

void FIX::FieldMap::clear ( )

Clear all fields from the map.

Definition at line 197 of file FieldMap.cpp.

197 {
198  return m_fields.empty();
199 }
200 
201 size_t FieldMap::totalFields() const
202 {
203  size_t result = m_fields.size();
204 
205  Groups::const_iterator i;
206  for ( i = m_groups.begin(); i != m_groups.end(); ++i )
207  {
208  std::vector < FieldMap* > ::const_iterator j;
209  for ( j = i->second.begin(); j != i->second.end(); ++j )

◆ end() [1/2]

iterator FIX::FieldMap::end ( )
inline

Definition at line 290 of file FieldMap.h.

298 {

Referenced by FIX::DataDictionary::iterate().

◆ end() [2/2]

const_iterator FIX::FieldMap::end ( ) const
inline

Definition at line 292 of file FieldMap.h.

298 {

◆ findPositionFor()

Fields::iterator FIX::FieldMap::findPositionFor ( int  tag)
inlineprivate

Definition at line 373 of file FieldMap.h.

◆ findTag() [1/2]

Fields::iterator FIX::FieldMap::findTag ( int  tag)
inlineprivate

Definition at line 346 of file FieldMap.h.

350  {

References m_fields.

◆ findTag() [2/2]

Fields::const_iterator FIX::FieldMap::findTag ( int  tag) const
inlineprivate

Definition at line 341 of file FieldMap.h.

343  {
344  if( m_fields.empty() )

References m_fields.

Referenced by setField().

◆ g_begin() [1/2]

g_iterator FIX::FieldMap::g_begin ( )
inline

Definition at line 293 of file FieldMap.h.

298 {

◆ g_begin() [2/2]

g_const_iterator FIX::FieldMap::g_begin ( ) const
inline

Definition at line 295 of file FieldMap.h.

298 {

◆ g_end() [1/2]

g_iterator FIX::FieldMap::g_end ( )
inline

Definition at line 294 of file FieldMap.h.

298 {

◆ g_end() [2/2]

g_const_iterator FIX::FieldMap::g_end ( ) const
inline

Definition at line 296 of file FieldMap.h.

298 {

References m_fields.

◆ getField() [1/2]

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

Get a field without type checking.

Definition at line 187 of file FieldMap.h.

189  { return isSetField( field.getTag() ); }
191  bool isSetField( int tag ) const
192  { return findTag( tag ) != m_fields.end(); }

◆ getField() [2/2]

const std::string& FIX::FieldMap::getField ( int  tag) const
throw (FieldNotFound
)
inline

Get a field without a field class.

Definition at line 195 of file FieldMap.h.

209  {

◆ getFieldIfSet()

bool FIX::FieldMap::getFieldIfSet ( FieldBase field) const
inline

Get a field if set.

Definition at line 177 of file FieldMap.h.

183  {
184  return &getFieldRef( tag );

Referenced by FIX::Message::bodyLength(), FIX::Message::checkSum(), and FIX::Session::doBadCompID().

◆ getFieldPtr()

const FieldBase* const FIX::FieldMap::getFieldPtr ( int  tag) const
throw (FieldNotFound
)
inline

Get direct access to a field through a pointer.

Definition at line 212 of file FieldMap.h.

216  {

References m_groups.

◆ getFieldRef()

const FieldBase& FIX::FieldMap::getFieldRef ( int  tag) const
throw (FieldNotFound
)
inline

Get direct access to a field through a reference.

Definition at line 202 of file FieldMap.h.

209  {

◆ getGroup()

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

Get a specific instance of a group.

Definition at line 238 of file FieldMap.h.

◆ getGroupPtr()

FieldMap* FIX::FieldMap::getGroupPtr ( int  num,
int  tag 
) const
throw (FieldNotFound
)
inline

Get direct access to a field through a pointer.

Definition at line 256 of file FieldMap.h.

258  { return m_fields.begin(); }
259  iterator end() { return m_fields.end(); }
260  const_iterator begin() const { return m_fields.begin(); }

◆ getGroupRef()

FieldMap& FIX::FieldMap::getGroupRef ( int  num,
int  tag 
) const
throw (FieldNotFound
)
inline

Get direct access to a field through a reference.

Definition at line 245 of file FieldMap.h.

◆ groupCount()

size_t FIX::FieldMap::groupCount ( int  tag) const

Count the number of instance of a group.

Definition at line 189 of file FieldMap.cpp.

◆ hasGroup() [1/2]

bool FIX::FieldMap::hasGroup ( int  num,
int  tag 
) const

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

Definition at line 178 of file FieldMap.cpp.

◆ hasGroup() [2/2]

bool FIX::FieldMap::hasGroup ( int  tag) const

Check to see any instance of a group exists.

Definition at line 183 of file FieldMap.cpp.

183 {
184  m_fields.clear();
185 
186  Groups::iterator i;
187  for ( i = m_groups.begin(); i != m_groups.end(); ++i )

Referenced by FIX::Group::getGroup(), FIX::Group::removeGroup(), FIX::Trailer::replaceGroup(), and FIX::Message::replaceGroup().

◆ isEmpty()

bool FIX::FieldMap::isEmpty ( )

Check if map contains any fields.

Definition at line 211 of file FieldMap.cpp.

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

◆ isSetField() [1/2]

bool FIX::FieldMap::isSetField ( const FieldBase field) const
inline

Check to see if a field is set.

Definition at line 219 of file FieldMap.h.

227  {

◆ isSetField() [2/2]

bool FIX::FieldMap::isSetField ( int  tag) const
inline

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

Definition at line 222 of file FieldMap.h.

227  {

◆ lookup()

template<typename Iterator >
Iterator FIX::FieldMap::lookup ( Iterator  begin,
Iterator  end,
int  tag 
) const
inlineprivate

Definition at line 352 of file FieldMap.h.

366 { return (MAP).isSetField(field); } \
367 void set( const FIELD& field ) \
368 { (MAP).setField(field); } \
369 FIELD& get( FIELD& field ) const \
370 { return (FIELD&)(MAP).getField(field); } \
371 bool getIfSet( FIELD& field ) const \

◆ operator=()

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

Definition at line 77 of file FieldMap.cpp.

84 {
85  FieldMap * pGroup = new FieldMap( group );
86 
87  addGroupPtr( field, pGroup, setCount );
88 }
89 
90 void FieldMap::addGroupPtr( int field, FieldMap * group, bool setCount )
91 {
92  if( group == 0 )
93  return;
94 
95  std::vector< FieldMap* >& vec = m_groups[ field ];
96  vec.push_back( group );

◆ removeField()

void FIX::FieldMap::removeField ( int  tag)

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

Definition at line 171 of file FieldMap.cpp.

175 {
176  Groups::const_iterator i = m_groups.find( field );

◆ removeGroup() [1/2]

void FIX::FieldMap::removeGroup ( int  num,
int  tag 
)

Remove a specific instance of a group.

Definition at line 126 of file FieldMap.cpp.

126  {
127  m_groups.erase( i );
128  removeField( field );
129  }
130  else
131  {
132  IntField groupCount( field, (int)vector.size() );
133  setField( groupCount );
134  }
135 }
136 
137 void FieldMap::removeGroup( int field )
138 {
139  Groups::iterator i = m_groups.find( field );
140  if ( i == m_groups.end() ) return;
141 
142  removeField( field );
143 
144  std::vector< FieldMap* > tmp;
145  tmp.swap( i->second );
146 
147  m_groups.erase( i );
148 
149  while ( !tmp.empty() )
150  {

Referenced by FIX::Group::addGroup(), FIX::Message::addGroup(), FIX::Header::hasGroup(), and FIX::Group::replaceGroup().

◆ removeGroup() [2/2]

void FIX::FieldMap::removeGroup ( int  tag)

Remove all instances of a group.

Definition at line 152 of file FieldMap.cpp.

157 {
158  Fields::iterator i = findTag( field );
159  if ( i != m_fields.end() )
160  m_fields.erase( i );
161 }
162 
163 bool FieldMap::hasGroup( int num, int field ) const
164 {
165  return (int)groupCount(field) >= num;
166 }
167 
168 bool FieldMap::hasGroup( int field ) const
169 {

◆ replaceGroup()

void FIX::FieldMap::replaceGroup ( int  num,
int  tag,
const FieldMap group 
)

Replace a specific instance of a group.

Definition at line 117 of file FieldMap.cpp.

126  {

◆ reverse_find()

const FieldBase& FIX::FieldMap::reverse_find ( int  tag) const
inlineprotected

Definition at line 317 of file FieldMap.h.

322  {
323 #if defined(__SUNPRO_CC)
324  std::size_t numElements;

◆ setField() [1/2]

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

Set a field without type checking.

Definition at line 147 of file FieldMap.h.

147  {
148  Fields::const_iterator iter = findTag( field.getTag() );
149  if ( iter == m_fields.end() )
150  return false;
151  field = (*iter);
152  return true;
153  }
154 
156  FieldBase& getField( FieldBase& field )
157  const throw( FieldNotFound )
158  {
159  field = getFieldRef( field.getTag() );
160  return field;
161  }
162 
164  const std::string& getField( int tag )
165  const throw( FieldNotFound )
166  {

References findTag(), and m_fields.

Referenced by FIX::Session::generateReject(), FIX::Message::getSessionID(), FIX::Message::InitializeXML(), and FIX::Message::reverseRoute().

◆ setField() [2/2]

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

Set a field without a field class.

Definition at line 169 of file FieldMap.h.

173  {
174  Fields::const_iterator iter = findTag( tag );

References findTag(), and m_fields.

◆ sortFields()

void FIX::FieldMap::sortFields ( )
inlineprotected

Definition at line 334 of file FieldMap.h.

335  {
336  return iter;
337  }

◆ totalFields()

size_t FIX::FieldMap::totalFields ( ) const

Definition at line 216 of file FieldMap.cpp.

216 {
217  Fields::const_iterator i;
218  for ( i = m_fields.begin(); i != m_fields.end(); ++i )
219  {
220  result += i->getFixString();
221 
222  // add groups if they exist
223  if( !m_groups.size() ) continue;
224  Groups::const_iterator j = m_groups.find( i->getTag() );
225  if ( j == m_groups.end() ) continue;
226  std::vector < FieldMap* > ::const_iterator k;
227  for ( k = j->second.begin(); k != j->second.end(); ++k )
228  ( *k ) ->calculateString( result );

Friends And Related Function Documentation

◆ Message

friend class Message
friend

Definition at line 300 of file FieldMap.h.

Member Data Documentation

◆ m_fields

Fields FIX::FieldMap::m_fields
private

Definition at line 388 of file FieldMap.h.

Referenced by addField(), FieldMap(), findTag(), g_end(), and setField().

◆ m_groups

Groups FIX::FieldMap::m_groups
private

Definition at line 389 of file FieldMap.h.

Referenced by getFieldPtr().

◆ m_order

message_order FIX::FieldMap::m_order
private

Definition at line 390 of file FieldMap.h.

Referenced by addField().


The documentation for this class was generated from the following files:
FIX::FieldMap::isSetField
bool isSetField(const FieldBase &field) const
Check to see if a field is set.
Definition: FieldMap.h:219
FIX::FieldMap::findTag
Fields::const_iterator findTag(int tag) const
Definition: FieldMap.h:341
FIX::FieldMap::calculateTotal
int calculateTotal(int checkSumField=FIELD::CheckSum) const
Definition: FieldMap.cpp:273
FIX::FieldMap::hasGroup
bool hasGroup(int tag) const
Check to see any instance of a group exists.
Definition: FieldMap.cpp:183
FIX::FieldMap::clear
void clear()
Clear all fields from the map.
Definition: FieldMap.cpp:197
FIX::FieldMap::FieldMap
FieldMap(const message_order &order, int size)
Definition: FieldMap.cpp:49
FIX::FieldMap::groupCount
size_t groupCount(int tag) const
Count the number of instance of a group.
Definition: FieldMap.cpp:189
FIX::FieldMap::addGroupPtr
void addGroupPtr(int tag, FieldMap *group, bool setCount=true)
Acquire ownership of Group object.
Definition: FieldMap.cpp:105
FIX::FieldMap::m_order
message_order m_order
Definition: FieldMap.h:390
FIX::FieldMap::m_groups
Groups m_groups
Definition: FieldMap.h:389
FIX::FieldMap::begin
iterator begin()
Definition: FieldMap.h:289
FIX::FieldMap::lookup
Iterator lookup(Iterator begin, Iterator end, int tag) const
Definition: FieldMap.h:352
FIX::FieldMap::totalFields
size_t totalFields() const
Definition: FieldMap.cpp:216
sort
void sort(I begin, I end, const Pred &pred)
Definition: pugixml.cpp:6153
FIX::FieldMap::m_fields
Fields m_fields
Definition: FieldMap.h:388
FIX::FieldMap::getField
FieldBase & getField(FieldBase &field) const
Get a field without type checking.
Definition: FieldMap.h:187
FIX::FieldMap::removeField
void removeField(int tag)
Remove a field. If field is not present, this is a no-op.
Definition: FieldMap.cpp:171
FIX::FieldMap::getFieldRef
const FieldBase & getFieldRef(int tag) const
Get direct access to a field through a reference.
Definition: FieldMap.h:202
FIX::FieldMap::setField
void setField(const FieldBase &field, bool overwrite=true)
Set a field without type checking.
Definition: FieldMap.h:147
FIX::FieldMap::end
iterator end()
Definition: FieldMap.h:290
FIX::FieldMap::iterator
Fields::iterator iterator
Definition: FieldMap.h:130
FIX::FieldMap::removeGroup
void removeGroup(int num, int tag)
Remove a specific instance of a group.
Definition: FieldMap.cpp:126
FIX::FieldMap::const_iterator
Fields::const_iterator const_iterator
Definition: FieldMap.h:131

Generated on Thu Apr 23 2020 04:32:03 for QuickFIX by doxygen 1.8.16 written by Dimitri van Heesch, © 1997-2001