FIX::Message Class Reference

Base class for all FIX messages. More...

`#include <Message.h>`

Inheritance diagram for FIX::Message:
[legend]
Collaboration diagram for FIX::Message:
[legend]

## Public Member Functions

| Message ()
| Message (const message_order &hdrOrder, const message_order &trlOrder, const message_order &order)
| Construct message with a specified order of fields. More...
| Message (const std::string &string, bool validate=true) throw ( InvalidMessage )
| Construct a message from a string. More...
| Message (const std::string &string, const FIX::DataDictionary &dataDictionary, bool validate=true) throw ( InvalidMessage )
| Construct a message from a string using a data dictionary. More...
| Message (const std::string &string, const FIX::DataDictionary &sessionDataDictionary, const FIX::DataDictionary &applicationDataDictionary, bool validate=true) throw ( InvalidMessage )
| Construct a message from a string using a session and application data dictionary. More...
| Message (const message_order &hdrOrder, const message_order &trlOrder, const message_order &order, const std::string &string, const FIX::DataDictionary &dataDictionary, bool validate=true) throw ( InvalidMessage )
| Construct a message from a string using a data dictionary. More...
| Message (const message_order &hdrOrder, const message_order &trlOrder, const message_order &order, const std::string &string, const FIX::DataDictionary &sessionDataDictionary, const FIX::DataDictionary &applicationDataDictionary, bool validate=true) throw ( InvalidMessage )
| Construct a message from a string using a session and application data dictionary. More...
| Message (const Message &copy)
| ~Message ()
void | addGroup (const FIX::Group &group)
void | replaceGroup (unsigned num, const FIX::Group &group)
Group & | getGroup (unsigned num, FIX::Group &group) const throw ( FieldNotFound )
void | removeGroup (unsigned num, const FIX::Group &group)
void | removeGroup (const FIX::Group &group)
bool | hasGroup (const FIX::Group &group) const
bool | hasGroup (unsigned num, const FIX::Group &group) const
std::string | toString (int beginStringField=FIELD::BeginString, int bodyLengthField=FIELD::BodyLength, int checkSumField=FIELD::CheckSum) const
| Get a string representation of the message. More...
std::string & | toString (std::string &, int beginStringField=FIELD::BeginString, int bodyLengthField=FIELD::BodyLength, int checkSumField=FIELD::CheckSum) const
| Get a string representation without making a copy. More...
std::string | toXML () const
| Get a XML representation of the message. More...
std::string & | toXML (std::string &) const
| Get a XML representation without making a copy. More...
void | reverseRoute (const Header &)
| Add header informations depending on a source message. More...
void | setString (const std::string &string) throw ( InvalidMessage )
| Set a message based on a string representation This will fill in the fields on the message by parsing out the string that is passed in. More...
void | setString (const std::string &string, bool validate) throw ( InvalidMessage )
void | setString (const std::string &string, bool validate, const FIX::DataDictionary *pDataDictionary) throw ( InvalidMessage )
void | setString (const std::string &string, bool validate, const FIX::DataDictionary *pSessionDataDictionary, const FIX::DataDictionary *pApplicationDataDictionary) throw ( InvalidMessage )
void | setGroup (const std::string &msg, const FieldBase &field, const std::string &string, std::string::size_type &pos, FieldMap &map, const DataDictionary &dataDictionary)
bool | setStringHeader (const std::string &string)
| Set a messages header from a string This is an optimization that can be used to get useful information from the header of a FIX string without parsing the whole thing. More...
const Header & | getHeader () const
| Getter for the message header. More...
Header & | getHeader ()
| Mutable getter for the message header. More...
const Trailer & | getTrailer () const
| Getter for the message trailer. More...
Trailer & | getTrailer ()
| Mutable getter for the message trailer. More...
bool | hasValidStructure (int &tag) const
int | bodyLength (int beginStringField=FIELD::BeginString, int bodyLengthField=FIELD::BodyLength, int checkSumField=FIELD::CheckSum) const
int | checkSum (int checkSumField=FIELD::CheckSum) const
bool | isAdmin () const
bool | isApp () const
bool | isEmpty ()
void | clear ()
SessionID | getSessionID (const std::string &qualifier="") const throw ( FieldNotFound )
| Returns the session ID of the intended recipient. More...
void | setSessionID (const SessionID &sessionID)
| Sets the session ID of the intended recipient. More...
Public Member Functions inherited from FIX::FieldMap
| 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

## Static Public Member Functions

static bool | InitializeXML (const std::string &string)
| Set global data dictionary for encoding messages into XML. More...
static bool | isAdminMsgType (const MsgType &msgType)
static ApplVerID | toApplVerID (const BeginString &value)
static BeginString | toBeginString (const ApplVerID &applVerID)
static bool | isHeaderField (int field)
static bool | isHeaderField (const FieldBase &field, const DataDictionary *pD=0)
static bool | isHeaderField (int field, const DataDictionary *pD)
static bool | isTrailerField (int field)
static bool | isTrailerField (const FieldBase &field, const DataDictionary *pD=0)
static bool | isTrailerField (int field, const DataDictionary *pD)

## Protected Member Functions

| Message (const BeginString &beginString, const MsgType &msgType)
Protected Member Functions inherited from FIX::FieldMap
| 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 ()

## Protected Attributes

Header | m_header
Trailer | m_trailer
bool | m_validStructure
int | m_tag

## Static Protected Attributes

static SmartPtr< DataDictionary > | s_dataDictionary

## Private Types

enum | field_type { header , body , trailer }

## Private Member Functions

FieldBase | extractField (const std::string &string, std::string::size_type &pos, const DataDictionary *pSessionDD=0, const DataDictionary *pAppDD=0, const Group *pGroup=0) const
void | validate () const
std::string | toXMLFields (const FieldMap &fields, int space) const

## Static Private Member Functions

static bool | IsDataField (int field, const DataDictionary *pSessionDD, const DataDictionary *pAppDD)

## Friends

class | DataDictionary
class | Session

## Additional Inherited Members

Public Types inherited from FIX::FieldMap
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

## Detailed Description

Base class for all FIX messages.

A message consists of three field maps. One for the header, the body, and the trailer.

Definition at line 117 of file Message.h.

## Member Enumeration Documentation

## field_type

enum FIX::Message::field_type

private

Enumerator
header |
body |
trailer |

Definition at line 122 of file Message.h.

{ header, body, trailer };
FIX::Message::trailer
@ trailer
Definition: Message.h:122
FIX::Message::body
@ body
Definition: Message.h:122
FIX::Message::header
@ header
Definition: Message.h:122

## Constructor & Destructor Documentation

## Message() [1/9]

FIX::Message::Message | ( |  | ) |

Definition at line 43 of file Message.cpp.

: m_validStructure( true )
, m_tag( 0 )
{
}
FIX::Message::m_tag
int m_tag
Definition: Message.h:400
FIX::Message::m_validStructure
bool m_validStructure
Definition: Message.h:399

## Message() [2/9]

FIX::Message::Message | ( | const message_order & | hdrOrder,
|  | const message_order & | trlOrder,
|  | const message_order & | order
| ) |  |

Construct message with a specified order of fields.

Definition at line 50 of file Message.cpp.

: FieldMap(order), m_header(hdrOrder),
m_trailer(trlOrder), m_validStructure( true ) {}
FIX::FieldMap::FieldMap
FieldMap(const message_order &order, int size)
Definition: FieldMap.cpp:34
FIX::Message::m_trailer
Trailer m_trailer
Definition: Message.h:398
FIX::Message::m_header
Header m_header
Definition: Message.h:397

## Message() [3/9]

FIX::Message::Message | ( | const std::string & | string,
|  | bool | validate = `true`
| ) |  |
throw | ( | InvalidMessage
| ) |  |

Construct a message from a string.

Definition at line 54 of file Message.cpp.

: m_validStructure( true )
, m_tag( 0 )
{
setString( string, validate );
}
FIX::Message::validate
void validate() const
Definition: Message.cpp:597
FIX::Message::setString
void setString(const std::string &string)
Set a message based on a string representation This will fill in the fields on the message by parsing...
Definition: Message.h:215

## Message() [4/9]

FIX::Message::Message | ( | const std::string & | string,
|  | const FIX::DataDictionary & | dataDictionary,
|  | bool | validate = `true`
| ) |  |
throw | ( | InvalidMessage
| ) |  |

Construct a message from a string using a data dictionary.

Definition at line 62 of file Message.cpp.

: m_validStructure( true )
, m_tag( 0 )
{
setString( string, validate, &dataDictionary, &dataDictionary );
}

## Message() [5/9]

FIX::Message::Message | ( | const std::string & | string,
|  | const FIX::DataDictionary & | sessionDataDictionary,
|  | const FIX::DataDictionary & | applicationDataDictionary,
|  | bool | validate = `true`
| ) |  |
throw | ( | InvalidMessage
| ) |  |

Construct a message from a string using a session and application data dictionary.

Definition at line 72 of file Message.cpp.

: m_validStructure( true )
, m_tag( 0 )
{
setString( string, validate, &sessionDataDictionary, &applicationDataDictionary );
}

## Message() [6/9]

FIX::Message::Message | ( | const message_order & | hdrOrder,
|  | const message_order & | trlOrder,
|  | const message_order & | order,
|  | const std::string & | string,
|  | const FIX::DataDictionary & | dataDictionary,
|  | bool | validate = `true`
| ) |  |
throw | ( | InvalidMessage
| ) |  |

Construct a message from a string using a data dictionary.

Definition at line 83 of file Message.cpp.

: FieldMap(order), m_header(hdrOrder),
m_trailer(trlOrder), m_validStructure( true )
{
setString( string, validate, &dataDictionary, &dataDictionary );
}

## Message() [7/9]

FIX::Message::Message | ( | const message_order & | hdrOrder,
|  | const message_order & | trlOrder,
|  | const message_order & | order,
|  | const std::string & | string,
|  | const FIX::DataDictionary & | sessionDataDictionary,
|  | const FIX::DataDictionary & | applicationDataDictionary,
|  | bool | validate = `true`
| ) |  |
throw | ( | InvalidMessage
| ) |  |

Construct a message from a string using a session and application data dictionary.

Definition at line 96 of file Message.cpp.

: FieldMap(order), m_header(hdrOrder),
m_trailer(trlOrder), m_validStructure( true )
{
setStringHeader( string );
if( isAdmin() )
setString( string, validate, &sessionDataDictionary, &sessionDataDictionary );
else
setString( string, validate, &sessionDataDictionary, &applicationDataDictionary );
}
FIX::Message::setStringHeader
bool setStringHeader(const std::string &string)
Set a messages header from a string This is an optimization that can be used to get useful informatio...
Definition: Message.cpp:475
FIX::Message::isAdmin
bool isAdmin() const
Definition: Message.h:272

## Message() [8/9]

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

Definition at line 122 of file Message.cpp.

: FieldMap(copy)
, m_header(copy.m_header)
, m_trailer(copy.m_trailer)
, m_validStructure(copy.m_validStructure)
, m_tag(copy.m_tag)
#ifdef HAVE_EMX
, m_subMsgType(copy.m_subMsgType)
#endif
{
}

## ~Message()

FIX::Message::~Message | ( |  | ) |

Definition at line 135 of file Message.cpp.

{
}

## Message() [9/9]

FIX::Message::Message | ( | const BeginString & | beginString,
|  | const MsgType & | msgType
| ) |  |

protected

Definition at line 114 of file Message.cpp.

: m_validStructure(true)
, m_tag( 0 )
{
m_header.setField(beginString);
m_header.setField(msgType);
}
FIX::FieldMap::setField
void setField(const FieldBase &field, bool overwrite=true)
Set a field without type checking.
Definition: FieldMap.h:116

References m_header, and FIX::FieldMap::setField().

## Member Function Documentation

## addGroup()

void FIX::Message::addGroup | ( | const FIX::Group & | group | ) |

inline

Definition at line 161 of file Message.h.

{ FieldMap::addGroup( group.field(), group ); }
FIX::FieldMap::addGroup
void addGroup(int tag, const FieldMap &group, bool setCount=true)
Add a group.
Definition: FieldMap.cpp:83
FIX::Group::field
int field() const
Definition: Group.h:56

References FIX::FieldMap::addGroup().

## bodyLength()

int FIX::Message::bodyLength | ( | int | beginStringField = `FIELD::BeginString`,
|  | int | bodyLengthField = `FIELD::BodyLength`,
|  | int | checkSumField = `FIELD::CheckSum`
| ) |  | const

inline

Definition at line 258 of file Message.h.

{ return m_header.calculateLength(beginStringField, bodyLengthField, checkSumField)
+ calculateLength(beginStringField, bodyLengthField, checkSumField)
+ m_trailer.calculateLength(beginStringField, bodyLengthField, checkSumField);
}
FIX::FieldMap::calculateLength
int calculateLength(int beginStringField=FIELD::BeginString, int bodyLengthField=FIELD::BodyLength, int checkSumField=FIELD::CheckSum) const
Definition: FieldMap.cpp:233

References FIX::FieldMap::calculateLength(), m_header, and m_trailer.

Referenced by toString(), and validate().

## checkSum()

int FIX::Message::checkSum | ( | int | checkSumField = `FIELD::CheckSum` | ) | const

inline

Definition at line 266 of file Message.h.

{ return ( m_header.calculateTotal(checkSumField)
+ calculateTotal(checkSumField)
+ m_trailer.calculateTotal(checkSumField) ) % 256;
}
FIX::FieldMap::calculateTotal
int calculateTotal(int checkSumField=FIELD::CheckSum) const
Definition: FieldMap.cpp:258

References FIX::FieldMap::calculateTotal(), m_header, and m_trailer.

Referenced by toString(), and validate().

## clear()

void FIX::Message::clear | ( |  | ) |

inline

Definition at line 291 of file Message.h.

{
m_tag = 0;
m_validStructure = true;
m_header.clear();
FieldMap::clear();
m_trailer.clear();
}
FIX::FieldMap::clear
void clear()
Clear all fields from the map.
Definition: FieldMap.cpp:182

References FIX::FieldMap::clear(), m_header, m_tag, m_trailer, and m_validStructure.

Referenced by setStringHeader().

## extractField()

FIX::FieldBase FIX::Message::extractField | ( | const std::string & | string,
|  | std::string::size_type & | pos,
|  | const DataDictionary * | pSessionDD = `0`,
|  | const DataDictionary * | pAppDD = `0`,
|  | const Group * | pGroup = `0`
| ) |  | const

private

Definition at line 639 of file Message.cpp.

{
std::string::const_iterator const tagStart = string.begin() + pos;
std::string::const_iterator const strEnd = string.end();
std::string::const_iterator const equalSign = std::find( tagStart, strEnd, '=' );
if( equalSign == strEnd )
throw InvalidMessage("Equal sign not found in field");
int field = 0;
if( !IntConvertor::convert( tagStart, equalSign, field ) )
throw InvalidMessage( std::string("Field tag is invalid: ") + std::string( tagStart, equalSign ));
std::string::const_iterator const valueStart = equalSign + 1;
std::string::const_iterator soh = std::find( valueStart, strEnd, '\001' );
if ( soh == strEnd )
throw InvalidMessage("SOH not found at end of field");
if ( IsDataField( field, pSessionDD, pAppDD ) )
{
// Assume length field is 1 less.
int lenField = field - 1;
// Special case for Signature which violates above assumption.
if ( field == FIELD::Signature ) lenField = FIELD::SignatureLength;
// identify part of the message that should contain length field
const FieldMap * location = pGroup;
if ( !location )
{
if ( isHeaderField( lenField, pSessionDD ) )
location = &m_header;
else if ( isTrailerField( lenField, pSessionDD ) )
location = &m_trailer;
else
location = this;
}
try
{
const FieldBase& fieldLength = location->reverse_find( lenField );
soh = valueStart + IntConvertor::convert( fieldLength.getString() );
}
catch( FieldNotFound& )
{
throw InvalidMessage( std::string( "Data length field " ) + IntConvertor::convert( lenField ) + std::string( " was not found for data field " ) + IntConvertor::convert( field ) );
}
catch( FieldConvertError& e )
{
throw InvalidMessage( std::string( "Unable to determine SOH for data field " ) + IntConvertor::convert( field ) + std::string( ": " ) + e.what() );
}
}
std::string::const_iterator const tagEnd = soh + 1;
#if defined(__SUNPRO_CC)
std::distance( string.begin(), tagEnd, pos );
#else
pos = std::distance( string.begin(), tagEnd );
#endif
return FieldBase (
field,
valueStart,
soh,
tagStart,
tagEnd );
}
FIX::FieldMap::begin
iterator begin()
Definition: FieldMap.h:258
FIX::FieldMap::reverse_find
const FieldBase & reverse_find(int tag) const
Definition: FieldMap.h:286
FIX::Message::isHeaderField
static bool isHeaderField(int field)
Definition: Message.cpp:497
FIX::Message::IsDataField
static bool IsDataField(int field, const DataDictionary *pSessionDD, const DataDictionary *pAppDD)
Definition: Message.h:379
FIX::Message::isTrailerField
static bool isTrailerField(int field)
Definition: Message.cpp:550
FIX::IntConvertor::convert
static std::string convert(signed_int value)
Definition: FieldConvertors.h:153

References FIX::FieldMap::begin(), FIX::IntConvertor::convert(), FIX::FieldBase::getString(), IsDataField(), isHeaderField(), isTrailerField(), m_header, m_trailer, and FIX::FieldMap::reverse_find().

Referenced by setGroup(), and setStringHeader().

## getGroup()

Group& FIX::Message::getGroup | ( | unsigned | num,
|  | FIX::Group & | group
| ) |  | const
throw | ( | FieldNotFound
| ) |  |

inline

Definition at line 167 of file Message.h.

{ group.clear();
return static_cast < Group& >
( FieldMap::getGroup( num, group.field(), group ) );
}
FIX::FieldMap::getGroup
FieldMap & getGroup(int num, int tag, FieldMap &group) const
Get a specific instance of a group.
Definition: FieldMap.h:207

References FIX::FieldMap::clear(), and FIX::FieldMap::getGroup().

## getHeader() [1/2]

Header& FIX::Message::getHeader | ( |  | ) |

inline

Mutable getter for the message header.

Definition at line 247 of file Message.h.

{ return m_header; }

References m_header.

## getHeader() [2/2]

const Header& FIX::Message::getHeader | ( |  | ) | const

inline

Getter for the message header.

Definition at line 245 of file Message.h.

{ return m_header; }

References m_header.

Referenced by FIX::MessageCracker::crack(), FIX::Session::doPossDup(), FIX::Session::doTargetTooHigh(), FIX::Session::doTargetTooLow(), FIX::Session::generateBusinessReject(), FIX::Session::generateHeartbeat(), FIX::Session::generateReject(), FIX::Session::generateResendRequest(), FIX::Session::generateSequenceReset(), FIX::Session::generateTestRequest(), FIX::Acceptor::getSession(), FIX::Session::lookupSession(), FIX::Session::next(), FIX::Session::nextQueued(), FIX::Session::nextResendRequest(), FIX::Session::populateRejectReason(), FIX::Session::resend(), FIX::Session::send(), FIX::Session::sendRaw(), setSessionID(), toXML(), and FIX::Session::verify().

## getSessionID()

SessionID FIX::Message::getSessionID | ( | const std::string & | qualifier = `""` | ) | const
throw | ( | FieldNotFound
| ) |  |

Returns the session ID of the intended recipient.

Definition at line 576 of file Message.cpp.

{
BeginString beginString;
SenderCompID senderCompID;
TargetCompID targetCompID;
getHeader().getField( beginString );
getHeader().getField( senderCompID );
getHeader().getField( targetCompID );
return SessionID( beginString, senderCompID, targetCompID, qualifier );
}
FIX::FieldMap::getField
FieldBase & getField(FieldBase &field) const
Get a field without type checking.
Definition: FieldMap.h:156
FIX::Message::getHeader
const Header & getHeader() const
Getter for the message header.
Definition: Message.h:245

## getTrailer() [1/2]

Trailer& FIX::Message::getTrailer | ( |  | ) |

inline

Mutable getter for the message trailer.

Definition at line 251 of file Message.h.

{ return m_trailer; }

References m_trailer.

## getTrailer() [2/2]

const Trailer& FIX::Message::getTrailer | ( |  | ) | const

inline

Getter for the message trailer.

Definition at line 249 of file Message.h.

{ return m_trailer; }

References m_trailer.

Referenced by toXML().

## hasGroup() [1/2]

bool FIX::Message::hasGroup | ( | const FIX::Group & | group | ) | const

inline

Definition at line 178 of file Message.h.

{ return FieldMap::hasGroup( group.field() ); }
FIX::FieldMap::hasGroup
bool hasGroup(int tag) const
Check to see any instance of a group exists.
Definition: FieldMap.cpp:168

References FIX::Group::field(), and FIX::FieldMap::hasGroup().

## hasGroup() [2/2]

bool FIX::Message::hasGroup | ( | unsigned | num,
|  | const FIX::Group & | group
| ) |  | const

inline

Definition at line 180 of file Message.h.

{ return FieldMap::hasGroup( num, group.field() ); }

References FIX::Group::field(), and FIX::FieldMap::hasGroup().

## hasValidStructure()

bool FIX::Message::hasValidStructure | ( | int & | tag | ) | const

inline

Definition at line 253 of file Message.h.

{ tag = m_tag;
return m_validStructure;
}

References m_tag, and m_validStructure.

## InitializeXML()

bool FIX::Message::InitializeXML | ( | const std::string & | string | ) |

static

Set global data dictionary for encoding messages into XML.

Definition at line 139 of file Message.cpp.

{
try
{
s_dataDictionary.reset(new DataDictionary(url));
return true;
}
catch( ConfigError& )
{ return false; }
}
FIX::Message::DataDictionary
friend class DataDictionary
Definition: Message.h:119
FIX::Message::s_dataDictionary
static SmartPtr< DataDictionary > s_dataDictionary
Definition: Message.h:404

References DataDictionary, and s_dataDictionary.

## isAdmin()

bool FIX::Message::isAdmin | ( |  | ) | const

inline

Definition at line 272 of file Message.h.

{
MsgType msgType;
if( m_header.getFieldIfSet( msgType ) )
return isAdminMsgType( msgType );
return false;
}
FIX::FieldMap::getFieldIfSet
bool getFieldIfSet(FieldBase &field) const
Get a field if set.
Definition: FieldMap.h:146
FIX::Message::isAdminMsgType
static bool isAdminMsgType(const MsgType &msgType)
Definition: Message.h:300

References FIX::FieldMap::getFieldIfSet(), isAdminMsgType(), and m_header.

Referenced by FIX::MessageCracker::crack().

## isAdminMsgType()

static bool FIX::Message::isAdminMsgType | ( | const MsgType & | msgType | ) |

inline static

Definition at line 300 of file Message.h.

{ if ( msgType.getValue().length() != 1 ) return false;
return strchr
( "0A12345",
msgType.getValue().c_str() [ 0 ] ) != 0;
}

Referenced by FIX::Session::fromCallback(), isAdmin(), isApp(), FIX::Session::newMessage(), FIX::Session::nextResendRequest(), and FIX::Session::sendRaw().

## isApp()

bool FIX::Message::isApp | ( |  | ) | const

inline

Definition at line 280 of file Message.h.

{
MsgType msgType;
if( m_header.getFieldIfSet( msgType ) )
return !isAdminMsgType( msgType );
return false;
}

References FIX::FieldMap::getFieldIfSet(), isAdminMsgType(), and m_header.

Referenced by FIX::Session::next().

## IsDataField()

static bool FIX::Message::IsDataField | ( | int | field,
|  | const DataDictionary * | pSessionDD,
|  | const DataDictionary * | pAppDD
| ) |  |

inline static private

Definition at line 379 of file Message.h.

{
if( (pSessionDD && pSessionDD->isDataField( field )) ||
(pAppDD && pAppDD != pSessionDD && pAppDD->isDataField( field )) )
{
return true;
}
return false;
}

References FIX::DataDictionary::isDataField().

Referenced by extractField().

## isEmpty()

bool FIX::Message::isEmpty | ( |  | ) |

inline

Definition at line 288 of file Message.h.

{ return m_header.isEmpty() && FieldMap::isEmpty() && m_trailer.isEmpty(); }
FIX::FieldMap::isEmpty
bool isEmpty()
Check if map contains any fields.
Definition: FieldMap.cpp:196

References FIX::FieldMap::isEmpty(), m_header, and m_trailer.

## isHeaderField() [1/3]

bool FIX::Message::isHeaderField | ( | const FieldBase & | field,
|  | const DataDictionary * | pD = `0`
| ) |  |

static

Definition at line 536 of file Message.cpp.

{
return isHeaderField( field.getTag(), pD );
}

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

## isHeaderField() [2/3]

bool FIX::Message::isHeaderField | ( | int | field | ) |

static

Definition at line 497 of file Message.cpp.

{
switch ( field )
{
case FIELD::BeginString:
case FIELD::BodyLength:
case FIELD::MsgType:
case FIELD::SenderCompID:
case FIELD::TargetCompID:
case FIELD::OnBehalfOfCompID:
case FIELD::DeliverToCompID:
case FIELD::SecureDataLen:
case FIELD::MsgSeqNum:
case FIELD::SenderSubID:
case FIELD::SenderLocationID:
case FIELD::TargetSubID:
case FIELD::TargetLocationID:
case FIELD::OnBehalfOfSubID:
case FIELD::OnBehalfOfLocationID:
case FIELD::DeliverToSubID:
case FIELD::DeliverToLocationID:
case FIELD::PossDupFlag:
case FIELD::PossResend:
case FIELD::SendingTime:
case FIELD::OrigSendingTime:
case FIELD::XmlDataLen:
case FIELD::XmlData:
case FIELD::MessageEncoding:
case FIELD::LastMsgSeqNumProcessed:
case FIELD::OnBehalfOfSendingTime:
case FIELD::ApplVerID:
case FIELD::CstmApplVerID:
case FIELD::NoHops:
return true;
default:
return false;
};
}
FIX::TYPE::XmlData
@ XmlData
Definition: FieldTypes.h:941

References FIX::TYPE::XmlData.

Referenced by extractField(), isHeaderField(), FIX::DataDictionary::iterate(), and setStringHeader().

## isHeaderField() [3/3]

bool FIX::Message::isHeaderField | ( | int | field,
|  | const DataDictionary * | pD
| ) |  |

static

Definition at line 542 of file Message.cpp.

{
if ( isHeaderField( field ) ) return true;
if ( pD ) return pD->isHeaderField( field );
return false;
}

References isHeaderField(), and FIX::DataDictionary::isHeaderField().

## isTrailerField() [1/3]

bool FIX::Message::isTrailerField | ( | const FieldBase & | field,
|  | const DataDictionary * | pD = `0`
| ) |  |

static

Definition at line 563 of file Message.cpp.

{
return isTrailerField( field.getTag(), pD );
}

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

## isTrailerField() [2/3]

bool FIX::Message::isTrailerField | ( | int | field | ) |

static

Definition at line 550 of file Message.cpp.

{
switch ( field )
{
case FIELD::SignatureLength:
case FIELD::Signature:
case FIELD::CheckSum:
return true;
default:
return false;
};
}

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

## isTrailerField() [3/3]

bool FIX::Message::isTrailerField | ( | int | field,
|  | const DataDictionary * | pD
| ) |  |

static

Definition at line 569 of file Message.cpp.

{
if ( isTrailerField( field ) ) return true;
if ( pD ) return pD->isTrailerField( field );
return false;
}

References isTrailerField(), and FIX::DataDictionary::isTrailerField().

## removeGroup() [1/2]

void FIX::Message::removeGroup | ( | const FIX::Group & | group | ) |

inline

Definition at line 175 of file Message.h.

{ FieldMap::removeGroup( group.field() ); }
FIX::FieldMap::removeGroup
void removeGroup(int num, int tag)
Remove a specific instance of a group.
Definition: FieldMap.cpp:111

References FIX::Group::field(), and FIX::FieldMap::removeGroup().

## removeGroup() [2/2]

void FIX::Message::removeGroup | ( | unsigned | num,
|  | const FIX::Group & | group
| ) |  |

inline

Definition at line 173 of file Message.h.

{ FieldMap::removeGroup( num, group.field() ); }

References FIX::Group::field(), and FIX::FieldMap::removeGroup().

## replaceGroup()

void FIX::Message::replaceGroup | ( | unsigned | num,
|  | const FIX::Group & | group
| ) |  |

inline

Definition at line 164 of file Message.h.

{ FieldMap::replaceGroup( num, group.field(), group ); }
FIX::FieldMap::replaceGroup
void replaceGroup(int num, int tag, const FieldMap &group)
Replace a specific instance of a group.
Definition: FieldMap.cpp:102

References FIX::Group::field(), and FIX::FieldMap::replaceGroup().

## reverseRoute()

void FIX::Message::reverseRoute | ( | const Header & | header | ) |

Add header informations depending on a source message.

This can be used to add routing informations like OnBehalfOfCompID and DeliverToCompID to a message.

Definition at line 150 of file Message.cpp.

{
// required routing tags
BeginString beginString;
SenderCompID senderCompID;
TargetCompID targetCompID;
m_header.removeField( beginString.getTag() );
m_header.removeField( senderCompID.getTag() );
m_header.removeField( targetCompID.getTag() );
if( header.getFieldIfSet( beginString ) )
{
if( beginString.getValue().size() )
m_header.setField( beginString );
OnBehalfOfLocationID onBehalfOfLocationID;
DeliverToLocationID deliverToLocationID;
m_header.removeField( onBehalfOfLocationID.getTag() );
m_header.removeField( deliverToLocationID.getTag() );
if( beginString >= BeginString_FIX41 )
{
if( header.getFieldIfSet( onBehalfOfLocationID ) )
{
if( onBehalfOfLocationID.getValue().size() )
m_header.setField( DeliverToLocationID( onBehalfOfLocationID ) );
}
if( header.getFieldIfSet( deliverToLocationID ) )
{
if( deliverToLocationID.getValue().size() )
m_header.setField( OnBehalfOfLocationID( deliverToLocationID ) );
}
}
}
if( header.getFieldIfSet( senderCompID ) )
{
if( senderCompID.getValue().size() )
m_header.setField( TargetCompID( senderCompID ) );
}
if( header.getFieldIfSet( targetCompID ) )
{
if( targetCompID.getValue().size() )
m_header.setField( SenderCompID( targetCompID ) );
}
// optional routing tags
OnBehalfOfCompID onBehalfOfCompID;
OnBehalfOfSubID onBehalfOfSubID;
DeliverToCompID deliverToCompID;
DeliverToSubID deliverToSubID;
m_header.removeField( onBehalfOfCompID.getTag() );
m_header.removeField( onBehalfOfSubID.getTag() );
m_header.removeField( deliverToCompID.getTag() );
m_header.removeField( deliverToSubID.getTag() );
if( header.getFieldIfSet( onBehalfOfCompID ) )
{
if( onBehalfOfCompID.getValue().size() )
m_header.setField( DeliverToCompID( onBehalfOfCompID ) );
}
if( header.getFieldIfSet( onBehalfOfSubID ) )
{
if( onBehalfOfSubID.getValue().size() )
m_header.setField( DeliverToSubID( onBehalfOfSubID ) );
}
if( header.getFieldIfSet( deliverToCompID ) )
{
if( deliverToCompID.getValue().size() )
m_header.setField( OnBehalfOfCompID( deliverToCompID ) );
}
if( header.getFieldIfSet( deliverToSubID ) )
{
if( deliverToSubID.getValue().size() )
m_header.setField( OnBehalfOfSubID( deliverToSubID ) );
}
}
FIX::FieldMap::removeField
void removeField(int tag)
Remove a field. If field is not present, this is a no-op.
Definition: FieldMap.cpp:156
FIX::BeginString_FIX41
const char BeginString_FIX41[]
Definition: Values.h:35

References FIX::BeginString_FIX41, header, m_header, FIX::FieldMap::removeField(), and FIX::FieldMap::setField().

Referenced by FIX::Session::generateReject().

## setGroup()

void FIX::Message::setGroup | ( | const std::string & | msg,
|  | const FieldBase & | field,
|  | const std::string & | string,
|  | std::string::size_type & | pos,
|  | FieldMap & | map,
|  | const DataDictionary & | dataDictionary
| ) |  |

Definition at line 431 of file Message.cpp.

{
int group = field.getTag();
int delim;
const DataDictionary* pDD = 0;
if ( !dataDictionary.getGroup( msg, group, delim, pDD ) ) return ;
SmartPtr<Group> pGroup;
while ( pos < string.size() )
{
std::string::size_type oldPos = pos;
FieldBase field = extractField( string, pos, &dataDictionary, &dataDictionary, pGroup.get() );
// Start a new group because...
if (// found delimiter
(field.getTag() == delim) ||
// no delimiter, but field belongs to group OR field already processed
(pDD->isField( field.getTag() ) && (pGroup.get() == 0 || pGroup->isSetField( field.getTag() )) ))
{
if ( pGroup.get() )
{
map.addGroupPtr( group, pGroup.release(), false );
}
pGroup.reset( new Group( field.getTag(), delim, pDD->getOrderedFields() ) );
}
else if ( !pDD->isField( field.getTag() ) )
{
if ( pGroup.get() )
{
map.addGroupPtr( group, pGroup.release(), false );
}
pos = oldPos;
return ;
}
if ( !pGroup.get() ) return ;
pGroup->addField( field );
setGroup( msg, field, string, pos, *pGroup, *pDD );
}
}
FIX::Message::extractField
FieldBase extractField(const std::string &string, std::string::size_type &pos, const DataDictionary *pSessionDD=0, const DataDictionary *pAppDD=0, const Group *pGroup=0) const
Definition: Message.cpp:639
FIX::Message::setGroup
void setGroup(const std::string &msg, const FieldBase &field, const std::string &string, std::string::size_type &pos, FieldMap &map, const DataDictionary &dataDictionary)
Definition: Message.cpp:431

References FIX::FieldMap::addGroupPtr(), extractField(), FIX::DataDictionary::getGroup(), FIX::DataDictionary::getOrderedFields(), FIX::FieldBase::getTag(), and FIX::DataDictionary::isField().

## setSessionID()

void FIX::Message::setSessionID | ( | const SessionID & | sessionID | ) |

Sets the session ID of the intended recipient.

Definition at line 590 of file Message.cpp.

{
getHeader().setField( sessionID.getBeginString() );
getHeader().setField( sessionID.getSenderCompID() );
getHeader().setField( sessionID.getTargetCompID() );
}

References FIX::SessionID::getBeginString(), getHeader(), FIX::SessionID::getSenderCompID(), FIX::SessionID::getTargetCompID(), and FIX::FieldMap::setField().

## setString() [1/4]

void FIX::Message::setString | ( | const std::string & | string | ) |
throw | ( | InvalidMessage
| ) |  |

inline

Set a message based on a string representation This will fill in the fields on the message by parsing out the string that is passed in.

It will return true on success and false on failure.

Definition at line 215 of file Message.h.

{ setString(string, true); }

Referenced by setString().

## setString() [2/4]

void FIX::Message::setString | ( | const std::string & | string,
|  | bool | validate
| ) |  |
throw | ( | InvalidMessage
| ) |  |

inline

Definition at line 218 of file Message.h.

{ setString(string, validate, 0); }

References setString(), and validate().

## setString() [3/4]

void FIX::Message::setString | ( | const std::string & | string,
|  | bool | validate,
|  | const FIX::DataDictionary * | pDataDictionary
| ) |  |
throw | ( | InvalidMessage
| ) |  |

inline

Definition at line 221 of file Message.h.

{ setString(string, validate, pDataDictionary, pDataDictionary); }

References setString(), and validate().

## setString() [4/4]

void FIX::Message::setString | ( | const std::string & | string,
|  | bool | validate,
|  | const FIX::DataDictionary * | pSessionDataDictionary,
|  | const FIX::DataDictionary * | pApplicationDataDictionary
| ) |  |
throw | ( | InvalidMessage
| ) |  |

Definition at line 336 of file Message.cpp.

{
clear();
std::string::size_type pos = 0;
int count = 0;
FIX::MsgType msg;
field_type type = header;
while ( pos < string.size() )
{
FieldBase field = extractField( string, pos, pSessionDataDictionary, pApplicationDataDictionary );
if ( count < 3 && headerOrder[ count++ ] != field.getTag() )
if ( doValidation ) throw InvalidMessage("Header fields out of order");
if ( isHeaderField( field, pSessionDataDictionary ) )
{
if ( type != header )
{
if(m_tag == 0) m_tag = field.getTag();
m_validStructure = false;
}
if ( field.getTag() == FIELD::MsgType )
{
msg.setString( field.getString() );
if ( isAdminMsgType( msg ) )
{
pApplicationDataDictionary = pSessionDataDictionary;
#ifdef HAVE_EMX
m_subMsgType.assign(msg);
}
else
{
std::string::size_type equalSign = string.find("\0019426=", pos);
if (equalSign == std::string::npos)
throw InvalidMessage("EMX message type (9426) not found");
equalSign += 6;
std::string::size_type soh = string.find_first_of('\001', equalSign);
if (soh == std::string::npos)
throw InvalidMessage("EMX message type (9426) soh char not found");
m_subMsgType.assign(string.substr(equalSign, soh - equalSign ));
#endif
}
}
m_header.appendField( field );
if ( pSessionDataDictionary )
setGroup( "_header_", field, string, pos, getHeader(), *pSessionDataDictionary );
}
else if ( isTrailerField( field, pSessionDataDictionary ) )
{
type = trailer;
m_trailer.appendField( field );
if ( pSessionDataDictionary )
setGroup( "_trailer_", field, string, pos, getTrailer(), *pSessionDataDictionary );
}
else
{
if ( type == trailer )
{
if(m_tag == 0) m_tag = field.getTag();
m_validStructure = false;
}
type = body;
appendField( field );
if ( pApplicationDataDictionary )
#ifdef HAVE_EMX
setGroup(m_subMsgType, field, string, pos, *this, *pApplicationDataDictionary);
#else
setGroup( msg, field, string, pos, *this, *pApplicationDataDictionary );
#endif
}
}
// sort fields
m_header.sortFields();
sortFields();
m_trailer.sortFields();
if ( doValidation )
validate();
}
FIX::FieldMap::sortFields
void sortFields()
Definition: FieldMap.h:303
FIX::FieldMap::appendField
void appendField(const FieldBase &field)
Definition: FieldMap.h:297
FIX::Message::clear
void clear()
Definition: Message.h:291
FIX::Message::getTrailer
const Trailer & getTrailer() const
Getter for the message trailer.
Definition: Message.h:249
FIX::Message::field_type
field_type
Definition: Message.h:122
FIX::headerOrder
int const headerOrder[]
Definition: Message.cpp:34

References FIX::FieldBase::getString(), FIX::FieldBase::getTag(), and FIX::headerOrder.

## setStringHeader()

bool FIX::Message::setStringHeader | ( | const std::string & | string | ) |

Set a messages header from a string This is an optimization that can be used to get useful information from the header of a FIX string without parsing the whole thing.

Definition at line 475 of file Message.cpp.

{
clear();
std::string::size_type pos = 0;
int count = 0;
while ( pos < string.size() )
{
FieldBase field = extractField( string, pos );
if ( count < 3 && headerOrder[ count++ ] != field.getTag() )
return false;
if ( isHeaderField( field ) )
m_header.appendField( field );
else break;
}
m_header.sortFields();
return true;
}

References FIX::FieldMap::appendField(), clear(), extractField(), FIX::FieldBase::getTag(), FIX::headerOrder, isHeaderField(), m_header, and FIX::FieldMap::sortFields().

Referenced by FIX::Acceptor::getSession(), FIX::Session::lookupSession(), and FIX::Session::nextResendRequest().

## toApplVerID()

static ApplVerID FIX::Message::toApplVerID | ( | const BeginString & | value | ) |

inline static

Definition at line 307 of file Message.h.

{
if( value == BeginString_FIX40 )
return ApplVerID(ApplVerID_FIX40);
if( value == BeginString_FIX41 )
return ApplVerID(ApplVerID_FIX41);
if( value == BeginString_FIX42 )
return ApplVerID(ApplVerID_FIX42);
if( value == BeginString_FIX43 )
return ApplVerID(ApplVerID_FIX43);
if( value == BeginString_FIX44 )
return ApplVerID(ApplVerID_FIX44);
if( value == BeginString_FIX50 )
return ApplVerID(ApplVerID_FIX50);
if( value == "FIX.5.0SP1" )
return ApplVerID(ApplVerID_FIX50SP1);
if( value == "FIX.5.0SP2" )
return ApplVerID(ApplVerID_FIX50SP2);
return ApplVerID(ApplVerID(value));
}
FIX::BeginString_FIX40
const char BeginString_FIX40[]
Definition: Values.h:36
FIX::BeginString_FIX42
const char BeginString_FIX42[]
Definition: Values.h:34
FIX::BeginString_FIX50
const char BeginString_FIX50[]
Definition: Values.h:31
FIX::BeginString_FIX43
const char BeginString_FIX43[]
Definition: Values.h:33
FIX::BeginString_FIX44
const char BeginString_FIX44[]
Definition: Values.h:32

References FIX::BeginString_FIX40, FIX::BeginString_FIX41, FIX::BeginString_FIX42, FIX::BeginString_FIX43, FIX::BeginString_FIX44, and FIX::BeginString_FIX50.

Referenced by FIX::SessionFactory::create(), FIX::Session::next(), FIX::SessionFactory::processFixDataDictionary(), and FIX::SessionFactory::processFixtDataDictionaries().

## toBeginString()

static BeginString FIX::Message::toBeginString | ( | const ApplVerID & | applVerID | ) |

inline static

Definition at line 328 of file Message.h.

{
if( applVerID == ApplVerID_FIX40 )
return BeginString(BeginString_FIX40);
else if( applVerID == ApplVerID_FIX41 )
return BeginString(BeginString_FIX41);
else if( applVerID == ApplVerID_FIX42 )
return BeginString(BeginString_FIX42);
else if( applVerID == ApplVerID_FIX43 )
return BeginString(BeginString_FIX43);
else if( applVerID == ApplVerID_FIX44 )
return BeginString(BeginString_FIX44);
else if( applVerID == ApplVerID_FIX50 )
return BeginString(BeginString_FIX50);
else if( applVerID == ApplVerID_FIX50SP1 )
return BeginString(BeginString_FIX50);
else if( applVerID == ApplVerID_FIX50SP2 )
return BeginString(BeginString_FIX50);
else
return BeginString("");
}

References FIX::BeginString_FIX40, FIX::BeginString_FIX41, FIX::BeginString_FIX42, FIX::BeginString_FIX43, FIX::BeginString_FIX44, and FIX::BeginString_FIX50.

## toString() [1/2]

std::string FIX::Message::toString | ( | int | beginStringField = `FIELD::BeginString`,
|  | int | bodyLengthField = `FIELD::BodyLength`,
|  | int | checkSumField = `FIELD::CheckSum`
| ) |  | const

Get a string representation of the message.

Definition at line 236 of file Message.cpp.

{
std::string str;
toString( str, beginStringField, bodyLengthField, checkSumField );
return str;
}
FIX::Message::toString
std::string toString(int beginStringField=FIELD::BeginString, int bodyLengthField=FIELD::BodyLength, int checkSumField=FIELD::CheckSum) const
Get a string representation of the message.
Definition: Message.cpp:236

Referenced by FIX::Session::nextResendRequest(), and FIX::Session::sendRaw().

## toString() [2/2]

std::string & FIX::Message::toString | ( | std::string & | str,
|  | int | beginStringField = `FIELD::BeginString`,
|  | int | bodyLengthField = `FIELD::BodyLength`,
|  | int | checkSumField = `FIELD::CheckSum`
| ) |  | const

Get a string representation without making a copy.

Definition at line 245 of file Message.cpp.

{
int length = bodyLength( beginStringField, bodyLengthField, checkSumField );
m_header.setField( IntField(bodyLengthField, length) );
m_trailer.setField( CheckSumField(checkSumField, checkSum(checkSumField)) );
#if defined(_MSC_VER) && _MSC_VER < 1300
str = "";
#else
str.clear();
#endif
/*small speculation about the space needed for FIX string*/
str.reserve( length + 64 );
m_header.calculateString( str );
FieldMap::calculateString( str );
m_trailer.calculateString( str );
return str;
}
FIX::FieldMap::calculateString
std::string & calculateString(std::string &) const
Definition: FieldMap.cpp:215
FIX::Message::bodyLength
int bodyLength(int beginStringField=FIELD::BeginString, int bodyLengthField=FIELD::BodyLength, int checkSumField=FIELD::CheckSum) const
Definition: Message.h:258
FIX::Message::checkSum
int checkSum(int checkSumField=FIELD::CheckSum) const
Definition: Message.h:266

References bodyLength(), FIX::FieldMap::calculateString(), checkSum(), m_header, m_trailer, and FIX::FieldMap::setField().

## toXML() [1/2]

std::string FIX::Message::toXML | ( |  | ) | const

Get a XML representation of the message.

Definition at line 270 of file Message.cpp.

{
std::string str;
toXML( str );
return str;
}
FIX::Message::toXML
std::string toXML() const
Get a XML representation of the message.
Definition: Message.cpp:270

## toXML() [2/2]

std::string & FIX::Message::toXML | ( | std::string & | str | ) | const

Get a XML representation without making a copy.

Definition at line 277 of file Message.cpp.

{
std::stringstream stream;
stream << "<message>" << std::endl
<< std::setw(2) << " " << "<header>" << std::endl
<< toXMLFields(getHeader(), 4)
<< std::setw(2) << " " << "</header>" << std::endl
<< std::setw(2) << " " << "<body>" << std::endl
<< toXMLFields(*this, 4)
<< std::setw(2) << " " << "</body>" << std::endl
<< std::setw(2) << " " << "<trailer>" << std::endl
<< toXMLFields(getTrailer(), 4)
<< std::setw(2) << " " << "</trailer>" << std::endl
<< "</message>";
return str = stream.str();
}
FIX::Message::toXMLFields
std::string toXMLFields(const FieldMap &fields, int space) const
Definition: Message.cpp:295

References getHeader(), getTrailer(), and toXMLFields().

## toXMLFields()

std::string FIX::Message::toXMLFields | ( | const FieldMap & | fields,
|  | int | space
| ) |  | const

private

Definition at line 295 of file Message.cpp.

{
std::stringstream stream;
FieldMap::const_iterator i;
std::string name;
for(i = fields.begin(); i != fields.end(); ++i)
{
int field = i->getTag();
std::string value = i->getString();
stream << std::setw(space) << " " << "<field ";
if(s_dataDictionary.get() && s_dataDictionary->getFieldName(field, name))
{
stream << "name=\"" << name << "\" ";
}
stream << "number=\"" << field << "\"";
if(s_dataDictionary.get()
&& s_dataDictionary->getValueName(field, value, name))
{
stream << " enum=\"" << name << "\"";
}
stream << ">";
stream << "<![CDATA[" << value << "]]>";
stream << "</field>" << std::endl;
}
FieldMap::g_const_iterator j;
for(j = fields.g_begin(); j != fields.g_end(); ++j)
{
std::vector<FieldMap*>::const_iterator k;
for(k = j->second.begin(); k != j->second.end(); ++k)
{
stream << std::setw(space) << " " << "<group>" << std::endl
<< toXMLFields(*(*k), space+2)
<< std::setw(space) << " " << "</group>" << std::endl;
}
}
return stream.str();
}
FIX::FieldMap::g_const_iterator
Groups::const_iterator g_const_iterator
Definition: FieldMap.h:102
FIX::FieldMap::const_iterator
Fields::const_iterator const_iterator
Definition: FieldMap.h:100

References FIX::FieldMap::begin(), FIX::FieldMap::end(), FIX::FieldMap::g_begin(), FIX::FieldMap::g_end(), and s_dataDictionary.

Referenced by toXML().

## validate()

void FIX::Message::validate | ( |  | ) | const

private

Definition at line 597 of file Message.cpp.

{
try
{
const BodyLength& aBodyLength = FIELD_GET_REF( m_header, BodyLength );
const int expectedLength = (int)aBodyLength;
const int actualLength = bodyLength();
if ( expectedLength != actualLength )
{
std::stringstream text;
text << "Expected BodyLength=" << actualLength
<< ", Received BodyLength=" << expectedLength;
throw InvalidMessage(text.str());
}
const CheckSum& aCheckSum = FIELD_GET_REF( m_trailer, CheckSum );
const int expectedChecksum = (int)aCheckSum;
const int actualChecksum = checkSum();
if ( expectedChecksum != actualChecksum )
{
std::stringstream text;
text << "Expected CheckSum=" << actualChecksum
<< ", Received CheckSum=" << expectedChecksum;
throw InvalidMessage(text.str());
}
}
catch ( FieldNotFound& e )
{
const std::string fieldName = ( e.field == FIX::FIELD::BodyLength ) ? "BodyLength" : "CheckSum";
throw InvalidMessage( fieldName + std::string(" is missing") );
}
catch ( IncorrectDataFormat& e )
{
const std::string fieldName = ( e.field == FIX::FIELD::BodyLength ) ? "BodyLength" : "CheckSum";
throw InvalidMessage( fieldName + std::string(" has wrong format: ") + e.detail );
}
}
FIELD_GET_REF
#define FIELD_GET_REF(MAP, FLD)
Definition: FieldMap.h:376

References bodyLength(), checkSum(), FIX::Exception::detail, FIX::FieldNotFound::field, FIELD_GET_REF, m_header, and m_trailer.

Referenced by setString().

## Friends And Related Function Documentation

## DataDictionary

friend class DataDictionary

friend

Definition at line 119 of file Message.h.

Referenced by InitializeXML().

## Session

friend class Session

friend

Definition at line 120 of file Message.h.

## Member Data Documentation

## m_header

Header FIX::Message::m_header

mutable protected

Definition at line 397 of file Message.h.

Referenced by bodyLength(), checkSum(), clear(), extractField(), getHeader(), isAdmin(), isApp(), isEmpty(), Message(), reverseRoute(), setStringHeader(), toString(), and validate().

## m_tag

int FIX::Message::m_tag

protected

Definition at line 400 of file Message.h.

Referenced by clear(), and hasValidStructure().

## m_trailer

Trailer FIX::Message::m_trailer

mutable protected

Definition at line 398 of file Message.h.

Referenced by bodyLength(), checkSum(), clear(), extractField(), getTrailer(), isEmpty(), toString(), and validate().

## m_validStructure

bool FIX::Message::m_validStructure

protected

Definition at line 399 of file Message.h.

Referenced by clear(), and hasValidStructure().

## s_dataDictionary

SmartPtr< DataDictionary > FIX::Message::s_dataDictionary

static protected

Definition at line 404 of file Message.h.

Referenced by InitializeXML(), and toXMLFields().

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

- Message.h
- Message.cpp