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 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 &copy)
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 &field) 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 field, 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 field) const throw ( FieldNotFound )
| Get a field without a field class. More...
const FieldBase & | getFieldRef (int field) const throw ( FieldNotFound )
| Get direct access to a field through a reference. More...
const FieldBase *const | getFieldPtr (int field) 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 field) const
| Check to see if a field is set by referencing its number. More...
void | removeField (int field)
| Remove a field. If field is not present, this is a no-op. More...
void | addGroup (int field, const FieldMap &group, bool setCount=true)
| Add a group. More...
void | addGroupPtr (int field, FieldMap *group, bool setCount=true)
| Acquire ownership of Group object. More...
void | replaceGroup (int num, int field, const FieldMap &group)
| Replace a specific instance of a group. More...
FieldMap & | getGroup (int num, int field, FieldMap &group) const throw ( FieldNotFound )
| Get a specific instance of a group. More...
FieldMap & | getGroupRef (int num, int field) const throw ( FieldNotFound )
| Get direct access to a field through a reference. More...
FieldMap * | getGroupPtr (int num, int field) const throw ( FieldNotFound )
| Get direct access to a field through a pointer. More...
void | removeGroup (int num, int field)
| Remove a specific instance of a group. More...
void | removeGroup (int field)
| Remove all instances of a group. More...
bool | hasGroup (int field) const
| Check to see any instance of a group exists. More...
bool | hasGroup (int num, int field) const
| Check to see if a specific instance of a group exists. More...
size_t | groupCount (int field) 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 () const
iterator | end () const
g_iterator | g_begin () const
g_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 | isTrailerField (int field)
static bool | isTrailerField (const FieldBase &field, const DataDictionary *pD=0)

## Protected Member Functions

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

## Protected Attributes

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

## Static Protected Attributes

static std::auto_ptr< 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)
void | validate ()
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::multimap< int, FieldBase, message_order, ALLOCATOR< std::pair< const int, FieldBase > > > | Fields
typedef std::map< int, std::vector< FieldMap *>, std::less< int >, ALLOCATOR< std::pair< const int, std::vector< FieldMap *> > > > | Groups
typedef Fields::const_iterator | iterator
typedef iterator | const_iterator
typedef Groups::const_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 67 of file Message.h.

## Member Enumeration Documentation

## field_type

enum FIX::Message::field_type

private

Enumerator
header |
body |
trailer |

Definition at line 72 of file Message.h.

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

## Constructor & Destructor Documentation

## Message() [1/6]

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

Definition at line 35 of file Message.cpp.

: m_validStructure( true ) {}
FIX::Message::m_validStructure
bool m_validStructure
Definition: Message.h:340

## Message() [2/6]

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

Construct a message from a string.

Definition at line 38 of file Message.cpp.

References setString(), and validate().

: m_validStructure( true )
{
setString( string, validate );
}
FIX::Message::validate
void validate()
Definition: Message.cpp:489
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:162
FIX::Message::m_validStructure
bool m_validStructure
Definition: Message.h:340

## Message() [3/6]

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 45 of file Message.cpp.

References setString(), and validate().

: m_validStructure( true )
{
setString( string, validate, &dataDictionary, &dataDictionary );
}
FIX::Message::validate
void validate()
Definition: Message.cpp:489
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:162
FIX::Message::m_validStructure
bool m_validStructure
Definition: Message.h:340

## Message() [4/6]

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 54 of file Message.cpp.

References isAdmin(), setString(), setStringHeader(), and validate().

: 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:380
FIX::Message::validate
void validate()
Definition: Message.cpp:489
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:162
FIX::Message::m_validStructure
bool m_validStructure
Definition: Message.h:340
FIX::Message::isAdmin
bool isAdmin() const
Definition: Message.h:219

## Message() [5/6]

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

inline

Definition at line 91 of file Message.h.

References m_field, m_header, m_trailer, and m_validStructure.

: FieldMap( copy )
{
m_header = copy.m_header;
m_trailer = copy.m_trailer;
m_validStructure = copy.m_validStructure;
m_field = copy.m_field;
}
FIX::Message::m_field
int m_field
Definition: Message.h:341
FIX::FieldMap::FieldMap
FieldMap(const message_order &order=message_order(message_order::normal))
Definition: FieldMap.h:64
FIX::Message::m_header
Header m_header
Definition: Message.h:338
FIX::Message::m_validStructure
bool m_validStructure
Definition: Message.h:340
FIX::Message::m_trailer
Trailer m_trailer
Definition: Message.h:339

## Message() [6/6]

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

inline protected

Definition at line 127 of file Message.h.

References FIX::FIELD::BeginString, FIX::FIELD::BodyLength, and FIX::FIELD::CheckSum.

: m_validStructure( true )
{
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:79
FIX::Message::m_header
Header m_header
Definition: Message.h:338
FIX::Message::m_validStructure
bool m_validStructure
Definition: Message.h:340

## Member Function Documentation

## addGroup()

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

inline

Definition at line 103 of file Message.h.

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

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

## bodyLength()

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

inline

Definition at line 205 of file Message.h.

References FIX::FieldMap::calculateLength().

Referenced by toString(), and validate().

{ 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:194
FIX::Message::m_header
Header m_header
Definition: Message.h:338
FIX::Message::m_trailer
Trailer m_trailer
Definition: Message.h:339

## checkSum()

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

inline

Definition at line 213 of file Message.h.

References FIX::FieldMap::calculateTotal().

Referenced by toString(), and validate().

{ 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:218
FIX::Message::m_header
Header m_header
Definition: Message.h:338
FIX::Message::m_trailer
Trailer m_trailer
Definition: Message.h:339

## clear()

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

inline

Definition at line 242 of file Message.h.

References FIX::FieldMap::clear().

Referenced by setString(), and setStringHeader().

{
m_field = 0;
m_header.clear();
FieldMap::clear();
m_trailer.clear();
}
FIX::Message::m_field
int m_field
Definition: Message.h:341
FIX::Message::m_header
Header m_header
Definition: Message.h:338
FIX::Message::m_trailer
Trailer m_trailer
Definition: Message.h:339
FIX::FieldMap::clear
void clear()
Clear all fields from the map.
Definition: FieldMap.cpp:143

## 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`
| ) |  |

private

Definition at line 531 of file Message.cpp.

References FIX::FieldMap::begin(), FIX::IntConvertor::convert(), FIX::FieldMap::getField(), IsDataField(), FIX::FieldMap::isSetField(), FIX::FIELD::Signature, and FIX::FIELD::SignatureLength.

Referenced by setGroup(), setString(), and setStringHeader().

{
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;
IntConvertor::convert( tagStart, equalSign, field );
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;
if ( pGroup && pGroup->isSetField( lenField ) )
{
const std::string& fieldLength = pGroup->getField( lenField );
soh = valueStart + atol( fieldLength.c_str() );
}
else if ( isSetField( lenField ) )
{
const std::string& fieldLength = getField( lenField );
soh = valueStart + atol( fieldLength.c_str() );
}
}
std::string::const_iterator const tagEnd = soh + 1;
pos = std::distance( string.begin(), tagEnd );
return FieldBase (
field,
valueStart,
soh,
tagStart,
tagEnd );
}
FIX::FieldMap::isSetField
bool isSetField(const FieldBase &field) const
Check to see if a field is set.
Definition: FieldMap.h:144
FIX::FieldMap::begin
iterator begin() const
Definition: FieldMap.h:214
FIX::Message::IsDataField
static bool IsDataField(int field, const DataDictionary *pSessionDD, const DataDictionary *pAppDD)
Definition: Message.h:320
FIX::IntConvertor::convert
static std::string convert(signed_int value)
Definition: FieldConvertors.h:154
FIX::FieldMap::getField
FieldBase & getField(FieldBase &field) const
Get a field without type checking.
Definition: FieldMap.h:112
FIX::FIELD::SignatureLength
const int SignatureLength
Definition: FixFieldNumbers.h:1502
FIX::FIELD::Signature
const int Signature
Definition: FixFieldNumbers.h:1334

## getGroup()

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

inline

Definition at line 109 of file Message.h.

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

{ group.clear();
return static_cast < Group& >
( FieldMap::getGroup( num, group.field(), group ) );
}
FIX::Group::field
int field() const
Definition: Group.h:56
FIX::FieldMap::clear
void clear()
Clear all fields from the map.
Definition: FieldMap.cpp:143
FIX::FieldMap::getGroup
FieldMap & getGroup(int num, int field, FieldMap &group) const
Get a specific instance of a group.
Definition: FieldMap.h:163

## getHeader() [1/2]

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

inline

Getter for the message header.

Definition at line 192 of file Message.h.

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

{ return m_header; }
FIX::Message::m_header
Header m_header
Definition: Message.h:338

## getHeader() [2/2]

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

inline

Mutable getter for the message header.

Definition at line 194 of file Message.h.

{ return m_header; }
FIX::Message::m_header
Header m_header
Definition: Message.h:338

## getSessionID()

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

Returns the session ID of the intended recipient.

Definition at line 468 of file Message.cpp.

References FIX::FIELD::BeginString, FIX::FieldMap::getField(), getHeader(), FIX::FIELD::SenderCompID, and FIX::FIELD::TargetCompID.

{
BeginString beginString;
SenderCompID senderCompID;
TargetCompID targetCompID;
getHeader().getField( beginString );
getHeader().getField( senderCompID );
getHeader().getField( targetCompID );
return SessionID( beginString, senderCompID, targetCompID, qualifier );
}
FIX::Message::getHeader
const Header & getHeader() const
Getter for the message header.
Definition: Message.h:192
FIX::FieldMap::getField
FieldBase & getField(FieldBase &field) const
Get a field without type checking.
Definition: FieldMap.h:112
FIX::FIELD::TargetCompID
const int TargetCompID
Definition: FixFieldNumbers.h:217
FIX::FIELD::SenderCompID
const int SenderCompID
Definition: FixFieldNumbers.h:124
FIX::FIELD::BeginString
const int BeginString
Definition: FixFieldNumbers.h:499

## getTrailer() [1/2]

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

inline

Getter for the message trailer.

Definition at line 196 of file Message.h.

Referenced by setString(), and toXML().

{ return m_trailer; }
FIX::Message::m_trailer
Trailer m_trailer
Definition: Message.h:339

## getTrailer() [2/2]

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

inline

Mutable getter for the message trailer.

Definition at line 198 of file Message.h.

{ return m_trailer; }
FIX::Message::m_trailer
Trailer m_trailer
Definition: Message.h:339

## hasGroup() [1/2]

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

inline

Definition at line 120 of file Message.h.

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

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

## hasGroup() [2/2]

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

inline

Definition at line 122 of file Message.h.

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

{ return FieldMap::hasGroup( num, group.field() ); }
FIX::FieldMap::hasGroup
bool hasGroup(int field) const
Check to see any instance of a group exists.
Definition: FieldMap.cpp:129
FIX::Group::field
int field() const
Definition: Group.h:56

## hasValidStructure()

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

inline

Definition at line 200 of file Message.h.

{ field = m_field;
return m_validStructure;
}
FIX::Message::m_field
int m_field
Definition: Message.h:341
FIX::Message::m_validStructure
bool m_validStructure
Definition: Message.h:340

## InitializeXML()

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

static

Set global data dictionary for encoding messages into XML.

Definition at line 68 of file Message.cpp.

References DataDictionary, and s_dataDictionary.

{
try
{
std::auto_ptr<DataDictionary> p =
std::auto_ptr<DataDictionary>(new DataDictionary(url));
s_dataDictionary = p;
return true;
}
catch( ConfigError& )
{ return false; }
}
FIX::Message::s_dataDictionary
static std::auto_ptr< DataDictionary > s_dataDictionary
Definition: Message.h:342
FIX::Message::DataDictionary
friend class DataDictionary
Definition: Message.h:69

## isAdmin()

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

inline

Definition at line 219 of file Message.h.

References FIELD_GET_REF, and FIX::FIELD::MsgType.

Referenced by FIX::MessageCracker::crack(), and Message().

{
if( m_header.isSetField(FIELD::MsgType) )
{
const MsgType& msgType = FIELD_GET_REF( m_header, MsgType );
return isAdminMsgType( msgType );
}
return false;
}
FIX::FieldMap::isSetField
bool isSetField(const FieldBase &field) const
Check to see if a field is set.
Definition: FieldMap.h:144
FIX::Message::isAdminMsgType
static bool isAdminMsgType(const MsgType &msgType)
Definition: Message.h:250
FIX::Message::m_header
Header m_header
Definition: Message.h:338
FIELD_GET_REF
#define FIELD_GET_REF(MAP, FLD)
Definition: FieldMap.h:238
FIX::FIELD::MsgType
const int MsgType
Definition: FixFieldNumbers.h:363

## isAdminMsgType()

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

inline static

Definition at line 250 of file Message.h.

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

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

## isApp()

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

inline

Definition at line 229 of file Message.h.

References FIELD_GET_REF, and FIX::FIELD::MsgType.

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

{
if( m_header.isSetField(FIELD::MsgType) )
{
const MsgType& msgType = FIELD_GET_REF( m_header, MsgType );
return !isAdminMsgType( msgType );
}
return false;
}
FIX::FieldMap::isSetField
bool isSetField(const FieldBase &field) const
Check to see if a field is set.
Definition: FieldMap.h:144
FIX::Message::isAdminMsgType
static bool isAdminMsgType(const MsgType &msgType)
Definition: Message.h:250
FIX::Message::m_header
Header m_header
Definition: Message.h:338
FIELD_GET_REF
#define FIELD_GET_REF(MAP, FLD)
Definition: FieldMap.h:238
FIX::FIELD::MsgType
const int MsgType
Definition: FixFieldNumbers.h:363

## IsDataField()

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

inline static private

Definition at line 320 of file Message.h.

References FIX::DataDictionary::isDataField().

Referenced by extractField().

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

## isEmpty()

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

inline

Definition at line 239 of file Message.h.

References FIX::FieldMap::isEmpty().

{ return m_header.isEmpty() && FieldMap::isEmpty() && m_trailer.isEmpty(); }
FIX::FieldMap::isEmpty
bool isEmpty()
Check if map contains any fields.
Definition: FieldMap.cpp:157
FIX::Message::m_header
Header m_header
Definition: Message.h:338
FIX::Message::m_trailer
Trailer m_trailer
Definition: Message.h:339

## isHeaderField() [1/2]

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

static

Definition at line 400 of file Message.cpp.

References FIX::FIELD::ApplVerID, FIX::FIELD::BeginString, FIX::FIELD::BodyLength, FIX::FIELD::CstmApplVerID, FIX::FIELD::DeliverToCompID, FIX::FIELD::DeliverToLocationID, FIX::FIELD::DeliverToSubID, FIX::FIELD::LastMsgSeqNumProcessed, FIX::FIELD::MessageEncoding, FIX::FIELD::MsgSeqNum, FIX::FIELD::MsgType, FIX::FIELD::NoHops, FIX::FIELD::OnBehalfOfCompID, FIX::FIELD::OnBehalfOfLocationID, FIX::FIELD::OnBehalfOfSendingTime, FIX::FIELD::OnBehalfOfSubID, FIX::FIELD::OrigSendingTime, FIX::FIELD::PossDupFlag, FIX::FIELD::PossResend, FIX::FIELD::SecureDataLen, FIX::FIELD::SenderCompID, FIX::FIELD::SenderLocationID, FIX::FIELD::SenderSubID, FIX::FIELD::SendingTime, FIX::FIELD::TargetCompID, FIX::FIELD::TargetLocationID, FIX::FIELD::TargetSubID, FIX::FIELD::XmlData, and FIX::FIELD::XmlDataLen.

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

{
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::FIELD::ApplVerID
const int ApplVerID
Definition: FixFieldNumbers.h:425
FIX::FIELD::SecureDataLen
const int SecureDataLen
Definition: FixFieldNumbers.h:1464
FIX::FIELD::OrigSendingTime
const int OrigSendingTime
Definition: FixFieldNumbers.h:921
FIX::FIELD::DeliverToLocationID
const int DeliverToLocationID
Definition: FixFieldNumbers.h:910
FIX::FIELD::CstmApplVerID
const int CstmApplVerID
Definition: FixFieldNumbers.h:1224
FIX::FIELD::OnBehalfOfCompID
const int OnBehalfOfCompID
Definition: FixFieldNumbers.h:1191
FIX::FIELD::NoHops
const int NoHops
Definition: FixFieldNumbers.h:164
FIX::FIELD::OnBehalfOfLocationID
const int OnBehalfOfLocationID
Definition: FixFieldNumbers.h:335
FIX::FIELD::OnBehalfOfSubID
const int OnBehalfOfSubID
Definition: FixFieldNumbers.h:336
FIX::FIELD::PossResend
const int PossResend
Definition: FixFieldNumbers.h:242
FIX::FIELD::LastMsgSeqNumProcessed
const int LastMsgSeqNumProcessed
Definition: FixFieldNumbers.h:949
FIX::FIELD::TargetLocationID
const int TargetLocationID
Definition: FixFieldNumbers.h:65
FIX::FIELD::SendingTime
const int SendingTime
Definition: FixFieldNumbers.h:1447
FIX::FIELD::XmlData
const int XmlData
Definition: FixFieldNumbers.h:1026
FIX::FIELD::DeliverToSubID
const int DeliverToSubID
Definition: FixFieldNumbers.h:500
FIX::FIELD::SenderSubID
const int SenderSubID
Definition: FixFieldNumbers.h:1044
FIX::FIELD::TargetCompID
const int TargetCompID
Definition: FixFieldNumbers.h:217
FIX::FIELD::SenderLocationID
const int SenderLocationID
Definition: FixFieldNumbers.h:149
FIX::FIELD::MessageEncoding
const int MessageEncoding
Definition: FixFieldNumbers.h:792
FIX::FIELD::SenderCompID
const int SenderCompID
Definition: FixFieldNumbers.h:124
FIX::FIELD::XmlDataLen
const int XmlDataLen
Definition: FixFieldNumbers.h:1289
FIX::FIELD::DeliverToCompID
const int DeliverToCompID
Definition: FixFieldNumbers.h:64
FIX::FIELD::PossDupFlag
const int PossDupFlag
Definition: FixFieldNumbers.h:1284
FIX::FIELD::TargetSubID
const int TargetSubID
Definition: FixFieldNumbers.h:1427
FIX::FIELD::OnBehalfOfSendingTime
const int OnBehalfOfSendingTime
Definition: FixFieldNumbers.h:1415
FIX::FIELD::BeginString
const int BeginString
Definition: FixFieldNumbers.h:499
FIX::FIELD::MsgSeqNum
const int MsgSeqNum
Definition: FixFieldNumbers.h:1333
FIX::FIELD::BodyLength
const int BodyLength
Definition: FixFieldNumbers.h:1478
FIX::FIELD::MsgType
const int MsgType
Definition: FixFieldNumbers.h:363

## isHeaderField() [2/2]

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

static

Definition at line 439 of file Message.cpp.

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

{
if ( isHeaderField( field.getField() ) ) return true;
if ( pD ) return pD->isHeaderField( field.getField() );
return false;
}
FIX::Message::isHeaderField
static bool isHeaderField(int field)
Definition: Message.cpp:400

## isTrailerField() [1/2]

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

static

Definition at line 447 of file Message.cpp.

References FIX::FIELD::CheckSum, FIX::FIELD::Signature, and FIX::FIELD::SignatureLength.

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

{
switch ( field )
{
case FIELD::SignatureLength:
case FIELD::Signature:
case FIELD::CheckSum:
return true;
default:
return false;
};
}
FIX::FIELD::SignatureLength
const int SignatureLength
Definition: FixFieldNumbers.h:1502
FIX::FIELD::Signature
const int Signature
Definition: FixFieldNumbers.h:1334
FIX::FIELD::CheckSum
const int CheckSum
Definition: FixFieldNumbers.h:1426

## isTrailerField() [2/2]

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

static

Definition at line 460 of file Message.cpp.

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

{
if ( isTrailerField( field.getField() ) ) return true;
if ( pD ) return pD->isTrailerField( field.getField() );
return false;
}
FIX::Message::isTrailerField
static bool isTrailerField(int field)
Definition: Message.cpp:447

## removeGroup() [1/2]

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

inline

Definition at line 115 of file Message.h.

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

{ FieldMap::removeGroup( num, group.field() ); }
FIX::FieldMap::removeGroup
void removeGroup(int num, int field)
Remove a specific instance of a group.
Definition: FieldMap.cpp:86
FIX::Group::field
int field() const
Definition: Group.h:56

## removeGroup() [2/2]

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

inline

Definition at line 117 of file Message.h.

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

{ FieldMap::removeGroup( group.field() ); }
FIX::FieldMap::removeGroup
void removeGroup(int num, int field)
Remove a specific instance of a group.
Definition: FieldMap.cpp:86
FIX::Group::field
int field() const
Definition: Group.h:56

## replaceGroup()

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

inline

Definition at line 106 of file Message.h.

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

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

## 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 81 of file Message.cpp.

References FIX::FIELD::BeginString, FIX::BeginString_FIX41, FIX::FIELD::DeliverToCompID, FIX::FIELD::DeliverToLocationID, FIX::FIELD::DeliverToSubID, FIX::FieldMap::getFieldIfSet(), m_header, FIX::FIELD::OnBehalfOfCompID, FIX::FIELD::OnBehalfOfLocationID, FIX::FIELD::OnBehalfOfSubID, FIX::FieldMap::removeField(), FIX::FIELD::SenderCompID, FIX::FieldMap::setField(), and FIX::FIELD::TargetCompID.

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

{
// required routing tags
BeginString beginString;
SenderCompID senderCompID;
TargetCompID targetCompID;
m_header.removeField( beginString.getField() );
m_header.removeField( senderCompID.getField() );
m_header.removeField( targetCompID.getField() );
if( header.getFieldIfSet( beginString ) )
{
if( beginString.getValue().size() )
m_header.setField( beginString );
OnBehalfOfLocationID onBehalfOfLocationID;
DeliverToLocationID deliverToLocationID;
m_header.removeField( onBehalfOfLocationID.getField() );
m_header.removeField( deliverToLocationID.getField() );
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.getField() );
m_header.removeField( onBehalfOfSubID.getField() );
m_header.removeField( deliverToCompID.getField() );
m_header.removeField( deliverToSubID.getField() );
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::FIELD::DeliverToLocationID
const int DeliverToLocationID
Definition: FixFieldNumbers.h:910
FIX::FIELD::OnBehalfOfCompID
const int OnBehalfOfCompID
Definition: FixFieldNumbers.h:1191
FIX::Message::header
Definition: Message.h:72
FIX::FIELD::OnBehalfOfLocationID
const int OnBehalfOfLocationID
Definition: FixFieldNumbers.h:335
FIX::FIELD::OnBehalfOfSubID
const int OnBehalfOfSubID
Definition: FixFieldNumbers.h:336
FIX::FIELD::DeliverToSubID
const int DeliverToSubID
Definition: FixFieldNumbers.h:500
FIX::FIELD::TargetCompID
const int TargetCompID
Definition: FixFieldNumbers.h:217
FIX::FieldMap::setField
void setField(const FieldBase &field, bool overwrite=true)
Set a field without type checking.
Definition: FieldMap.h:79
FIX::FieldMap::removeField
void removeField(int field)
Remove a field. If field is not present, this is a no-op.
Definition: FieldMap.cpp:117
FIX::BeginString_FIX41
const char BeginString_FIX41[]
Definition: Values.h:35
FIX::FIELD::SenderCompID
const int SenderCompID
Definition: FixFieldNumbers.h:124
FIX::FIELD::DeliverToCompID
const int DeliverToCompID
Definition: FixFieldNumbers.h:64
FIX::Message::m_header
Header m_header
Definition: Message.h:338
FIX::FIELD::BeginString
const int BeginString
Definition: FixFieldNumbers.h:499

## 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 336 of file Message.cpp.

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

Referenced by setString().

{
int group = field.getField();
int delim;
const DataDictionary* pDD = 0;
if ( !dataDictionary.getGroup( msg, group, delim, pDD ) ) return ;
std::auto_ptr<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.getField() == delim) ||
// no delimiter, but field belongs to group OR field already processed
(pDD->isField( field.getField() ) && (pGroup.get() == 0 || pGroup->isSetField( field.getField() )) ))
{
if ( pGroup.get() )
{
map.addGroupPtr( group, pGroup.release(), false );
}
pGroup.reset( new Group( field.getField(), delim, pDD->getOrderedFields() ) );
}
else if ( !pDD->isField( field.getField() ) )
{
if ( pGroup.get() )
{
map.addGroupPtr( group, pGroup.release(), false );
}
pos = oldPos;
return ;
}
if ( !pGroup.get() ) return ;
pGroup->setField( field, false );
setGroup( msg, field, string, pos, *pGroup, *pDD );
}
}
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:336
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)
Definition: Message.cpp:531
FIX::FieldBase::setField
void setField(int field)
Definition: Field.h:93
FIX::Message::DataDictionary
friend class DataDictionary
Definition: Message.h:69

## setSessionID()

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

Sets the session ID of the intended recipient.

Definition at line 482 of file Message.cpp.

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

{
getHeader().setField( sessionID.getBeginString() );
getHeader().setField( sessionID.getSenderCompID() );
getHeader().setField( sessionID.getTargetCompID() );
}
FIX::Message::getHeader
const Header & getHeader() const
Getter for the message header.
Definition: Message.h:192
FIX::FieldMap::setField
void setField(const FieldBase &field, bool overwrite=true)
Set a field without type checking.
Definition: FieldMap.h:79

## 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 162 of file Message.h.

Referenced by Message().

{ setString(string, true); }
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:162

## setString() [2/4]

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

inline

Definition at line 165 of file Message.h.

{ setString(string, validate, 0); }
FIX::Message::validate
void validate()
Definition: Message.cpp:489
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:162

## setString() [3/4]

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

inline

Definition at line 168 of file Message.h.

{ setString(string, validate, pDataDictionary, pDataDictionary); }
FIX::Message::validate
void validate()
Definition: Message.cpp:489
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:162

## 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 265 of file Message.cpp.

References FIX::FIELD::BeginString, body, FIX::FIELD::BodyLength, clear(), extractField(), FIX::FieldBase::getField(), getHeader(), FIX::FieldBase::getString(), getTrailer(), header, FIX::headerOrder, isHeaderField(), isTrailerField(), m_field, m_header, m_trailer, m_validStructure, FIX::FIELD::MsgType, FIX::FieldMap::setField(), setGroup(), trailer, and validate().

{
clear();
std::string::size_type pos = 0;
int count = 0;
std::string msg;
static int const headerOrder[] =
{
FIELD::BeginString,
FIELD::BodyLength,
FIELD::MsgType
};
field_type type = header;
while ( pos < string.size() )
{
FieldBase field = extractField( string, pos, pSessionDataDictionary, pApplicationDataDictionary );
if ( count < 3 && headerOrder[ count++ ] != field.getField() )
if ( doValidation ) throw InvalidMessage("Header fields out of order");
if ( isHeaderField( field, pSessionDataDictionary ) )
{
if ( type != header )
{
if(m_field == 0) m_field = field.getField();
m_validStructure = false;
}
if ( field.getField() == FIELD::MsgType )
msg = field.getString();
m_header.setField( field, false );
if ( pSessionDataDictionary )
setGroup( "_header_", field, string, pos, getHeader(), *pSessionDataDictionary );
}
else if ( isTrailerField( field, pSessionDataDictionary ) )
{
type = trailer;
m_trailer.setField( field, false );
if ( pSessionDataDictionary )
setGroup( "_trailer_", field, string, pos, getTrailer(), *pSessionDataDictionary );
}
else
{
if ( type == trailer )
{
if(m_field == 0) m_field = field.getField();
m_validStructure = false;
}
type = body;
setField( field, false );
if ( pApplicationDataDictionary )
setGroup( msg, field, string, pos, *this, *pApplicationDataDictionary );
}
}
if ( doValidation )
validate();
}
FIX::Message::header
Definition: Message.h:72
FIX::Message::validate
void validate()
Definition: Message.cpp:489
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:336
FIX::Message::getHeader
const Header & getHeader() const
Getter for the message header.
Definition: Message.h:192
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)
Definition: Message.cpp:531
FIX::Message::getTrailer
const Trailer & getTrailer() const
Getter for the message trailer.
Definition: Message.h:196
FIX::FieldMap::setField
void setField(const FieldBase &field, bool overwrite=true)
Set a field without type checking.
Definition: FieldMap.h:79
FIX::Message::field_type
field_type
Definition: Message.h:72
FIX::Message::m_field
int m_field
Definition: Message.h:341
FIX::Message::clear
void clear()
Definition: Message.h:242
FIX::Message::trailer
Definition: Message.h:72
FIX::Message::m_header
Header m_header
Definition: Message.h:338
FIX::FIELD::BeginString
const int BeginString
Definition: FixFieldNumbers.h:499
FIX::Message::body
Definition: Message.h:72
FIX::FIELD::BodyLength
const int BodyLength
Definition: FixFieldNumbers.h:1478
FIX::FIELD::MsgType
const int MsgType
Definition: FixFieldNumbers.h:363
FIX::Message::isHeaderField
static bool isHeaderField(int field)
Definition: Message.cpp:400
FIX::Message::isTrailerField
static bool isTrailerField(int field)
Definition: Message.cpp:447
FIX::Message::m_validStructure
bool m_validStructure
Definition: Message.h:340
FIX::headerOrder
static int const headerOrder[]
Definition: Message.h:40
FIX::Message::m_trailer
Trailer m_trailer
Definition: Message.h:339

## 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 380 of file Message.cpp.

References clear(), extractField(), FIX::FieldBase::getField(), FIX::headerOrder, isHeaderField(), m_header, and FIX::FieldMap::setField().

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

{
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.getField() )
return false;
if ( isHeaderField( field ) )
m_header.setField( field, false );
else break;
}
return true;
}
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)
Definition: Message.cpp:531
FIX::FieldMap::setField
void setField(const FieldBase &field, bool overwrite=true)
Set a field without type checking.
Definition: FieldMap.h:79
FIX::Message::clear
void clear()
Definition: Message.h:242
FIX::Message::m_header
Header m_header
Definition: Message.h:338
FIX::Message::isHeaderField
static bool isHeaderField(int field)
Definition: Message.cpp:400
FIX::headerOrder
static int const headerOrder[]
Definition: Message.h:40

## toApplVerID()

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

inline static

Definition at line 257 of file Message.h.

References FIX::FIELD::ApplVerID, FIX::ApplVerID_FIX40, FIX::ApplVerID_FIX41, FIX::ApplVerID_FIX42, FIX::ApplVerID_FIX43, FIX::ApplVerID_FIX44, FIX::ApplVerID_FIX50, FIX::ApplVerID_FIX50SP1, FIX::ApplVerID_FIX50SP2, 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().

{
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::FIELD::ApplVerID
const int ApplVerID
Definition: FixFieldNumbers.h:425
FIX::BeginString_FIX44
const char BeginString_FIX44[]
Definition: Values.h:32
FIX::ApplVerID_FIX44
const char ApplVerID_FIX44[]
Definition: FixValues.h:816
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::ApplVerID_FIX40
const char ApplVerID_FIX40[]
Definition: FixValues.h:811
FIX::ApplVerID_FIX43
const char ApplVerID_FIX43[]
Definition: FixValues.h:815
FIX::ApplVerID_FIX50SP1
const char ApplVerID_FIX50SP1[]
Definition: FixValues.h:807
FIX::BeginString_FIX41
const char BeginString_FIX41[]
Definition: Values.h:35
FIX::BeginString_FIX40
const char BeginString_FIX40[]
Definition: Values.h:36
FIX::ApplVerID_FIX50SP2
const char ApplVerID_FIX50SP2[]
Definition: FixValues.h:809
FIX::ApplVerID_FIX42
const char ApplVerID_FIX42[]
Definition: FixValues.h:814
FIX::ApplVerID_FIX50
const char ApplVerID_FIX50[]
Definition: FixValues.h:810
FIX::ApplVerID_FIX41
const char ApplVerID_FIX41[]
Definition: FixValues.h:812

## toBeginString()

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

inline static

Definition at line 278 of file Message.h.

References FIX::ApplVerID_FIX40, FIX::ApplVerID_FIX41, FIX::ApplVerID_FIX42, FIX::ApplVerID_FIX43, FIX::ApplVerID_FIX44, FIX::ApplVerID_FIX50, FIX::ApplVerID_FIX50SP1, FIX::ApplVerID_FIX50SP2, FIX::FIELD::BeginString, FIX::BeginString_FIX40, FIX::BeginString_FIX41, FIX::BeginString_FIX42, FIX::BeginString_FIX43, FIX::BeginString_FIX44, and FIX::BeginString_FIX50.

{
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("");
}
FIX::BeginString_FIX44
const char BeginString_FIX44[]
Definition: Values.h:32
FIX::ApplVerID_FIX44
const char ApplVerID_FIX44[]
Definition: FixValues.h:816
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::ApplVerID_FIX40
const char ApplVerID_FIX40[]
Definition: FixValues.h:811
FIX::ApplVerID_FIX43
const char ApplVerID_FIX43[]
Definition: FixValues.h:815
FIX::ApplVerID_FIX50SP1
const char ApplVerID_FIX50SP1[]
Definition: FixValues.h:807
FIX::BeginString_FIX41
const char BeginString_FIX41[]
Definition: Values.h:35
FIX::FIELD::BeginString
const int BeginString
Definition: FixFieldNumbers.h:499
FIX::BeginString_FIX40
const char BeginString_FIX40[]
Definition: Values.h:36
FIX::ApplVerID_FIX50SP2
const char ApplVerID_FIX50SP2[]
Definition: FixValues.h:809
FIX::ApplVerID_FIX42
const char ApplVerID_FIX42[]
Definition: FixValues.h:814
FIX::ApplVerID_FIX50
const char ApplVerID_FIX50[]
Definition: FixValues.h:810
FIX::ApplVerID_FIX41
const char ApplVerID_FIX41[]
Definition: FixValues.h:812

## 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 167 of file Message.cpp.

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

{
std::string str;
return toString( str, beginStringField, bodyLengthField, checkSumField );
}
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:167

## 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 175 of file Message.cpp.

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

{
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::Message::checkSum
int checkSum(int checkSumField=FIELD::CheckSum) const
Definition: Message.h:213
FIX::Message::bodyLength
int bodyLength(int beginStringField=FIELD::BeginString, int bodyLengthField=FIELD::BodyLength, int checkSumField=FIELD::CheckSum) const
Definition: Message.h:205
FIX::FieldMap::setField
void setField(const FieldBase &field, bool overwrite=true)
Set a field without type checking.
Definition: FieldMap.h:79
FIX::FieldMap::calculateString
std::string & calculateString(std::string &) const
Definition: FieldMap.cpp:176
FIX::Message::m_header
Header m_header
Definition: Message.h:338
FIX::Message::m_trailer
Trailer m_trailer
Definition: Message.h:339

## toXML() [1/2]

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

Get a XML representation of the message.

Definition at line 200 of file Message.cpp.

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

## toXML() [2/2]

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

Get a XML representation without making a copy.

Definition at line 206 of file Message.cpp.

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

{
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:224
FIX::Message::getHeader
const Header & getHeader() const
Getter for the message header.
Definition: Message.h:192
FIX::Message::getTrailer
const Trailer & getTrailer() const
Getter for the message trailer.
Definition: Message.h:196

## toXMLFields()

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

private

Definition at line 224 of file Message.cpp.

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

Referenced by toXML().

{
std::stringstream stream;
FieldMap::iterator i;
std::string name;
for(i = fields.begin(); i != fields.end(); ++i)
{
int field = i->first;
std::string value = i->second.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_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::iterator
Fields::const_iterator iterator
Definition: FieldMap.h:59
FIX::FieldMap::g_iterator
Groups::const_iterator g_iterator
Definition: FieldMap.h:61
FIX::Message::toXMLFields
std::string toXMLFields(const FieldMap &fields, int space) const
Definition: Message.cpp:224
FIX::Message::s_dataDictionary
static std::auto_ptr< DataDictionary > s_dataDictionary
Definition: Message.h:342

## validate()

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

private

Definition at line 489 of file Message.cpp.

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

Referenced by Message(), and setString().

{
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 );
}
}
FIX::Message::checkSum
int checkSum(int checkSumField=FIELD::CheckSum) const
Definition: Message.h:213
FIX::Message::bodyLength
int bodyLength(int beginStringField=FIELD::BeginString, int bodyLengthField=FIELD::BodyLength, int checkSumField=FIELD::CheckSum) const
Definition: Message.h:205
FIX::Message::m_header
Header m_header
Definition: Message.h:338
FIX::FIELD::BodyLength
const int BodyLength
Definition: FixFieldNumbers.h:1478
FIELD_GET_REF
#define FIELD_GET_REF(MAP, FLD)
Definition: FieldMap.h:238
FIX::FIELD::CheckSum
const int CheckSum
Definition: FixFieldNumbers.h:1426
FIX::Message::m_trailer
Trailer m_trailer
Definition: Message.h:339

## Friends And Related Function Documentation

## DataDictionary

friend class DataDictionary

friend

Definition at line 69 of file Message.h.

Referenced by InitializeXML().

## Session

friend class Session

friend

Definition at line 70 of file Message.h.

## Member Data Documentation

## m_field

int FIX::Message::m_field

protected

Definition at line 341 of file Message.h.

Referenced by Message(), and setString().

## m_header

Header FIX::Message::m_header

mutable protected

Definition at line 338 of file Message.h.

Referenced by Message(), reverseRoute(), setString(), setStringHeader(), toString(), and validate().

## m_trailer

Trailer FIX::Message::m_trailer

mutable protected

Definition at line 339 of file Message.h.

Referenced by Message(), setString(), toString(), and validate().

## m_validStructure

bool FIX::Message::m_validStructure

protected

Definition at line 340 of file Message.h.

Referenced by Message(), and setString().

## s_dataDictionary

std::auto_ptr< DataDictionary > FIX::Message::s_dataDictionary

static protected

Definition at line 342 of file Message.h.

Referenced by InitializeXML(), and toXMLFields().

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

- Message.h
- Message.cpp