FIX::FieldMap Class Reference

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

`#include <FieldMap.h>`

Inheritance diagram for FIX::FieldMap:
[legend]
Collaboration diagram for FIX::FieldMap:
[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 ()
FieldMap & | operator= (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...
FieldBase & | getField (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 FieldBase & | getFieldRef (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...
FieldMap & | getGroup (int num, int tag, FieldMap &group) const throw ( FieldNotFound )
| Get a specific instance of a group. More...
FieldMap & | getGroupRef (int num, int tag) const throw ( FieldNotFound )
| Get direct access to a field through a reference. More...
FieldMap * | getGroupPtr (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 FieldBase & | reverse_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.

{ DEFAULT_SIZE = 16 };
FIX::FieldMap::DEFAULT_SIZE
@ DEFAULT_SIZE
Definition: FieldMap.h:87

## Constructor & Destructor Documentation

## FieldMap() [1/4]

FIX::FieldMap::FieldMap | ( | const message_order & | order,
|  | int | size
| ) |  |

protected

Definition at line 34 of file FieldMap.cpp.

: m_order(order)
{
m_fields.reserve(size);
}
FIX::FieldMap::m_order
message_order m_order
Definition: FieldMap.h:359
FIX::FieldMap::m_fields
Fields m_fields
Definition: FieldMap.h:357

References m_fields.

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

## FieldMap() [2/4]

FIX::FieldMap::FieldMap | ( | const message_order & | order = `message_order( message_order::normal )` | ) |

Definition at line 40 of file FieldMap.cpp.

: m_order(order)
{
m_fields.reserve(DEFAULT_SIZE);
}

References DEFAULT_SIZE, and m_fields.

## FieldMap() [3/4]

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

Definition at line 46 of file FieldMap.cpp.

: m_order(message_order(order))
{
m_fields.reserve(DEFAULT_SIZE);
}

References DEFAULT_SIZE, and m_fields.

## FieldMap() [4/4]

FIX::FieldMap::FieldMap | ( | const FieldMap & | copy | ) |

Definition at line 52 of file FieldMap.cpp.

{
*this = copy;
}

## ~FieldMap()

FIX::FieldMap::~FieldMap | ( |  | ) |

virtual

Definition at line 57 of file FieldMap.cpp.

{
clear();
}
FIX::FieldMap::clear
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 | ) |

inline protected

Definition at line 271 of file FieldMap.h.

{
Fields::iterator iter = findPositionFor( field.getTag() );
if( iter == m_fields.end() )
{
m_fields.push_back( field );
}
else
{
m_fields.insert( iter, field );
}
}
FIX::FieldMap::findPositionFor
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.

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

References addGroupPtr(), and FieldMap().

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.

{
if( group == 0 )
return;
std::vector< FieldMap* >& vec = m_groups[ field ];
vec.push_back( group );
if( setCount )
setField( IntField( field, (int)vec.size() ) );
}
FIX::FieldMap::setField
void setField(const FieldBase &field, bool overwrite=true)
Set a field without type checking.
Definition: FieldMap.h:116
FIX::FieldMap::m_groups
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 | ) |

inline protected

Definition at line 297 of file FieldMap.h.

{
m_fields.push_back( field );
}

References m_fields.

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

## begin() [1/2]

iterator FIX::FieldMap::begin | ( |  | ) |

inline

Definition at line 258 of file FieldMap.h.

{ return m_fields.begin(); }

References m_fields.

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

## begin() [2/2]

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

inline

Definition at line 260 of file FieldMap.h.

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

{
int result = 0;
Fields::const_iterator i;
for ( i = m_fields.begin(); i != m_fields.end(); ++i )
{
int tag = i->getTag();
if ( tag != beginStringField
&& tag != bodyLengthField
&& tag != checkSumField )
{ result += i->getLength(); }
}
Groups::const_iterator j;
for ( j = m_groups.begin(); j != m_groups.end(); ++j )
{
std::vector < FieldMap* > ::const_iterator k;
for ( k = j->second.begin(); k != j->second.end(); ++k )
result += ( *k ) ->calculateLength();
}
return result;
}
FIX::FieldMap::const_iterator
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.

{
Fields::const_iterator i;
for ( i = m_fields.begin(); i != m_fields.end(); ++i )
{
result += i->getFixString();
// add groups if they exist
if( !m_groups.size() ) continue;
Groups::const_iterator j = m_groups.find( i->getTag() );
if ( j == m_groups.end() ) continue;
std::vector < FieldMap* > ::const_iterator k;
for ( k = j->second.begin(); k != j->second.end(); ++k )
( *k ) ->calculateString( result );
}
return result;
}

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.

{
int result = 0;
Fields::const_iterator i;
for ( i = m_fields.begin(); i != m_fields.end(); ++i )
{
if ( i->getTag() != checkSumField )
result += i->getTotal();
}
Groups::const_iterator j;
for ( j = m_groups.begin(); j != m_groups.end(); ++j )
{
std::vector < FieldMap* > ::const_iterator k;
for ( k = j->second.begin(); k != j->second.end(); ++k )
result += ( *k ) ->calculateTotal();
}
return result;
}

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.

{
m_fields.clear();
Groups::iterator i;
for ( i = m_groups.begin(); i != m_groups.end(); ++i )
{
std::vector < FieldMap* > ::iterator j;
for ( j = i->second.begin(); j != i->second.end(); ++j )
delete *j;
}
m_groups.clear();
}
FIX::FieldMap::iterator
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.

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

{ return m_fields.end(); }

References m_fields.

## findPositionFor()

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

inline private

Definition at line 342 of file FieldMap.h.

{
if( m_fields.empty() )
return m_fields.end();
const FieldBase& last = m_fields.back();
if( m_order( last.getTag(), tag ) ||
last.getTag() == tag )
{
return m_fields.end();
}
return std::upper_bound( m_fields.begin(), m_fields.end(), tag, sorter( m_order ) );
}

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

Referenced by addField().

## findTag() [1/2]

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

inline private

Definition at line 315 of file FieldMap.h.

{
return lookup( m_fields.begin(), m_fields.end(), tag );
}
FIX::FieldMap::lookup
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

inline private

Definition at line 310 of file FieldMap.h.

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

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.

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

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

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

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

{
field = getFieldRef( field.getTag() );
return field;
}
FIX::FieldMap::getFieldRef
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::generateBusinessReject(), FIX::Session::generateHeartbeat(), FIX::Session::generateLogon(), FIX::Session::generateReject(), FIX::Session::generateSequenceReset(), FIX::Acceptor::getSession(), FIX::Session::next(), FIX::Session::nextQueued(), FIX::Session::nextResendRequest(), FIX::Session::populateRejectReason(), 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.

{
return getFieldRef( tag ).getString();
}
FIX::FieldBase::getString
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.

{
Fields::const_iterator iter = findTag( field.getTag() );
if ( iter == m_fields.end() )
return false;
field = (*iter);
return true;
}
FIX::FieldMap::findTag
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::Session::doPossDup(), FIX::Session::doTargetTooLow(), FIX::Session::generateReject(), FIX::Message::isAdmin(), FIX::Message::isApp(), FIX::Session::next(), FIX::Session::nextResendRequest(), FIX::Session::nextSequenceReset(), 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.

{
return &getFieldRef( tag );
}

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.

{
Fields::const_iterator iter = findTag( tag );
if ( iter == m_fields.end() )
throw FieldNotFound( tag );
return (*iter);
}

References findTag(), and m_fields.

Referenced by 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.

{
return group = getGroupRef( num, tag );
}
FIX::FieldMap::getGroupRef
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.

{
return &getGroupRef( num, tag );
}

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.

{
Groups::const_iterator i = m_groups.find( tag );
if( i == m_groups.end() ) throw FieldNotFound( tag );
if( num <= 0 ) throw FieldNotFound( tag );
if( i->second.size() < (unsigned)num ) throw FieldNotFound( tag );
return *( *(i->second.begin() + (num-1) ) );
}

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.

{
Groups::const_iterator i = m_groups.find( field );
if( i == m_groups.end() )
return 0;
return i->second.size();
}

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.

{
return (int)groupCount(field) >= num;
}
FIX::FieldMap::groupCount
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.

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

References m_groups.

Referenced by 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.

{
return m_fields.empty();
}

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.

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

References FIX::FieldBase::getTag().

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

{ 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

inline private

Definition at line 321 of file FieldMap.h.

{
#if defined(__SUNPRO_CC)
std::size_t numElements;
std::distance( begin, end, numElements );
#else
std::size_t numElements = std::distance( begin, end );
#endif
if( numElements < 16 )
return std::find_if( begin, end, finder( tag ) );
Iterator iter = std::lower_bound( begin, end, tag, sorter( m_order ) );
if( iter != end &&
iter->getTag() == tag )
{
return iter;
}
return end;
}
FIX::FieldMap::begin
iterator begin()
Definition: FieldMap.h:258
FIX::FieldMap::end
iterator end()
Definition: FieldMap.h:259

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

Referenced by findTag().

## operator=()

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

Definition at line 62 of file FieldMap.cpp.

{
clear();
m_fields = rhs.m_fields;
m_order = rhs.m_order;
Groups::const_iterator i;
for ( i = rhs.m_groups.begin(); i != rhs.m_groups.end(); ++i )
{
std::vector < FieldMap* > ::const_iterator j;
for ( j = i->second.begin(); j != i->second.end(); ++j )
{
FieldMap * pGroup = new FieldMap( **j );
m_groups[ i->first ].push_back( pGroup );
}
}
return *this;
}

References clear(), FieldMap(), 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.

{
Fields::iterator i = findTag( field );
if ( i != m_fields.end() )
m_fields.erase( i );
}

References findTag(), and m_fields.

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

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

{
Groups::iterator i = m_groups.find( field );
if ( i == m_groups.end() ) return;
if ( num <= 0 ) return;
std::vector< FieldMap* >& vector = i->second;
if ( vector.size() < ( unsigned ) num ) return;
std::vector< FieldMap* >::iterator iter = vector.begin();
std::advance( iter, ( num - 1 ) );
delete (*iter);
vector.erase( iter );
if( vector.size() == 0 )
{
m_groups.erase( i );
removeField( field );
}
else
{
IntField groupCount( field, (int)vector.size() );
setField( groupCount );
}
}
FIX::FieldMap::removeField
void removeField(int tag)
Remove a field. If field is not present, this is a no-op.
Definition: FieldMap.cpp:156

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

Referenced by 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.

{
Groups::iterator i = m_groups.find( field );
if ( i == m_groups.end() ) return;
removeField( field );
std::vector< FieldMap* > tmp;
tmp.swap( i->second );
m_groups.erase( i );
while ( !tmp.empty() )
{
delete tmp.back();
tmp.pop_back();
}
}

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.

{
Groups::const_iterator i = m_groups.find( field );
if ( i == m_groups.end() ) return;
if ( num <= 0 ) return;
if ( i->second.size() < ( unsigned ) num ) return;
*( *( i->second.begin() + ( num - 1 ) ) ) = group;
}

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

inline protected

Definition at line 286 of file FieldMap.h.

{
Fields::const_reverse_iterator iter = std::find_if( m_fields.rbegin(), m_fields.rend(), finder( tag ) );
if( iter == m_fields.rend() )
throw FieldNotFound( tag );
return *iter;
}

References m_fields.

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

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

{
if( !overwrite )
{
addField( field );
}
else
{
Fields::iterator i = findTag( field.getTag() );
if( i == m_fields.end() )
{
addField( field );
}
else
{
i->setString( field.getString() );
}
}
}
FIX::FieldMap::addField
void addField(const FieldBase &field)
Definition: FieldMap.h:271

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

Referenced by addGroupPtr(), FIX::Session::fill(), FIX::Session::generateBusinessReject(), FIX::Session::generateHeartbeat(), 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::setSessionID(), and FIX::Message::toString().

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

{
FieldBase fieldBase( tag, value );
setField( fieldBase );
}

References setField().

## sortFields()

void FIX::FieldMap::sortFields | ( |  | ) |

inline protected

Definition at line 303 of file FieldMap.h.

{
std::sort( m_fields.begin(), m_fields.end(), sorter(m_order) );
}
sort
void sort(I begin, I end, const Pred &pred)
Definition: pugixml.cpp:6153

References m_fields, m_order, and sort().

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

## totalFields()

size_t FIX::FieldMap::totalFields | ( |  | ) | const

Definition at line 201 of file FieldMap.cpp.

{
size_t result = m_fields.size();
Groups::const_iterator i;
for ( i = m_groups.begin(); i != m_groups.end(); ++i )
{
std::vector < FieldMap* > ::const_iterator j;
for ( j = i->second.begin(); j != i->second.end(); ++j )
result += ( *j ) ->totalFields();
}
return result;
}

References m_fields, and m_groups.

## Friends And Related Function 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

Definition at line 357 of file FieldMap.h.

Referenced by addField(), appendField(), begin(), calculateLength(), calculateString(), calculateTotal(), clear(), end(), FieldMap(), findPositionFor(), findTag(), getFieldIfSet(), getFieldRef(), isEmpty(), isSetField(), operator=(), removeField(), reverse_find(), setField(), sortFields(), and totalFields().

## m_groups

Groups FIX::FieldMap::m_groups

private

Definition at line 358 of file FieldMap.h.

Referenced by addGroupPtr(), calculateLength(), calculateString(), calculateTotal(), clear(), g_begin(), g_end(), getGroupRef(), groupCount(), hasGroup(), operator=(), removeGroup(), replaceGroup(), and totalFields().

## 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:

- FieldMap.h
- FieldMap.cpp