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

Member Typedef Documentation

◆ const_iterator

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

Definition at line 100 of file FieldMap.h.

◆ Fields

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

Definition at line 95 of file FieldMap.h.

◆ g_const_iterator

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

Definition at line 102 of file FieldMap.h.

◆ g_iterator

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

Definition at line 101 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 97 of file FieldMap.h.

◆ iterator

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

Definition at line 99 of file FieldMap.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
private
Enumerator
DEFAULT_SIZE 

Definition at line 87 of file FieldMap.h.

Constructor & Destructor Documentation

◆ FieldMap() [1/4]

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

Definition at line 34 of file FieldMap.cpp.

References m_fields.

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

35 : m_order(order)
36 {
37  m_fields.reserve(size);
38 }
Fields m_fields
Definition: FieldMap.h:357
message_order m_order
Definition: FieldMap.h:359

◆ FieldMap() [2/4]

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

Definition at line 40 of file FieldMap.cpp.

References DEFAULT_SIZE, and m_fields.

41 : m_order(order)
42 {
43  m_fields.reserve(DEFAULT_SIZE);
44 }
Fields m_fields
Definition: FieldMap.h:357
message_order m_order
Definition: FieldMap.h:359

◆ FieldMap() [3/4]

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

Definition at line 46 of file FieldMap.cpp.

References DEFAULT_SIZE, and m_fields.

47 : m_order(message_order(order))
48 {
49  m_fields.reserve(DEFAULT_SIZE);
50 }
Fields m_fields
Definition: FieldMap.h:357
message_order m_order
Definition: FieldMap.h:359

◆ FieldMap() [4/4]

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

Definition at line 52 of file FieldMap.cpp.

53 {
54  *this = copy;
55 }

◆ ~FieldMap()

FIX::FieldMap::~FieldMap ( )
virtual

Definition at line 57 of file FieldMap.cpp.

References clear().

58 {
59  clear();
60 }
void clear()
Clear all fields from the map.
Definition: FieldMap.cpp:182

Member Function Documentation

◆ addField()

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

Definition at line 271 of file FieldMap.h.

References findPositionFor(), FIX::FieldBase::getTag(), and m_fields.

Referenced by setField().

272  {
273  Fields::iterator iter = findPositionFor( field.getTag() );
274  if( iter == m_fields.end() )
275  {
276  m_fields.push_back( field );
277  }
278  else
279  {
280  m_fields.insert( iter, field );
281  }
282  }
Fields::iterator findPositionFor(int tag)
Definition: FieldMap.h:342
Fields m_fields
Definition: FieldMap.h:357

◆ addGroup()

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

Add a group.

Definition at line 83 of file FieldMap.cpp.

References addGroupPtr(), and FieldMap().

Referenced by FIX::Header::addGroup(), FIX::Group::addGroup(), FIX::Trailer::addGroup(), FIX::Message::addGroup(), and isSetField().

84 {
85  FieldMap * pGroup = new FieldMap( group );
86 
87  addGroupPtr( field, pGroup, setCount );
88 }
FieldMap(const message_order &order, int size)
Definition: FieldMap.cpp:34
void addGroupPtr(int tag, FieldMap *group, bool setCount=true)
Acquire ownership of Group object.
Definition: FieldMap.cpp:90

◆ addGroupPtr()

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

Acquire ownership of Group object.

Definition at line 90 of file FieldMap.cpp.

References m_groups, and setField().

Referenced by addGroup(), isSetField(), and FIX::Message::setGroup().

91 {
92  if( group == 0 )
93  return;
94 
95  std::vector< FieldMap* >& vec = m_groups[ field ];
96  vec.push_back( group );
97 
98  if( setCount )
99  setField( IntField( field, (int)vec.size() ) );
100 }
Groups m_groups
Definition: FieldMap.h:358
void setField(const FieldBase &field, bool overwrite=true)
Set a field without type checking.
Definition: FieldMap.h:116

◆ appendField()

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

Definition at line 297 of file FieldMap.h.

References m_fields.

Referenced by FIX::Message::setString(), and FIX::Message::setStringHeader().

298  {
299  m_fields.push_back( field );
300  }
Fields m_fields
Definition: FieldMap.h:357

◆ begin() [1/2]

iterator FIX::FieldMap::begin ( )
inline

Definition at line 258 of file FieldMap.h.

References m_fields.

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

258 { return m_fields.begin(); }
Fields m_fields
Definition: FieldMap.h:357

◆ begin() [2/2]

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

Definition at line 260 of file FieldMap.h.

References m_fields.

260 { return m_fields.begin(); }
Fields m_fields
Definition: FieldMap.h:357

◆ calculateLength()

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

Definition at line 233 of file FieldMap.cpp.

References m_fields, and m_groups.

Referenced by FIX::Message::bodyLength(), and getGroupPtr().

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  }
247 
248  Groups::const_iterator j;
249  for ( j = m_groups.begin(); j != m_groups.end(); ++j )
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 }
Fields m_fields
Definition: FieldMap.h:357
Fields::const_iterator const_iterator
Definition: FieldMap.h:100
Groups m_groups
Definition: FieldMap.h:358

◆ calculateString()

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

Definition at line 215 of file FieldMap.cpp.

References m_fields, and m_groups.

Referenced by getGroupPtr(), and FIX::Message::toString().

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 );
229  }
230  return result;
231 }
Fields m_fields
Definition: FieldMap.h:357
Fields::const_iterator const_iterator
Definition: FieldMap.h:100
Groups m_groups
Definition: FieldMap.h:358

◆ calculateTotal()

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

Definition at line 258 of file FieldMap.cpp.

References m_fields, and m_groups.

Referenced by FIX::Message::checkSum(), and getGroupPtr().

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;
272  for ( k = j->second.begin(); k != j->second.end(); ++k )
273  result += ( *k ) ->calculateTotal();
274  }
275  return result;
276 }
Fields m_fields
Definition: FieldMap.h:357
Fields::const_iterator const_iterator
Definition: FieldMap.h:100
Groups m_groups
Definition: FieldMap.h:358

◆ clear()

void FIX::FieldMap::clear ( )

Clear all fields from the map.

Definition at line 182 of file FieldMap.cpp.

References m_fields, and m_groups.

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

183 {
184  m_fields.clear();
185 
186  Groups::iterator i;
187  for ( i = m_groups.begin(); i != m_groups.end(); ++i )
188  {
189  std::vector < FieldMap* > ::iterator j;
190  for ( j = i->second.begin(); j != i->second.end(); ++j )
191  delete *j;
192  }
193  m_groups.clear();
194 }
Fields m_fields
Definition: FieldMap.h:357
Groups m_groups
Definition: FieldMap.h:358
Fields::iterator iterator
Definition: FieldMap.h:99

◆ end() [1/2]

iterator FIX::FieldMap::end ( )
inline

Definition at line 259 of file FieldMap.h.

References m_fields.

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

259 { return m_fields.end(); }
Fields m_fields
Definition: FieldMap.h:357

◆ end() [2/2]

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

Definition at line 261 of file FieldMap.h.

References m_fields.

261 { return m_fields.end(); }
Fields m_fields
Definition: FieldMap.h:357

◆ findPositionFor()

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

Definition at line 342 of file FieldMap.h.

References FIX::FieldBase::getTag(), m_fields, FIX::FieldMap::sorter::m_order, and FIX::FieldMap::sorter::sorter().

Referenced by addField().

343  {
344  if( m_fields.empty() )
345  return m_fields.end();
346 
347  const FieldBase& last = m_fields.back();
348  if( m_order( last.getTag(), tag ) ||
349  last.getTag() == tag )
350  {
351  return m_fields.end();
352  }
353 
354  return std::upper_bound( m_fields.begin(), m_fields.end(), tag, sorter( m_order ) );
355  }
Fields m_fields
Definition: FieldMap.h:357
message_order m_order
Definition: FieldMap.h:359

◆ findTag() [1/2]

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

Definition at line 310 of file FieldMap.h.

References lookup(), and m_fields.

Referenced by getFieldIfSet(), getFieldRef(), isSetField(), removeField(), and setField().

311  {
312  return lookup( m_fields.begin(), m_fields.end(), tag );
313  }
Fields m_fields
Definition: FieldMap.h:357
Iterator lookup(Iterator begin, Iterator end, int tag) const
Definition: FieldMap.h:321

◆ findTag() [2/2]

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

Definition at line 315 of file FieldMap.h.

References lookup(), and m_fields.

316  {
317  return lookup( m_fields.begin(), m_fields.end(), tag );
318  }
Fields m_fields
Definition: FieldMap.h:357
Iterator lookup(Iterator begin, Iterator end, int tag) const
Definition: FieldMap.h:321

◆ g_begin() [1/2]

g_iterator FIX::FieldMap::g_begin ( )
inline

Definition at line 262 of file FieldMap.h.

References m_groups.

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

262 { return m_groups.begin(); }
Groups m_groups
Definition: FieldMap.h:358

◆ g_begin() [2/2]

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

Definition at line 264 of file FieldMap.h.

References m_groups.

264 { return m_groups.begin(); }
Groups m_groups
Definition: FieldMap.h:358

◆ g_end() [1/2]

g_iterator FIX::FieldMap::g_end ( )
inline

Definition at line 263 of file FieldMap.h.

References m_groups.

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

263 { return m_groups.end(); }
Groups m_groups
Definition: FieldMap.h:358

◆ g_end() [2/2]

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

Definition at line 265 of file FieldMap.h.

References m_groups.

265 { return m_groups.end(); }
Groups m_groups
Definition: FieldMap.h:358

◆ getField() [1/2]

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

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

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

166  {
167  return getFieldRef( tag ).getString();
168  }
const std::string & getString() const
Get the string representation of the fields value.
Definition: Field.h:152
const FieldBase & getFieldRef(int tag) const
Get direct access to a field through a reference.
Definition: FieldMap.h:171

◆ getFieldIfSet()

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

Get a field if set.

Definition at line 146 of file FieldMap.h.

References findTag(), FIX::FieldBase::getTag(), and m_fields.

Referenced by FIX::MessageCracker::crack(), FIX::Session::doPossDup(), FIX::Session::doTargetTooLow(), FIX::Session::generateReject(), FIX::Session::next(), FIX::Session::nextLogon(), FIX::Session::nextResendRequest(), FIX::Session::nextSequenceReset(), FIX::Message::reverseRoute(), and FIX::Session::sendRaw().

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  }
Fields m_fields
Definition: FieldMap.h:357
Fields::const_iterator findTag(int tag) const
Definition: FieldMap.h:310

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

References getFieldRef().

183  {
184  return &getFieldRef( tag );
185  }
const FieldBase & getFieldRef(int tag) const
Get direct access to a field through a reference.
Definition: FieldMap.h:171

◆ getFieldRef()

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

Get direct access to a field through a reference.

Definition at line 171 of file FieldMap.h.

References findTag(), and m_fields.

Referenced by getField(), and getFieldPtr().

173  {
174  Fields::const_iterator iter = findTag( tag );
175  if ( iter == m_fields.end() )
176  throw FieldNotFound( tag );
177  return (*iter);
178  }
Fields m_fields
Definition: FieldMap.h:357
Fields::const_iterator findTag(int tag) const
Definition: FieldMap.h:310

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

References getGroupRef().

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

209  {
210  return group = getGroupRef( num, tag );
211  }
FieldMap & getGroupRef(int num, int tag) const
Get direct access to a field through a reference.
Definition: FieldMap.h:214

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

References FIX::FIELD::BeginString, FIX::FIELD::BodyLength, calculateLength(), calculateString(), calculateTotal(), FIX::FIELD::CheckSum, clear(), getGroupRef(), groupCount(), hasGroup(), isEmpty(), removeGroup(), and totalFields().

227  {
228  return &getGroupRef( num, tag );
229  }
FieldMap & getGroupRef(int num, int tag) const
Get direct access to a field through a reference.
Definition: FieldMap.h:214

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

References m_groups.

Referenced by getGroup(), and getGroupPtr().

216  {
217  Groups::const_iterator i = m_groups.find( tag );
218  if( i == m_groups.end() ) throw FieldNotFound( tag );
219  if( num <= 0 ) throw FieldNotFound( tag );
220  if( i->second.size() < (unsigned)num ) throw FieldNotFound( tag );
221  return *( *(i->second.begin() + (num-1) ) );
222  }
Groups m_groups
Definition: FieldMap.h:358

◆ groupCount()

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

Count the number of instance of a group.

Definition at line 174 of file FieldMap.cpp.

References m_groups.

Referenced by FIX::DataDictionary::checkGroupCount(), getGroupPtr(), hasGroup(), and removeGroup().

175 {
176  Groups::const_iterator i = m_groups.find( field );
177  if( i == m_groups.end() )
178  return 0;
179  return i->second.size();
180 }
Groups m_groups
Definition: FieldMap.h:358

◆ hasGroup() [1/2]

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

Check to see any instance of a group exists.

Definition at line 168 of file FieldMap.cpp.

References m_groups.

Referenced by getGroupPtr(), FIX::Group::hasGroup(), FIX::Header::hasGroup(), FIX::Trailer::hasGroup(), and FIX::Message::hasGroup().

169 {
170  Groups::const_iterator i = m_groups.find( field );
171  return i != m_groups.end();
172 }
Groups m_groups
Definition: FieldMap.h:358

◆ hasGroup() [2/2]

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

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

Definition at line 163 of file FieldMap.cpp.

References groupCount().

164 {
165  return (int)groupCount(field) >= num;
166 }
size_t groupCount(int tag) const
Count the number of instance of a group.
Definition: FieldMap.cpp:174

◆ isEmpty()

bool FIX::FieldMap::isEmpty ( )

Check if map contains any fields.

Definition at line 196 of file FieldMap.cpp.

References m_fields.

Referenced by getGroupPtr(), and FIX::Message::isEmpty().

197 {
198  return m_fields.empty();
199 }
Fields m_fields
Definition: FieldMap.h:357

◆ isSetField() [1/2]

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

Check to see if a field is set.

Definition at line 188 of file FieldMap.h.

References FIX::FieldBase::getTag().

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

189  { return isSetField( field.getTag() ); }
bool isSetField(const FieldBase &field) const
Check to see if a field is set.
Definition: FieldMap.h:188

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

References addGroup(), addGroupPtr(), findTag(), m_fields, removeField(), and replaceGroup().

192  { return findTag( tag ) != m_fields.end(); }
Fields m_fields
Definition: FieldMap.h:357
Fields::const_iterator findTag(int tag) const
Definition: FieldMap.h:310

◆ lookup()

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

Definition at line 321 of file FieldMap.h.

References end(), FIX::FieldMap::sorter::m_order, and FIX::FieldMap::sorter::sorter().

Referenced by findTag().

322  {
323 #if defined(__SUNPRO_CC)
324  std::size_t numElements;
325  std::distance( begin, end, numElements );
326 #else
327  std::size_t numElements = std::distance( begin, end );
328 #endif
329  if( numElements < 16 )
330  return std::find_if( begin, end, finder( tag ) );
331 
332  Iterator iter = std::lower_bound( begin, end, tag, sorter( m_order ) );
333  if( iter != end &&
334  iter->getTag() == tag )
335  {
336  return iter;
337  }
338 
339  return end;
340  }
iterator end()
Definition: FieldMap.h:259
iterator begin()
Definition: FieldMap.h:258
message_order m_order
Definition: FieldMap.h:359

◆ operator=()

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

Definition at line 62 of file FieldMap.cpp.

References clear(), FieldMap(), m_fields, m_groups, and m_order.

63 {
64  clear();
65 
66  m_fields = rhs.m_fields;
67  m_order = rhs.m_order;
68 
69  Groups::const_iterator i;
70  for ( i = rhs.m_groups.begin(); i != rhs.m_groups.end(); ++i )
71  {
72  std::vector < FieldMap* > ::const_iterator j;
73  for ( j = i->second.begin(); j != i->second.end(); ++j )
74  {
75  FieldMap * pGroup = new FieldMap( **j );
76  m_groups[ i->first ].push_back( pGroup );
77  }
78  }
79 
80  return *this;
81 }
FieldMap(const message_order &order, int size)
Definition: FieldMap.cpp:34
Fields m_fields
Definition: FieldMap.h:357
Fields::const_iterator const_iterator
Definition: FieldMap.h:100
Groups m_groups
Definition: FieldMap.h:358
message_order m_order
Definition: FieldMap.h:359
void clear()
Clear all fields from the map.
Definition: FieldMap.cpp:182

◆ removeField()

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

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

Definition at line 156 of file FieldMap.cpp.

References findTag(), and m_fields.

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

157 {
158  Fields::iterator i = findTag( field );
159  if ( i != m_fields.end() )
160  m_fields.erase( i );
161 }
Fields m_fields
Definition: FieldMap.h:357
Fields::const_iterator findTag(int tag) const
Definition: FieldMap.h:310

◆ removeGroup() [1/2]

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

Remove a specific instance of a group.

Definition at line 111 of file FieldMap.cpp.

References groupCount(), m_groups, removeField(), and setField().

Referenced by getGroupPtr(), FIX::Group::removeGroup(), FIX::Header::removeGroup(), FIX::Trailer::removeGroup(), and FIX::Message::removeGroup().

112 {
113  Groups::iterator i = m_groups.find( field );
114  if ( i == m_groups.end() ) return;
115  if ( num <= 0 ) return;
116  std::vector< FieldMap* >& vector = i->second;
117  if ( vector.size() < ( unsigned ) num ) return;
118 
119  std::vector< FieldMap* >::iterator iter = vector.begin();
120  std::advance( iter, ( num - 1 ) );
121 
122  delete (*iter);
123  vector.erase( iter );
124 
125  if( vector.size() == 0 )
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 }
void removeField(int tag)
Remove a field. If field is not present, this is a no-op.
Definition: FieldMap.cpp:156
size_t groupCount(int tag) const
Count the number of instance of a group.
Definition: FieldMap.cpp:174
Groups m_groups
Definition: FieldMap.h:358
void setField(const FieldBase &field, bool overwrite=true)
Set a field without type checking.
Definition: FieldMap.h:116

◆ removeGroup() [2/2]

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

Remove all instances of a group.

Definition at line 137 of file FieldMap.cpp.

References m_groups, and removeField().

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  {
151  delete tmp.back();
152  tmp.pop_back();
153  }
154 }
void removeField(int tag)
Remove a field. If field is not present, this is a no-op.
Definition: FieldMap.cpp:156
Groups m_groups
Definition: FieldMap.h:358

◆ replaceGroup()

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

Replace a specific instance of a group.

Definition at line 102 of file FieldMap.cpp.

References m_groups.

Referenced by isSetField(), FIX::Header::replaceGroup(), FIX::Group::replaceGroup(), FIX::Trailer::replaceGroup(), and FIX::Message::replaceGroup().

103 {
104  Groups::const_iterator i = m_groups.find( field );
105  if ( i == m_groups.end() ) return;
106  if ( num <= 0 ) return;
107  if ( i->second.size() < ( unsigned ) num ) return;
108  *( *( i->second.begin() + ( num - 1 ) ) ) = group;
109 }
Groups m_groups
Definition: FieldMap.h:358

◆ reverse_find()

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

Definition at line 286 of file FieldMap.h.

References m_fields.

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

287  {
288  Fields::const_reverse_iterator iter = std::find_if( m_fields.rbegin(), m_fields.rend(), finder( tag ) );
289  if( iter == m_fields.rend() )
290  throw FieldNotFound( tag );
291 
292  return *iter;
293  }
Fields m_fields
Definition: FieldMap.h:357

◆ setField() [1/2]

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

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

References setField().

140  {
141  FieldBase fieldBase( tag, value );
142  setField( fieldBase );
143  }
void setField(const FieldBase &field, bool overwrite=true)
Set a field without type checking.
Definition: FieldMap.h:116

◆ sortFields()

void FIX::FieldMap::sortFields ( )
inlineprotected

Definition at line 303 of file FieldMap.h.

References m_fields, FIX::FieldMap::sorter::m_order, sort(), and FIX::FieldMap::sorter::sorter().

Referenced by FIX::Message::setString(), and FIX::Message::setStringHeader().

304  {
305  std::sort( m_fields.begin(), m_fields.end(), sorter(m_order) );
306  }
Fields m_fields
Definition: FieldMap.h:357
void sort(I begin, I end, const Pred &pred)
Definition: pugixml.cpp:6153
message_order m_order
Definition: FieldMap.h:359

◆ totalFields()

size_t FIX::FieldMap::totalFields ( ) const

Definition at line 201 of file FieldMap.cpp.

References m_fields, and m_groups.

Referenced by getGroupPtr().

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 )
210  result += ( *j ) ->totalFields();
211  }
212  return result;
213 }
Fields m_fields
Definition: FieldMap.h:357
Fields::const_iterator const_iterator
Definition: FieldMap.h:100
Groups m_groups
Definition: FieldMap.h:358

Friends And Related Function Documentation

◆ Message

friend class Message
friend

Definition at line 269 of file FieldMap.h.

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

Member Data Documentation

◆ m_fields

Fields FIX::FieldMap::m_fields
private

◆ m_groups

Groups FIX::FieldMap::m_groups
private

◆ m_order

message_order FIX::FieldMap::m_order
private

Definition at line 359 of file FieldMap.h.

Referenced by operator=().


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

Generated on Sun Apr 15 2018 21:44:05 for QuickFIX by doxygen 1.8.13 written by Dimitri van Heesch, © 1997-2001