Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes | Private Types | Private Member Functions | Static Private Member Functions | Friends | List of all members
FIX::Message Class Reference

Base class for all FIX messages. More...

#include <Message.h>

Inheritance diagram for FIX::Message:
Inheritance graph
[legend]
Collaboration diagram for FIX::Message:
Collaboration graph
[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)
 
GroupgetGroup (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 HeadergetHeader () const
 Getter for the message header. More...
 
HeadergetHeader ()
 Mutable getter for the message header. More...
 
const TrailergetTrailer () const
 Getter for the message trailer. More...
 
TrailergetTrailer ()
 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 ()
 
FieldMapoperator= (const FieldMap &rhs)
 
void setField (const FieldBase &field, bool overwrite=true) throw ( RepeatedTag )
 Set a field without type checking. More...
 
void setField (int tag, const std::string &value) throw ( RepeatedTag, NoTagValue )
 Set a field without a field class. More...
 
bool getFieldIfSet (FieldBase &field) const
 Get a field if set. More...
 
FieldBasegetField (FieldBase &field) const throw ( FieldNotFound )
 Get a field without type checking. More...
 
const std::string & getField (int tag) const throw ( FieldNotFound )
 Get a field without a field class. More...
 
const FieldBasegetFieldRef (int tag) const throw ( FieldNotFound )
 Get direct access to a field through a reference. More...
 
const FieldBase *const getFieldPtr (int tag) const throw ( FieldNotFound )
 Get direct access to a field through a pointer. More...
 
bool isSetField (const FieldBase &field) const
 Check to see if a field is set. More...
 
bool isSetField (int tag) const
 Check to see if a field is set by referencing its number. More...
 
void removeField (int tag)
 Remove a field. If field is not present, this is a no-op. More...
 
void addGroup (int tag, const FieldMap &group, bool setCount=true)
 Add a group. More...
 
void addGroupPtr (int tag, FieldMap *group, bool setCount=true)
 Acquire ownership of Group object. More...
 
void replaceGroup (int num, int tag, const FieldMap &group)
 Replace a specific instance of a group. More...
 
FieldMapgetGroup (int num, int tag, FieldMap &group) const throw ( FieldNotFound )
 Get a specific instance of a group. More...
 
FieldMapgetGroupRef (int num, int tag) const throw ( FieldNotFound )
 Get direct access to a field through a reference. More...
 
FieldMapgetGroupPtr (int num, int tag) const throw ( FieldNotFound )
 Get direct access to a field through a pointer. More...
 
void removeGroup (int num, int tag)
 Remove a specific instance of a group. More...
 
void removeGroup (int tag)
 Remove all instances of a group. More...
 
bool hasGroup (int tag) const
 Check to see any instance of a group exists. More...
 
bool hasGroup (int num, int tag) const
 Check to see if a specific instance of a group exists. More...
 
size_t groupCount (int tag) const
 Count the number of instance of a group. More...
 
void clear ()
 Clear all fields from the map. More...
 
bool isEmpty ()
 Check if map contains any fields. More...
 
size_t totalFields () const
 
std::string & calculateString (std::string &) const
 
int calculateLength (int beginStringField=FIELD::BeginString, int bodyLengthField=FIELD::BodyLength, int checkSumField=FIELD::CheckSum) const
 
int calculateTotal (int checkSumField=FIELD::CheckSum) const
 
iterator begin ()
 
iterator end ()
 
const_iterator begin () const
 
const_iterator end () const
 
g_iterator g_begin ()
 
g_iterator g_end ()
 
g_const_iterator g_begin () const
 
g_const_iterator g_end () const
 

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 FieldBasereverse_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< DataDictionarys_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

Enumerator
header 
body 
trailer 

Definition at line 122 of file Message.h.

122 { header, body, trailer };

Constructor & Destructor Documentation

◆ Message() [1/9]

FIX::Message::Message ( )

Definition at line 43 of file Message.cpp.

44 : m_validStructure( true )
45 , m_tag( 0 )
46 {
47 
48 }
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.

51 : FieldMap(order), m_header(hdrOrder),
52  m_trailer(trlOrder), m_validStructure( true ) {}
FieldMap(const message_order &order, int size)
Definition: FieldMap.cpp:34
Trailer m_trailer
Definition: Message.h:398
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.

56 : m_validStructure( true )
57 , m_tag( 0 )
58 {
59  setString( string, validate );
60 }
void validate() const
Definition: Message.cpp:597
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.

66 : m_validStructure( true )
67 , m_tag( 0 )
68 {
69  setString( string, validate, &dataDictionary, &dataDictionary );
70 }

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

77 : m_validStructure( true )
78 , m_tag( 0 )
79 {
80  setString( string, validate, &sessionDataDictionary, &applicationDataDictionary );
81 }

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

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

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

104 : FieldMap(order), m_header(hdrOrder),
105  m_trailer(trlOrder), m_validStructure( true )
106 {
107  setStringHeader( string );
108  if( isAdmin() )
109  setString( string, validate, &sessionDataDictionary, &sessionDataDictionary );
110  else
111  setString( string, validate, &sessionDataDictionary, &applicationDataDictionary );
112 }
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
bool isAdmin() const
Definition: Message.h:272

◆ Message() [8/9]

FIX::Message::Message ( const Message copy)

Definition at line 122 of file Message.cpp.

123 : FieldMap(copy)
124 , m_header(copy.m_header)
125 , m_trailer(copy.m_trailer)
126 , m_validStructure(copy.m_validStructure)
127 , m_tag(copy.m_tag)
128 #ifdef HAVE_EMX
129 , m_subMsgType(copy.m_subMsgType)
130 #endif
131 {
132 
133 }

◆ ~Message()

FIX::Message::~Message ( )

Definition at line 135 of file Message.cpp.

136 {
137 }

◆ Message() [9/9]

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

Definition at line 114 of file Message.cpp.

115 : m_validStructure(true)
116 , m_tag( 0 )
117 {
118  m_header.setField(beginString);
119  m_header.setField(msgType);
120 }
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.

162  { FieldMap::addGroup( group.field(), group ); }
void addGroup(int tag, const FieldMap &group, bool setCount=true)
Add a group.
Definition: FieldMap.cpp:83
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.

261  { return m_header.calculateLength(beginStringField, bodyLengthField, checkSumField)
262  + calculateLength(beginStringField, bodyLengthField, checkSumField)
263  + m_trailer.calculateLength(beginStringField, bodyLengthField, checkSumField);
264  }
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.

267  { return ( m_header.calculateTotal(checkSumField)
268  + calculateTotal(checkSumField)
269  + m_trailer.calculateTotal(checkSumField) ) % 256;
270  }
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.

292  {
293  m_tag = 0;
294  m_validStructure = true;
295  m_header.clear();
296  FieldMap::clear();
297  m_trailer.clear();
298  }
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.

642 {
643  std::string::const_iterator const tagStart = string.begin() + pos;
644  std::string::const_iterator const strEnd = string.end();
645 
646  std::string::const_iterator const equalSign = std::find( tagStart, strEnd, '=' );
647  if( equalSign == strEnd )
648  throw InvalidMessage("Equal sign not found in field");
649 
650  int field = 0;
651  if( !IntConvertor::convert( tagStart, equalSign, field ) )
652  throw InvalidMessage( std::string("Field tag is invalid: ") + std::string( tagStart, equalSign ));
653 
654  std::string::const_iterator const valueStart = equalSign + 1;
655 
656  std::string::const_iterator soh = std::find( valueStart, strEnd, '\001' );
657  if ( soh == strEnd )
658  throw InvalidMessage("SOH not found at end of field");
659 
660  if ( IsDataField( field, pSessionDD, pAppDD ) )
661  {
662  // Assume length field is 1 less.
663  int lenField = field - 1;
664  // Special case for Signature which violates above assumption.
665  if ( field == FIELD::Signature ) lenField = FIELD::SignatureLength;
666 
667  // identify part of the message that should contain length field
668  const FieldMap * location = pGroup;
669  if ( !location )
670  {
671  if ( isHeaderField( lenField, pSessionDD ) )
672  location = &m_header;
673  else if ( isTrailerField( lenField, pSessionDD ) )
674  location = &m_trailer;
675  else
676  location = this;
677  }
678 
679  try
680  {
681  const FieldBase& fieldLength = location->reverse_find( lenField );
682  soh = valueStart + IntConvertor::convert( fieldLength.getString() );
683  }
684  catch( FieldNotFound& )
685  {
686  throw InvalidMessage( std::string( "Data length field " ) + IntConvertor::convert( lenField ) + std::string( " was not found for data field " ) + IntConvertor::convert( field ) );
687  }
688  catch( FieldConvertError& e )
689  {
690  throw InvalidMessage( std::string( "Unable to determine SOH for data field " ) + IntConvertor::convert( field ) + std::string( ": " ) + e.what() );
691  }
692  }
693 
694  std::string::const_iterator const tagEnd = soh + 1;
695 #if defined(__SUNPRO_CC)
696  std::distance( string.begin(), tagEnd, pos );
697 #else
698  pos = std::distance( string.begin(), tagEnd );
699 #endif
700 
701  return FieldBase (
702  field,
703  valueStart,
704  soh,
705  tagStart,
706  tagEnd );
707 }
iterator begin()
Definition: FieldMap.h:258
const FieldBase & reverse_find(int tag) const
Definition: FieldMap.h:286
static bool isHeaderField(int field)
Definition: Message.cpp:497
static bool IsDataField(int field, const DataDictionary *pSessionDD, const DataDictionary *pAppDD)
Definition: Message.h:379
static bool isTrailerField(int field)
Definition: Message.cpp:550
static std::string convert(signed_int value)

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.

168  { group.clear();
169  return static_cast < Group& >
170  ( FieldMap::getGroup( num, group.field(), group ) );
171  }
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.

247 { return m_header; }

References m_header.

◆ getHeader() [2/2]

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

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

578 {
579  BeginString beginString;
580  SenderCompID senderCompID;
581  TargetCompID targetCompID;
582 
583  getHeader().getField( beginString );
584  getHeader().getField( senderCompID );
585  getHeader().getField( targetCompID );
586 
587  return SessionID( beginString, senderCompID, targetCompID, qualifier );
588 }
FieldBase & getField(FieldBase &field) const
Get a field without type checking.
Definition: FieldMap.h:156
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.

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

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

179  { return FieldMap::hasGroup( group.field() ); }
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.

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

254  { tag = m_tag;
255  return m_validStructure;
256  }

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.

140 {
141  try
142  {
143  s_dataDictionary.reset(new DataDictionary(url));
144  return true;
145  }
146  catch( ConfigError& )
147  { return false; }
148 }
friend class DataDictionary
Definition: Message.h:119
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.

273  {
274  MsgType msgType;
275  if( m_header.getFieldIfSet( msgType ) )
276  return isAdminMsgType( msgType );
277  return false;
278  }
bool getFieldIfSet(FieldBase &field) const
Get a field if set.
Definition: FieldMap.h:146
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)
inlinestatic

Definition at line 300 of file Message.h.

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

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.

281  {
282  MsgType msgType;
283  if( m_header.getFieldIfSet( msgType ) )
284  return !isAdminMsgType( msgType );
285  return false;
286  }

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 
)
inlinestaticprivate

Definition at line 379 of file Message.h.

383  {
384  if( (pSessionDD && pSessionDD->isDataField( field )) ||
385  (pAppDD && pAppDD != pSessionDD && pAppDD->isDataField( field )) )
386  {
387  return true;
388  }
389 
390  return false;
391  }

References FIX::DataDictionary::isDataField().

Referenced by extractField().

◆ isEmpty()

bool FIX::Message::isEmpty ( )
inline

Definition at line 288 of file Message.h.

289  { return m_header.isEmpty() && FieldMap::isEmpty() && m_trailer.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.

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

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

◆ isHeaderField() [2/3]

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

Definition at line 497 of file Message.cpp.

498 {
499  switch ( field )
500  {
501  case FIELD::BeginString:
502  case FIELD::BodyLength:
503  case FIELD::MsgType:
504  case FIELD::SenderCompID:
505  case FIELD::TargetCompID:
506  case FIELD::OnBehalfOfCompID:
507  case FIELD::DeliverToCompID:
508  case FIELD::SecureDataLen:
509  case FIELD::MsgSeqNum:
510  case FIELD::SenderSubID:
511  case FIELD::SenderLocationID:
512  case FIELD::TargetSubID:
513  case FIELD::TargetLocationID:
514  case FIELD::OnBehalfOfSubID:
515  case FIELD::OnBehalfOfLocationID:
516  case FIELD::DeliverToSubID:
517  case FIELD::DeliverToLocationID:
518  case FIELD::PossDupFlag:
519  case FIELD::PossResend:
520  case FIELD::SendingTime:
521  case FIELD::OrigSendingTime:
522  case FIELD::XmlDataLen:
523  case FIELD::XmlData:
524  case FIELD::MessageEncoding:
525  case FIELD::LastMsgSeqNumProcessed:
526  case FIELD::OnBehalfOfSendingTime:
527  case FIELD::ApplVerID:
528  case FIELD::CstmApplVerID:
529  case FIELD::NoHops:
530  return true;
531  default:
532  return false;
533  };
534 }

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.

544 {
545  if ( isHeaderField( field ) ) return true;
546  if ( pD ) return pD->isHeaderField( field );
547  return false;
548 }

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.

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

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

◆ isTrailerField() [2/3]

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

Definition at line 550 of file Message.cpp.

551 {
552  switch ( field )
553  {
554  case FIELD::SignatureLength:
555  case FIELD::Signature:
556  case FIELD::CheckSum:
557  return true;
558  default:
559  return false;
560  };
561 }

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.

570 {
571  if ( isTrailerField( field ) ) return true;
572  if ( pD ) return pD->isTrailerField( field );
573  return false;
574 }

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.

176  { FieldMap::removeGroup( group.field() ); }
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.

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

165  { FieldMap::replaceGroup( num, group.field(), group ); }
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.

151 {
152  // required routing tags
153  BeginString beginString;
154  SenderCompID senderCompID;
155  TargetCompID targetCompID;
156 
157  m_header.removeField( beginString.getTag() );
158  m_header.removeField( senderCompID.getTag() );
159  m_header.removeField( targetCompID.getTag() );
160 
161  if( header.getFieldIfSet( beginString ) )
162  {
163  if( beginString.getValue().size() )
164  m_header.setField( beginString );
165 
166  OnBehalfOfLocationID onBehalfOfLocationID;
167  DeliverToLocationID deliverToLocationID;
168 
169  m_header.removeField( onBehalfOfLocationID.getTag() );
170  m_header.removeField( deliverToLocationID.getTag() );
171 
172  if( beginString >= BeginString_FIX41 )
173  {
174  if( header.getFieldIfSet( onBehalfOfLocationID ) )
175  {
176  if( onBehalfOfLocationID.getValue().size() )
177  m_header.setField( DeliverToLocationID( onBehalfOfLocationID ) );
178  }
179 
180  if( header.getFieldIfSet( deliverToLocationID ) )
181  {
182  if( deliverToLocationID.getValue().size() )
183  m_header.setField( OnBehalfOfLocationID( deliverToLocationID ) );
184  }
185  }
186  }
187 
188  if( header.getFieldIfSet( senderCompID ) )
189  {
190  if( senderCompID.getValue().size() )
191  m_header.setField( TargetCompID( senderCompID ) );
192  }
193 
194  if( header.getFieldIfSet( targetCompID ) )
195  {
196  if( targetCompID.getValue().size() )
197  m_header.setField( SenderCompID( targetCompID ) );
198  }
199 
200  // optional routing tags
201  OnBehalfOfCompID onBehalfOfCompID;
202  OnBehalfOfSubID onBehalfOfSubID;
203  DeliverToCompID deliverToCompID;
204  DeliverToSubID deliverToSubID;
205 
206  m_header.removeField( onBehalfOfCompID.getTag() );
207  m_header.removeField( onBehalfOfSubID.getTag() );
208  m_header.removeField( deliverToCompID.getTag() );
209  m_header.removeField( deliverToSubID.getTag() );
210 
211  if( header.getFieldIfSet( onBehalfOfCompID ) )
212  {
213  if( onBehalfOfCompID.getValue().size() )
214  m_header.setField( DeliverToCompID( onBehalfOfCompID ) );
215  }
216 
217  if( header.getFieldIfSet( onBehalfOfSubID ) )
218  {
219  if( onBehalfOfSubID.getValue().size() )
220  m_header.setField( DeliverToSubID( onBehalfOfSubID ) );
221  }
222 
223  if( header.getFieldIfSet( deliverToCompID ) )
224  {
225  if( deliverToCompID.getValue().size() )
226  m_header.setField( OnBehalfOfCompID( deliverToCompID ) );
227  }
228 
229  if( header.getFieldIfSet( deliverToSubID ) )
230  {
231  if( deliverToSubID.getValue().size() )
232  m_header.setField( OnBehalfOfSubID( deliverToSubID ) );
233  }
234 }
void removeField(int tag)
Remove a field. If field is not present, this is a no-op.
Definition: FieldMap.cpp:156
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.

435 {
436  int group = field.getTag();
437  int delim;
438  const DataDictionary* pDD = 0;
439  if ( !dataDictionary.getGroup( msg, group, delim, pDD ) ) return ;
440  SmartPtr<Group> pGroup;
441 
442  while ( pos < string.size() )
443  {
444  std::string::size_type oldPos = pos;
445  FieldBase field = extractField( string, pos, &dataDictionary, &dataDictionary, pGroup.get() );
446 
447  // Start a new group because...
448  if (// found delimiter
449  (field.getTag() == delim) ||
450  // no delimiter, but field belongs to group OR field already processed
451  (pDD->isField( field.getTag() ) && (pGroup.get() == 0 || pGroup->isSetField( field.getTag() )) ))
452  {
453  if ( pGroup.get() )
454  {
455  map.addGroupPtr( group, pGroup.release(), false );
456  }
457  pGroup.reset( new Group( field.getTag(), delim, pDD->getOrderedFields() ) );
458  }
459  else if ( !pDD->isField( field.getTag() ) )
460  {
461  if ( pGroup.get() )
462  {
463  map.addGroupPtr( group, pGroup.release(), false );
464  }
465  pos = oldPos;
466  return ;
467  }
468 
469  if ( !pGroup.get() ) return ;
470  pGroup->addField( field );
471  setGroup( msg, field, string, pos, *pGroup, *pDD );
472  }
473 }
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
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.

591 {
592  getHeader().setField( sessionID.getBeginString() );
593  getHeader().setField( sessionID.getSenderCompID() );
594  getHeader().setField( sessionID.getTargetCompID() );
595 }

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.

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

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

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

341 {
342  clear();
343 
344  std::string::size_type pos = 0;
345  int count = 0;
346 
347  FIX::MsgType msg;
348 
349  field_type type = header;
350 
351  while ( pos < string.size() )
352  {
353  FieldBase field = extractField( string, pos, pSessionDataDictionary, pApplicationDataDictionary );
354  if ( count < 3 && headerOrder[ count++ ] != field.getTag() )
355  if ( doValidation ) throw InvalidMessage("Header fields out of order");
356 
357  if ( isHeaderField( field, pSessionDataDictionary ) )
358  {
359  if ( type != header )
360  {
361  if(m_tag == 0) m_tag = field.getTag();
362  m_validStructure = false;
363  }
364 
365  if ( field.getTag() == FIELD::MsgType )
366  {
367  msg.setString( field.getString() );
368  if ( isAdminMsgType( msg ) )
369  {
370  pApplicationDataDictionary = pSessionDataDictionary;
371 #ifdef HAVE_EMX
372  m_subMsgType.assign(msg);
373  }
374  else
375  {
376  std::string::size_type equalSign = string.find("\0019426=", pos);
377  if (equalSign == std::string::npos)
378  throw InvalidMessage("EMX message type (9426) not found");
379 
380  equalSign += 6;
381  std::string::size_type soh = string.find_first_of('\001', equalSign);
382  if (soh == std::string::npos)
383  throw InvalidMessage("EMX message type (9426) soh char not found");
384  m_subMsgType.assign(string.substr(equalSign, soh - equalSign ));
385 #endif
386  }
387  }
388 
389  m_header.appendField( field );
390 
391  if ( pSessionDataDictionary )
392  setGroup( "_header_", field, string, pos, getHeader(), *pSessionDataDictionary );
393  }
394  else if ( isTrailerField( field, pSessionDataDictionary ) )
395  {
396  type = trailer;
397  m_trailer.appendField( field );
398 
399  if ( pSessionDataDictionary )
400  setGroup( "_trailer_", field, string, pos, getTrailer(), *pSessionDataDictionary );
401  }
402  else
403  {
404  if ( type == trailer )
405  {
406  if(m_tag == 0) m_tag = field.getTag();
407  m_validStructure = false;
408  }
409 
410  type = body;
411  appendField( field );
412 
413  if ( pApplicationDataDictionary )
414 #ifdef HAVE_EMX
415  setGroup(m_subMsgType, field, string, pos, *this, *pApplicationDataDictionary);
416 #else
417  setGroup( msg, field, string, pos, *this, *pApplicationDataDictionary );
418 #endif
419  }
420  }
421 
422  // sort fields
424  sortFields();
426 
427  if ( doValidation )
428  validate();
429 }
void sortFields()
Definition: FieldMap.h:303
void appendField(const FieldBase &field)
Definition: FieldMap.h:297
void clear()
Definition: Message.h:291
const Trailer & getTrailer() const
Getter for the message trailer.
Definition: Message.h:249
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.

476 {
477  clear();
478 
479  std::string::size_type pos = 0;
480  int count = 0;
481 
482  while ( pos < string.size() )
483  {
484  FieldBase field = extractField( string, pos );
485  if ( count < 3 && headerOrder[ count++ ] != field.getTag() )
486  return false;
487 
488  if ( isHeaderField( field ) )
489  m_header.appendField( field );
490  else break;
491  }
492 
494  return true;
495 }

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)
inlinestatic

Definition at line 307 of file Message.h.

308  {
309  if( value == BeginString_FIX40 )
310  return ApplVerID(ApplVerID_FIX40);
311  if( value == BeginString_FIX41 )
312  return ApplVerID(ApplVerID_FIX41);
313  if( value == BeginString_FIX42 )
314  return ApplVerID(ApplVerID_FIX42);
315  if( value == BeginString_FIX43 )
316  return ApplVerID(ApplVerID_FIX43);
317  if( value == BeginString_FIX44 )
318  return ApplVerID(ApplVerID_FIX44);
319  if( value == BeginString_FIX50 )
320  return ApplVerID(ApplVerID_FIX50);
321  if( value == "FIX.5.0SP1" )
322  return ApplVerID(ApplVerID_FIX50SP1);
323  if( value == "FIX.5.0SP2" )
324  return ApplVerID(ApplVerID_FIX50SP2);
325  return ApplVerID(ApplVerID(value));
326  }
const char BeginString_FIX40[]
Definition: Values.h:36
const char BeginString_FIX42[]
Definition: Values.h:34
const char BeginString_FIX50[]
Definition: Values.h:31
const char BeginString_FIX43[]
Definition: Values.h:33
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)
inlinestatic

Definition at line 328 of file Message.h.

329  {
330  if( applVerID == ApplVerID_FIX40 )
331  return BeginString(BeginString_FIX40);
332  else if( applVerID == ApplVerID_FIX41 )
333  return BeginString(BeginString_FIX41);
334  else if( applVerID == ApplVerID_FIX42 )
335  return BeginString(BeginString_FIX42);
336  else if( applVerID == ApplVerID_FIX43 )
337  return BeginString(BeginString_FIX43);
338  else if( applVerID == ApplVerID_FIX44 )
339  return BeginString(BeginString_FIX44);
340  else if( applVerID == ApplVerID_FIX50 )
341  return BeginString(BeginString_FIX50);
342  else if( applVerID == ApplVerID_FIX50SP1 )
343  return BeginString(BeginString_FIX50);
344  else if( applVerID == ApplVerID_FIX50SP2 )
345  return BeginString(BeginString_FIX50);
346  else
347  return BeginString("");
348  }

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.

239 {
240  std::string str;
241  toString( str, beginStringField, bodyLengthField, checkSumField );
242  return str;
243 }
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.

249 {
250  int length = bodyLength( beginStringField, bodyLengthField, checkSumField );
251  m_header.setField( IntField(bodyLengthField, length) );
252  m_trailer.setField( CheckSumField(checkSumField, checkSum(checkSumField)) );
253 
254 #if defined(_MSC_VER) && _MSC_VER < 1300
255  str = "";
256 #else
257  str.clear();
258 #endif
259 
260  /*small speculation about the space needed for FIX string*/
261  str.reserve( length + 64 );
262 
263  m_header.calculateString( str );
265  m_trailer.calculateString( str );
266 
267  return str;
268 }
std::string & calculateString(std::string &) const
Definition: FieldMap.cpp:215
int bodyLength(int beginStringField=FIELD::BeginString, int bodyLengthField=FIELD::BodyLength, int checkSumField=FIELD::CheckSum) const
Definition: Message.h:258
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.

271 {
272  std::string str;
273  toXML( str );
274  return str;
275 }
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.

278 {
279  std::stringstream stream;
280  stream << "<message>" << std::endl
281  << std::setw(2) << " " << "<header>" << std::endl
282  << toXMLFields(getHeader(), 4)
283  << std::setw(2) << " " << "</header>" << std::endl
284  << std::setw(2) << " " << "<body>" << std::endl
285  << toXMLFields(*this, 4)
286  << std::setw(2) << " " << "</body>" << std::endl
287  << std::setw(2) << " " << "<trailer>" << std::endl
288  << toXMLFields(getTrailer(), 4)
289  << std::setw(2) << " " << "</trailer>" << std::endl
290  << "</message>";
291 
292  return str = stream.str();
293 }
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.

296 {
297  std::stringstream stream;
299  std::string name;
300  for(i = fields.begin(); i != fields.end(); ++i)
301  {
302  int field = i->getTag();
303  std::string value = i->getString();
304 
305  stream << std::setw(space) << " " << "<field ";
306  if(s_dataDictionary.get() && s_dataDictionary->getFieldName(field, name))
307  {
308  stream << "name=\"" << name << "\" ";
309  }
310  stream << "number=\"" << field << "\"";
311  if(s_dataDictionary.get()
312  && s_dataDictionary->getValueName(field, value, name))
313  {
314  stream << " enum=\"" << name << "\"";
315  }
316  stream << ">";
317  stream << "<![CDATA[" << value << "]]>";
318  stream << "</field>" << std::endl;
319  }
320 
322  for(j = fields.g_begin(); j != fields.g_end(); ++j)
323  {
324  std::vector<FieldMap*>::const_iterator k;
325  for(k = j->second.begin(); k != j->second.end(); ++k)
326  {
327  stream << std::setw(space) << " " << "<group>" << std::endl
328  << toXMLFields(*(*k), space+2)
329  << std::setw(space) << " " << "</group>" << std::endl;
330  }
331  }
332 
333  return stream.str();
334 }
Groups::const_iterator g_const_iterator
Definition: FieldMap.h:102
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.

598 {
599  try
600  {
601  const BodyLength& aBodyLength = FIELD_GET_REF( m_header, BodyLength );
602 
603  const int expectedLength = (int)aBodyLength;
604  const int actualLength = bodyLength();
605 
606  if ( expectedLength != actualLength )
607  {
608  std::stringstream text;
609  text << "Expected BodyLength=" << actualLength
610  << ", Received BodyLength=" << expectedLength;
611  throw InvalidMessage(text.str());
612  }
613 
614  const CheckSum& aCheckSum = FIELD_GET_REF( m_trailer, CheckSum );
615 
616  const int expectedChecksum = (int)aCheckSum;
617  const int actualChecksum = checkSum();
618 
619  if ( expectedChecksum != actualChecksum )
620  {
621  std::stringstream text;
622  text << "Expected CheckSum=" << actualChecksum
623  << ", Received CheckSum=" << expectedChecksum;
624  throw InvalidMessage(text.str());
625  }
626  }
627  catch ( FieldNotFound& e )
628  {
629  const std::string fieldName = ( e.field == FIX::FIELD::BodyLength ) ? "BodyLength" : "CheckSum";
630  throw InvalidMessage( fieldName + std::string(" is missing") );
631  }
632  catch ( IncorrectDataFormat& e )
633  {
634  const std::string fieldName = ( e.field == FIX::FIELD::BodyLength ) ? "BodyLength" : "CheckSum";
635  throw InvalidMessage( fieldName + std::string(" has wrong format: ") + e.detail );
636  }
637 }
#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
mutableprotected

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

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
staticprotected

Definition at line 404 of file Message.h.

Referenced by InitializeXML(), and toXMLFields().


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

Generated on Wed Nov 24 2021 09:55:53 for QuickFIX by doxygen 1.9.1 written by Dimitri van Heesch, © 1997-2001