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.
 
void setField (int tag, const std::string &value) throw ( RepeatedTag, NoTagValue )
 Set a field without a field class.
 
bool getFieldIfSet (FieldBase &field) const
 Get a field if set.
 
FieldBasegetField (FieldBase &field) const throw ( FieldNotFound )
 Get a field without type checking.
 
const std::string & getField (int tag) const throw ( FieldNotFound )
 Get a field without a field class.
 
const FieldBasegetFieldRef (int tag) const throw ( FieldNotFound )
 Get direct access to a field through a reference.
 
const FieldBase *const getFieldPtr (int tag) const throw ( FieldNotFound )
 Get direct access to a field through a pointer.
 
bool isSetField (const FieldBase &field) const
 Check to see if a field is set.
 
bool isSetField (int tag) const
 Check to see if a field is set by referencing its number.
 
void removeField (int tag)
 Remove a field. If field is not present, this is a no-op.
 
void addGroup (int tag, const FieldMap &group, bool setCount=true)
 Add a group.
 
void addGroupPtr (int tag, FieldMap *group, bool setCount=true)
 Acquire ownership of Group object.
 
void replaceGroup (int num, int tag, const FieldMap &group)
 Replace a specific instance of a group.
 
FieldMapgetGroup (int num, int tag, FieldMap &group) const throw ( FieldNotFound )
 Get a specific instance of a group.
 
FieldMapgetGroupRef (int num, int tag) const throw ( FieldNotFound )
 Get direct access to a field through a reference.
 
FieldMapgetGroupPtr (int num, int tag) const throw ( FieldNotFound )
 Get direct access to a field through a pointer.
 
void removeGroup (int num, int tag)
 Remove a specific instance of a group.
 
void removeGroup (int tag)
 Remove all instances of a group.
 
bool hasGroup (int tag) const
 Check to see any instance of a group exists.
 
bool hasGroup (int num, int tag) const
 Check to see if a specific instance of a group exists.
 
size_t groupCount (int tag) 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.
 
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.

87{ DEFAULT_SIZE = 16 };

Constructor & Destructor Documentation

◆ FieldMap() [1/4]

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

Definition at line 34 of file FieldMap.cpp.

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

References m_fields.

◆ FieldMap() [2/4]

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

Definition at line 40 of file FieldMap.cpp.

41: m_order(order)
42{
43 m_fields.reserve(DEFAULT_SIZE);
44}

References DEFAULT_SIZE, and m_fields.

◆ FieldMap() [3/4]

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

Definition at line 46 of file FieldMap.cpp.

47: m_order(message_order(order))
48{
49 m_fields.reserve(DEFAULT_SIZE);
50}

References DEFAULT_SIZE, and m_fields.

◆ 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.

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

References clear().

Member Function Documentation

◆ addField()

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

Definition at line 271 of file FieldMap.h.

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

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

Referenced by setField().

◆ addGroup()

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

Add a group.

Definition at line 83 of file FieldMap.cpp.

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

References addGroupPtr().

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

◆ 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.

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}
void setField(const FieldBase &field, bool overwrite=true)
Set a field without type checking.
Definition FieldMap.h:116
Groups m_groups
Definition FieldMap.h:358

References m_groups, and setField().

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

◆ appendField()

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

Definition at line 297 of file FieldMap.h.

298 {
299 m_fields.push_back( field );
300 }

References m_fields.

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

◆ begin() [1/2]

iterator FIX::FieldMap::begin ( )
inline

Definition at line 258 of file FieldMap.h.

258{ return m_fields.begin(); }

References m_fields.

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

◆ begin() [2/2]

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

Definition at line 260 of file FieldMap.h.

260{ return m_fields.begin(); }

References m_fields.

◆ 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.

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::const_iterator const_iterator
Definition FieldMap.h:100

References m_fields, and m_groups.

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

◆ calculateString()

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

Definition at line 215 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 );
229 }
230 return result;
231}

References m_fields, and m_groups.

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

◆ calculateTotal()

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

Definition at line 258 of file FieldMap.cpp.

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}

References m_fields, and m_groups.

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

◆ clear()

void FIX::FieldMap::clear ( )

Clear all fields from the map.

Definition at line 182 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 )
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::iterator iterator
Definition FieldMap.h:99

References m_fields, and m_groups.

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

◆ end() [1/2]

iterator FIX::FieldMap::end ( )
inline

Definition at line 259 of file FieldMap.h.

259{ return m_fields.end(); }

References m_fields.

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

◆ end() [2/2]

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

Definition at line 261 of file FieldMap.h.

261{ return m_fields.end(); }

References m_fields.

◆ findPositionFor()

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

Definition at line 342 of file FieldMap.h.

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 }

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

Referenced by addField().

◆ findTag() [1/2]

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

Definition at line 315 of file FieldMap.h.

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

References lookup(), and m_fields.

◆ findTag() [2/2]

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

Definition at line 310 of file FieldMap.h.

311 {
312 return lookup( m_fields.begin(), m_fields.end(), tag );
313 }

References lookup(), and m_fields.

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

◆ g_begin() [1/2]

g_iterator FIX::FieldMap::g_begin ( )
inline

Definition at line 262 of file FieldMap.h.

262{ return m_groups.begin(); }

References m_groups.

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

◆ g_begin() [2/2]

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

Definition at line 264 of file FieldMap.h.

264{ return m_groups.begin(); }

References m_groups.

◆ g_end() [1/2]

g_iterator FIX::FieldMap::g_end ( )
inline

Definition at line 263 of file FieldMap.h.

263{ return m_groups.end(); }

References m_groups.

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

◆ g_end() [2/2]

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

Definition at line 265 of file FieldMap.h.

265{ return m_groups.end(); }

References m_groups.

◆ getField() [1/2]

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

Get a field without type checking.

Definition at line 156 of file FieldMap.h.

158 {
159 field = getFieldRef( field.getTag() );
160 return field;
161 }
const FieldBase & getFieldRef(int tag) const
Get direct access to a field through a reference.
Definition FieldMap.h:171

References getFieldRef().

Referenced by FIX::Session::doPossDup(), FIX::Session::doTargetTooHigh(), FIX::Session::doTargetTooLow(), FIX::Session::generateHeartbeat(), FIX::Acceptor::getSession(), FIX::Session::next(), FIX::Session::nextResendRequest(), and FIX::Session::resend().

◆ 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.

166 {
167 return getFieldRef( tag ).getString();
168 }
const std::string & getString() const
Get the string representation of the fields value.
Definition Field.h:152

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

◆ getFieldIfSet()

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

Get a field if set.

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

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

Referenced by FIX::MessageCracker::crack(), FIX::MessageCracker::crack(), FIX::Session::doPossDup(), FIX::Session::doTargetTooLow(), FIX::Message::isAdmin(), FIX::Message::isApp(), FIX::Session::next(), and FIX::Session::sendRaw().

◆ 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.

183 {
184 return &getFieldRef( tag );
185 }

References getFieldRef().

◆ 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.

173 {
174 Fields::const_iterator iter = findTag( tag );
175 if ( iter == m_fields.end() )
176 throw FieldNotFound( tag );
177 return (*iter);
178 }

References findTag(), and m_fields.

Referenced by getField(), getField(), and getFieldPtr().

◆ 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.

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

References getGroupRef().

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

◆ 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.

227 {
228 return &getGroupRef( num, tag );
229 }

References getGroupRef().

◆ 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.

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 }

References m_groups.

Referenced by getGroup(), and getGroupPtr().

◆ 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.

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}

References m_groups.

Referenced by hasGroup(), and removeGroup().

◆ 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 163 of file FieldMap.cpp.

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

References groupCount().

◆ hasGroup() [2/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.

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

References m_groups.

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

◆ isEmpty()

bool FIX::FieldMap::isEmpty ( )

Check if map contains any fields.

Definition at line 196 of file FieldMap.cpp.

197{
198 return m_fields.empty();
199}

References m_fields.

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

◆ 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.

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

References FIX::FieldBase::getTag(), and isSetField().

Referenced by isSetField().

◆ 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.

192 { return findTag( tag ) != m_fields.end(); }

References findTag(), and m_fields.

◆ lookup()

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

Definition at line 321 of file FieldMap.h.

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 begin()
Definition FieldMap.h:258
iterator end()
Definition FieldMap.h:259

References begin(), end(), and m_order.

Referenced by findTag(), and findTag().

◆ operator=()

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

Definition at line 62 of file FieldMap.cpp.

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}

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

◆ 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.

157{
158 Fields::iterator i = findTag( field );
159 if ( i != m_fields.end() )
160 m_fields.erase( i );
161}

References findTag(), and m_fields.

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

◆ 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.

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() );
134 }
135}
void removeField(int tag)
Remove a field. If field is not present, this is a no-op.
Definition FieldMap.cpp:156

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

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

◆ removeGroup() [2/2]

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

Remove all instances of a group.

Definition at line 137 of file FieldMap.cpp.

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}

References m_groups, and removeField().

◆ 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.

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}

References m_groups.

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

◆ reverse_find()

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

Definition at line 286 of file FieldMap.h.

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 }

References m_fields.

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

◆ 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.

140 {
141 FieldBase fieldBase( tag, value );
142 setField( fieldBase );
143 }

References setField().

◆ sortFields()

void FIX::FieldMap::sortFields ( )
inlineprotected

Definition at line 303 of file FieldMap.h.

304 {
305 std::sort( m_fields.begin(), m_fields.end(), sorter(m_order) );
306 }

References m_fields, and m_order.

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

◆ totalFields()

size_t FIX::FieldMap::totalFields ( ) const

Definition at line 201 of file FieldMap.cpp.

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}

References m_fields, and m_groups.

Friends And Related Symbol Documentation

◆ Message

friend class Message
friend

Definition at line 269 of file FieldMap.h.

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 findPositionFor(), lookup(), operator=(), and sortFields().


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

Generated on Fri Sep 27 2024 13:45:21 for QuickFIX by doxygen 1.9.8 written by Dimitri van Heesch, © 1997-2001