quickfix_ruby 1.14.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/ext/quickfix/Acceptor.cpp +248 -0
- data/ext/quickfix/Acceptor.h +127 -0
- data/ext/quickfix/Allocator.h +9 -0
- data/ext/quickfix/Application.h +127 -0
- data/ext/quickfix/AtomicCount.h +109 -0
- data/ext/quickfix/DOMDocument.h +74 -0
- data/ext/quickfix/DataDictionary.cpp +618 -0
- data/ext/quickfix/DataDictionary.h +539 -0
- data/ext/quickfix/DataDictionaryProvider.cpp +71 -0
- data/ext/quickfix/DataDictionaryProvider.h +70 -0
- data/ext/quickfix/DatabaseConnectionID.h +105 -0
- data/ext/quickfix/DatabaseConnectionPool.h +91 -0
- data/ext/quickfix/Dictionary.cpp +162 -0
- data/ext/quickfix/Dictionary.h +94 -0
- data/ext/quickfix/Event.h +95 -0
- data/ext/quickfix/Exceptions.h +299 -0
- data/ext/quickfix/Field.h +672 -0
- data/ext/quickfix/FieldConvertors.h +863 -0
- data/ext/quickfix/FieldMap.cpp +238 -0
- data/ext/quickfix/FieldMap.h +244 -0
- data/ext/quickfix/FieldNumbers.h +46 -0
- data/ext/quickfix/FieldTypes.cpp +64 -0
- data/ext/quickfix/FieldTypes.h +698 -0
- data/ext/quickfix/Fields.h +31 -0
- data/ext/quickfix/FileLog.cpp +200 -0
- data/ext/quickfix/FileLog.h +112 -0
- data/ext/quickfix/FileStore.cpp +332 -0
- data/ext/quickfix/FileStore.h +129 -0
- data/ext/quickfix/FixFieldNumbers.h +1537 -0
- data/ext/quickfix/FixFields.h +1538 -0
- data/ext/quickfix/FixValues.h +3281 -0
- data/ext/quickfix/FlexLexer.h +188 -0
- data/ext/quickfix/Group.cpp +64 -0
- data/ext/quickfix/Group.h +73 -0
- data/ext/quickfix/HtmlBuilder.h +186 -0
- data/ext/quickfix/HttpConnection.cpp +739 -0
- data/ext/quickfix/HttpConnection.h +78 -0
- data/ext/quickfix/HttpMessage.cpp +149 -0
- data/ext/quickfix/HttpMessage.h +133 -0
- data/ext/quickfix/HttpParser.cpp +49 -0
- data/ext/quickfix/HttpParser.h +54 -0
- data/ext/quickfix/HttpServer.cpp +169 -0
- data/ext/quickfix/HttpServer.h +78 -0
- data/ext/quickfix/Initiator.cpp +289 -0
- data/ext/quickfix/Initiator.h +149 -0
- data/ext/quickfix/Log.cpp +77 -0
- data/ext/quickfix/Log.h +179 -0
- data/ext/quickfix/Message.cpp +580 -0
- data/ext/quickfix/Message.h +370 -0
- data/ext/quickfix/MessageCracker.h +188 -0
- data/ext/quickfix/MessageSorters.cpp +105 -0
- data/ext/quickfix/MessageSorters.h +156 -0
- data/ext/quickfix/MessageStore.cpp +146 -0
- data/ext/quickfix/MessageStore.h +174 -0
- data/ext/quickfix/Mutex.h +131 -0
- data/ext/quickfix/MySQLConnection.h +194 -0
- data/ext/quickfix/MySQLLog.cpp +275 -0
- data/ext/quickfix/MySQLLog.h +145 -0
- data/ext/quickfix/MySQLStore.cpp +331 -0
- data/ext/quickfix/MySQLStore.h +142 -0
- data/ext/quickfix/NullStore.cpp +54 -0
- data/ext/quickfix/NullStore.h +99 -0
- data/ext/quickfix/OdbcConnection.h +266 -0
- data/ext/quickfix/OdbcLog.cpp +252 -0
- data/ext/quickfix/OdbcLog.h +117 -0
- data/ext/quickfix/OdbcStore.cpp +338 -0
- data/ext/quickfix/OdbcStore.h +113 -0
- data/ext/quickfix/PUGIXML_DOMDocument.cpp +112 -0
- data/ext/quickfix/PUGIXML_DOMDocument.h +81 -0
- data/ext/quickfix/Parser.cpp +103 -0
- data/ext/quickfix/Parser.h +57 -0
- data/ext/quickfix/PostgreSQLConnection.h +176 -0
- data/ext/quickfix/PostgreSQLLog.cpp +276 -0
- data/ext/quickfix/PostgreSQLLog.h +144 -0
- data/ext/quickfix/PostgreSQLStore.cpp +334 -0
- data/ext/quickfix/PostgreSQLStore.h +141 -0
- data/ext/quickfix/Queue.h +75 -0
- data/ext/quickfix/QuickfixRuby.cpp +252066 -0
- data/ext/quickfix/QuickfixRuby.h +34 -0
- data/ext/quickfix/Responder.h +43 -0
- data/ext/quickfix/Session.cpp +1487 -0
- data/ext/quickfix/Session.h +335 -0
- data/ext/quickfix/SessionFactory.cpp +274 -0
- data/ext/quickfix/SessionFactory.h +86 -0
- data/ext/quickfix/SessionID.h +170 -0
- data/ext/quickfix/SessionSettings.cpp +189 -0
- data/ext/quickfix/SessionSettings.h +171 -0
- data/ext/quickfix/SessionState.h +231 -0
- data/ext/quickfix/Settings.cpp +100 -0
- data/ext/quickfix/Settings.h +53 -0
- data/ext/quickfix/SharedArray.h +150 -0
- data/ext/quickfix/SocketAcceptor.cpp +222 -0
- data/ext/quickfix/SocketAcceptor.h +75 -0
- data/ext/quickfix/SocketConnection.cpp +238 -0
- data/ext/quickfix/SocketConnection.h +103 -0
- data/ext/quickfix/SocketConnector.cpp +116 -0
- data/ext/quickfix/SocketConnector.h +67 -0
- data/ext/quickfix/SocketInitiator.cpp +260 -0
- data/ext/quickfix/SocketInitiator.h +81 -0
- data/ext/quickfix/SocketMonitor.cpp +335 -0
- data/ext/quickfix/SocketMonitor.h +111 -0
- data/ext/quickfix/SocketServer.cpp +177 -0
- data/ext/quickfix/SocketServer.h +100 -0
- data/ext/quickfix/ThreadedSocketAcceptor.cpp +258 -0
- data/ext/quickfix/ThreadedSocketAcceptor.h +98 -0
- data/ext/quickfix/ThreadedSocketConnection.cpp +209 -0
- data/ext/quickfix/ThreadedSocketConnection.h +82 -0
- data/ext/quickfix/ThreadedSocketInitiator.cpp +268 -0
- data/ext/quickfix/ThreadedSocketInitiator.h +84 -0
- data/ext/quickfix/TimeRange.cpp +173 -0
- data/ext/quickfix/TimeRange.h +258 -0
- data/ext/quickfix/Utility.cpp +537 -0
- data/ext/quickfix/Utility.h +219 -0
- data/ext/quickfix/Values.h +62 -0
- data/ext/quickfix/config.h +0 -0
- data/ext/quickfix/config_windows.h +0 -0
- data/ext/quickfix/extconf.rb +12 -0
- data/ext/quickfix/index.h +37 -0
- data/ext/quickfix/pugiconfig.hpp +72 -0
- data/ext/quickfix/pugixml.cpp +10765 -0
- data/ext/quickfix/pugixml.hpp +1341 -0
- data/ext/quickfix/strptime.h +7 -0
- data/lib/quickfix40.rb +274 -0
- data/lib/quickfix41.rb +351 -0
- data/lib/quickfix42.rb +1184 -0
- data/lib/quickfix43.rb +3504 -0
- data/lib/quickfix44.rb +10721 -0
- data/lib/quickfix50.rb +13426 -0
- data/lib/quickfix50sp1.rb +15629 -0
- data/lib/quickfix50sp2.rb +17068 -0
- data/lib/quickfix_fields.rb +19853 -0
- data/lib/quickfix_ruby.rb +82 -0
- data/lib/quickfixt11.rb +70 -0
- data/spec/FIX40.xml +862 -0
- data/spec/FIX41.xml +1285 -0
- data/spec/FIX42.xml +2746 -0
- data/spec/FIX43.xml +4229 -0
- data/spec/FIX44.xml +6596 -0
- data/spec/FIX50.xml +8137 -0
- data/spec/FIX50SP1.xml +9496 -0
- data/spec/FIX50SP2.xml +10011 -0
- data/spec/FIXT11.xml +313 -0
- data/test/test_DataDictionaryTestCase.rb +268 -0
- data/test/test_DictionaryTestCase.rb +112 -0
- data/test/test_FieldBaseTestCase.rb +24 -0
- data/test/test_MessageTestCase.rb +368 -0
- data/test/test_SessionSettingsTestCase.rb +41 -0
- metadata +193 -0
@@ -0,0 +1,370 @@
|
|
1
|
+
/* -*- C++ -*- */
|
2
|
+
|
3
|
+
/****************************************************************************
|
4
|
+
** Copyright (c) 2001-2014
|
5
|
+
**
|
6
|
+
** This file is part of the QuickFIX FIX Engine
|
7
|
+
**
|
8
|
+
** This file may be distributed under the terms of the quickfixengine.org
|
9
|
+
** license as defined by quickfixengine.org and appearing in the file
|
10
|
+
** LICENSE included in the packaging of this file.
|
11
|
+
**
|
12
|
+
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
13
|
+
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
14
|
+
**
|
15
|
+
** See http://www.quickfixengine.org/LICENSE for licensing information.
|
16
|
+
**
|
17
|
+
** Contact ask@quickfixengine.org if any conditions of this licensing are
|
18
|
+
** not clear to you.
|
19
|
+
**
|
20
|
+
****************************************************************************/
|
21
|
+
|
22
|
+
#ifndef FIX_MESSAGE
|
23
|
+
#define FIX_MESSAGE
|
24
|
+
|
25
|
+
#ifdef _MSC_VER
|
26
|
+
#pragma warning( disable: 4786 )
|
27
|
+
#endif
|
28
|
+
|
29
|
+
#include "FieldMap.h"
|
30
|
+
#include "Fields.h"
|
31
|
+
#include "Group.h"
|
32
|
+
#include "SessionID.h"
|
33
|
+
#include "DataDictionary.h"
|
34
|
+
#include "Values.h"
|
35
|
+
#include <vector>
|
36
|
+
#include <memory>
|
37
|
+
|
38
|
+
namespace FIX
|
39
|
+
{
|
40
|
+
static int const headerOrder[] =
|
41
|
+
{
|
42
|
+
FIELD::BeginString,
|
43
|
+
FIELD::BodyLength,
|
44
|
+
FIELD::MsgType
|
45
|
+
};
|
46
|
+
|
47
|
+
class Header : public FieldMap
|
48
|
+
{
|
49
|
+
public:
|
50
|
+
Header() : FieldMap(message_order( message_order::header ) )
|
51
|
+
{}
|
52
|
+
};
|
53
|
+
|
54
|
+
class Trailer : public FieldMap
|
55
|
+
{
|
56
|
+
public:
|
57
|
+
Trailer() : FieldMap(message_order( message_order::trailer ) )
|
58
|
+
{}
|
59
|
+
};
|
60
|
+
|
61
|
+
/**
|
62
|
+
* Base class for all %FIX messages.
|
63
|
+
*
|
64
|
+
* A message consists of three field maps. One for the header, the body,
|
65
|
+
* and the trailer.
|
66
|
+
*/
|
67
|
+
class Message : public FieldMap
|
68
|
+
{
|
69
|
+
friend class DataDictionary;
|
70
|
+
friend class Session;
|
71
|
+
|
72
|
+
enum field_type { header, body, trailer };
|
73
|
+
|
74
|
+
public:
|
75
|
+
Message();
|
76
|
+
|
77
|
+
/// Construct a message from a string
|
78
|
+
Message( const std::string& string, bool validate = true )
|
79
|
+
throw( InvalidMessage );
|
80
|
+
|
81
|
+
/// Construct a message from a string using a data dictionary
|
82
|
+
Message( const std::string& string, const FIX::DataDictionary& dataDictionary,
|
83
|
+
bool validate = true )
|
84
|
+
throw( InvalidMessage );
|
85
|
+
|
86
|
+
/// Construct a message from a string using a session and application data dictionary
|
87
|
+
Message( const std::string& string, const FIX::DataDictionary& sessionDataDictionary,
|
88
|
+
const FIX::DataDictionary& applicationDataDictionary, bool validate = true )
|
89
|
+
throw( InvalidMessage );
|
90
|
+
|
91
|
+
Message( const Message& copy )
|
92
|
+
: FieldMap( copy )
|
93
|
+
{
|
94
|
+
m_header = copy.m_header;
|
95
|
+
m_trailer = copy.m_trailer;
|
96
|
+
m_validStructure = copy.m_validStructure;
|
97
|
+
m_field = copy.m_field;
|
98
|
+
}
|
99
|
+
|
100
|
+
/// Set global data dictionary for encoding messages into XML
|
101
|
+
static bool InitializeXML( const std::string& string );
|
102
|
+
|
103
|
+
void addGroup( const FIX::Group& group )
|
104
|
+
{ FieldMap::addGroup( group.field(), group ); }
|
105
|
+
|
106
|
+
void replaceGroup( unsigned num, const FIX::Group& group )
|
107
|
+
{ FieldMap::replaceGroup( num, group.field(), group ); }
|
108
|
+
|
109
|
+
Group& getGroup( unsigned num, FIX::Group& group ) const throw( FieldNotFound )
|
110
|
+
{ group.clear();
|
111
|
+
return static_cast < Group& >
|
112
|
+
( FieldMap::getGroup( num, group.field(), group ) );
|
113
|
+
}
|
114
|
+
|
115
|
+
void removeGroup( unsigned num, const FIX::Group& group )
|
116
|
+
{ FieldMap::removeGroup( num, group.field() ); }
|
117
|
+
void removeGroup( const FIX::Group& group )
|
118
|
+
{ FieldMap::removeGroup( group.field() ); }
|
119
|
+
|
120
|
+
bool hasGroup( const FIX::Group& group ) const
|
121
|
+
{ return FieldMap::hasGroup( group.field() ); }
|
122
|
+
bool hasGroup( unsigned num, const FIX::Group& group ) const
|
123
|
+
{ return FieldMap::hasGroup( num, group.field() ); }
|
124
|
+
|
125
|
+
protected:
|
126
|
+
// Constructor for derived classes
|
127
|
+
Message( const BeginString& beginString, const MsgType& msgType )
|
128
|
+
: m_validStructure( true )
|
129
|
+
{
|
130
|
+
m_header.setField( beginString );
|
131
|
+
m_header.setField( msgType );
|
132
|
+
}
|
133
|
+
|
134
|
+
public:
|
135
|
+
/// Get a string representation of the message
|
136
|
+
std::string toString( int beginStringField = FIELD::BeginString,
|
137
|
+
int bodyLengthField = FIELD::BodyLength,
|
138
|
+
int checkSumField = FIELD::CheckSum ) const;
|
139
|
+
/// Get a string representation without making a copy
|
140
|
+
std::string& toString( std::string&,
|
141
|
+
int beginStringField = FIELD::BeginString,
|
142
|
+
int bodyLengthField = FIELD::BodyLength,
|
143
|
+
int checkSumField = FIELD::CheckSum ) const;
|
144
|
+
/// Get a XML representation of the message
|
145
|
+
std::string toXML() const;
|
146
|
+
/// Get a XML representation without making a copy
|
147
|
+
std::string& toXML( std::string& ) const;
|
148
|
+
|
149
|
+
/**
|
150
|
+
* Add header informations depending on a source message.
|
151
|
+
* This can be used to add routing informations like OnBehalfOfCompID
|
152
|
+
* and DeliverToCompID to a message.
|
153
|
+
*/
|
154
|
+
void reverseRoute( const Header& );
|
155
|
+
|
156
|
+
/**
|
157
|
+
* Set a message based on a string representation
|
158
|
+
* This will fill in the fields on the message by parsing out the string
|
159
|
+
* that is passed in. It will return true on success and false
|
160
|
+
* on failure.
|
161
|
+
*/
|
162
|
+
void setString( const std::string& string )
|
163
|
+
throw( InvalidMessage )
|
164
|
+
{ setString(string, true); }
|
165
|
+
void setString( const std::string& string, bool validate )
|
166
|
+
throw( InvalidMessage )
|
167
|
+
{ setString(string, validate, 0); }
|
168
|
+
void setString( const std::string& string,
|
169
|
+
bool validate,
|
170
|
+
const FIX::DataDictionary* pDataDictionary )
|
171
|
+
throw( InvalidMessage )
|
172
|
+
{ setString(string, validate, pDataDictionary, pDataDictionary); }
|
173
|
+
|
174
|
+
void setString( const std::string& string,
|
175
|
+
bool validate,
|
176
|
+
const FIX::DataDictionary* pSessionDataDictionary,
|
177
|
+
const FIX::DataDictionary* pApplicationDataDictionary )
|
178
|
+
throw( InvalidMessage );
|
179
|
+
|
180
|
+
void setGroup( const std::string& msg, const FieldBase& field,
|
181
|
+
const std::string& string, std::string::size_type& pos,
|
182
|
+
FieldMap& map, const DataDictionary& dataDictionary );
|
183
|
+
|
184
|
+
/**
|
185
|
+
* Set a messages header from a string
|
186
|
+
* This is an optimization that can be used to get useful information
|
187
|
+
* from the header of a FIX string without parsing the whole thing.
|
188
|
+
*/
|
189
|
+
bool setStringHeader( const std::string& string );
|
190
|
+
|
191
|
+
/// Getter for the message header
|
192
|
+
const Header& getHeader() const { return m_header; }
|
193
|
+
/// Mutable getter for the message header
|
194
|
+
Header& getHeader() { return m_header; }
|
195
|
+
/// Getter for the message trailer
|
196
|
+
const Trailer& getTrailer() const { return m_trailer; }
|
197
|
+
/// Mutable getter for the message trailer
|
198
|
+
Trailer& getTrailer() { return m_trailer; }
|
199
|
+
|
200
|
+
bool hasValidStructure(int& field) const
|
201
|
+
{ field = m_field;
|
202
|
+
return m_validStructure;
|
203
|
+
}
|
204
|
+
|
205
|
+
int bodyLength( int beginStringField = FIELD::BeginString,
|
206
|
+
int bodyLengthField = FIELD::BodyLength,
|
207
|
+
int checkSumField = FIELD::CheckSum ) const
|
208
|
+
{ return m_header.calculateLength(beginStringField, bodyLengthField, checkSumField)
|
209
|
+
+ calculateLength(beginStringField, bodyLengthField, checkSumField)
|
210
|
+
+ m_trailer.calculateLength(beginStringField, bodyLengthField, checkSumField);
|
211
|
+
}
|
212
|
+
|
213
|
+
int checkSum( int checkSumField = FIELD::CheckSum ) const
|
214
|
+
{ return ( m_header.calculateTotal(checkSumField)
|
215
|
+
+ calculateTotal(checkSumField)
|
216
|
+
+ m_trailer.calculateTotal(checkSumField) ) % 256;
|
217
|
+
}
|
218
|
+
|
219
|
+
bool isAdmin() const
|
220
|
+
{
|
221
|
+
if( m_header.isSetField(FIELD::MsgType) )
|
222
|
+
{
|
223
|
+
const MsgType& msgType = FIELD_GET_REF( m_header, MsgType );
|
224
|
+
return isAdminMsgType( msgType );
|
225
|
+
}
|
226
|
+
return false;
|
227
|
+
}
|
228
|
+
|
229
|
+
bool isApp() const
|
230
|
+
{
|
231
|
+
if( m_header.isSetField(FIELD::MsgType) )
|
232
|
+
{
|
233
|
+
const MsgType& msgType = FIELD_GET_REF( m_header, MsgType );
|
234
|
+
return !isAdminMsgType( msgType );
|
235
|
+
}
|
236
|
+
return false;
|
237
|
+
}
|
238
|
+
|
239
|
+
bool isEmpty()
|
240
|
+
{ return m_header.isEmpty() && FieldMap::isEmpty() && m_trailer.isEmpty(); }
|
241
|
+
|
242
|
+
void clear()
|
243
|
+
{
|
244
|
+
m_field = 0;
|
245
|
+
m_header.clear();
|
246
|
+
FieldMap::clear();
|
247
|
+
m_trailer.clear();
|
248
|
+
}
|
249
|
+
|
250
|
+
static bool isAdminMsgType( const MsgType& msgType )
|
251
|
+
{ if ( msgType.getValue().length() != 1 ) return false;
|
252
|
+
return strchr
|
253
|
+
( "0A12345",
|
254
|
+
msgType.getValue().c_str() [ 0 ] ) != 0;
|
255
|
+
}
|
256
|
+
|
257
|
+
static ApplVerID toApplVerID(const BeginString& value)
|
258
|
+
{
|
259
|
+
if( value == BeginString_FIX40 )
|
260
|
+
return ApplVerID(ApplVerID_FIX40);
|
261
|
+
if( value == BeginString_FIX41 )
|
262
|
+
return ApplVerID(ApplVerID_FIX41);
|
263
|
+
if( value == BeginString_FIX42 )
|
264
|
+
return ApplVerID(ApplVerID_FIX42);
|
265
|
+
if( value == BeginString_FIX43 )
|
266
|
+
return ApplVerID(ApplVerID_FIX43);
|
267
|
+
if( value == BeginString_FIX44 )
|
268
|
+
return ApplVerID(ApplVerID_FIX44);
|
269
|
+
if( value == BeginString_FIX50 )
|
270
|
+
return ApplVerID(ApplVerID_FIX50);
|
271
|
+
if( value == "FIX.5.0SP1" )
|
272
|
+
return ApplVerID(ApplVerID_FIX50SP1);
|
273
|
+
if( value == "FIX.5.0SP2" )
|
274
|
+
return ApplVerID(ApplVerID_FIX50SP2);
|
275
|
+
return ApplVerID(ApplVerID(value));
|
276
|
+
}
|
277
|
+
|
278
|
+
static BeginString toBeginString( const ApplVerID& applVerID )
|
279
|
+
{
|
280
|
+
if( applVerID == ApplVerID_FIX40 )
|
281
|
+
return BeginString(BeginString_FIX40);
|
282
|
+
else if( applVerID == ApplVerID_FIX41 )
|
283
|
+
return BeginString(BeginString_FIX41);
|
284
|
+
else if( applVerID == ApplVerID_FIX42 )
|
285
|
+
return BeginString(BeginString_FIX42);
|
286
|
+
else if( applVerID == ApplVerID_FIX43 )
|
287
|
+
return BeginString(BeginString_FIX43);
|
288
|
+
else if( applVerID == ApplVerID_FIX44 )
|
289
|
+
return BeginString(BeginString_FIX44);
|
290
|
+
else if( applVerID == ApplVerID_FIX50 )
|
291
|
+
return BeginString(BeginString_FIX50);
|
292
|
+
else if( applVerID == ApplVerID_FIX50SP1 )
|
293
|
+
return BeginString(BeginString_FIX50);
|
294
|
+
else if( applVerID == ApplVerID_FIX50SP2 )
|
295
|
+
return BeginString(BeginString_FIX50);
|
296
|
+
else
|
297
|
+
return BeginString("");
|
298
|
+
}
|
299
|
+
|
300
|
+
static bool isHeaderField( int field );
|
301
|
+
static bool isHeaderField( const FieldBase& field,
|
302
|
+
const DataDictionary* pD = 0 );
|
303
|
+
|
304
|
+
static bool isTrailerField( int field );
|
305
|
+
static bool isTrailerField( const FieldBase& field,
|
306
|
+
const DataDictionary* pD = 0 );
|
307
|
+
|
308
|
+
/// Returns the session ID of the intended recipient
|
309
|
+
SessionID getSessionID( const std::string& qualifier = "" ) const
|
310
|
+
throw( FieldNotFound );
|
311
|
+
/// Sets the session ID of the intended recipient
|
312
|
+
void setSessionID( const SessionID& sessionID );
|
313
|
+
|
314
|
+
private:
|
315
|
+
FieldBase extractField(
|
316
|
+
const std::string& string, std::string::size_type& pos,
|
317
|
+
const DataDictionary* pSessionDD = 0, const DataDictionary* pAppDD = 0,
|
318
|
+
const Group* pGroup = 0);
|
319
|
+
|
320
|
+
static bool IsDataField(
|
321
|
+
int field,
|
322
|
+
const DataDictionary* pSessionDD,
|
323
|
+
const DataDictionary* pAppDD )
|
324
|
+
{
|
325
|
+
if( (pSessionDD && pSessionDD->isDataField( field )) ||
|
326
|
+
(pAppDD && pAppDD != pSessionDD && pAppDD->isDataField( field )) )
|
327
|
+
{
|
328
|
+
return true;
|
329
|
+
}
|
330
|
+
|
331
|
+
return false;
|
332
|
+
}
|
333
|
+
|
334
|
+
void validate();
|
335
|
+
std::string toXMLFields(const FieldMap& fields, int space) const;
|
336
|
+
|
337
|
+
protected:
|
338
|
+
mutable Header m_header;
|
339
|
+
mutable Trailer m_trailer;
|
340
|
+
bool m_validStructure;
|
341
|
+
int m_field;
|
342
|
+
static std::auto_ptr<DataDictionary> s_dataDictionary;
|
343
|
+
};
|
344
|
+
/*! @} */
|
345
|
+
|
346
|
+
inline std::ostream& operator <<
|
347
|
+
( std::ostream& stream, const Message& message )
|
348
|
+
{
|
349
|
+
std::string str;
|
350
|
+
stream << message.toString( str );
|
351
|
+
return stream;
|
352
|
+
}
|
353
|
+
|
354
|
+
/// Parse the type of a message from a string.
|
355
|
+
inline MsgType identifyType( const std::string& message )
|
356
|
+
throw( MessageParseError )
|
357
|
+
{
|
358
|
+
std::string::size_type pos = message.find( "\001" "35=" );
|
359
|
+
if ( pos == std::string::npos ) throw MessageParseError();
|
360
|
+
|
361
|
+
std::string::size_type startValue = pos + 4;
|
362
|
+
std::string::size_type soh = message.find_first_of( '\001', startValue );
|
363
|
+
if ( soh == std::string::npos ) throw MessageParseError();
|
364
|
+
|
365
|
+
std::string value = message.substr( startValue, soh - startValue );
|
366
|
+
return MsgType( value );
|
367
|
+
}
|
368
|
+
}
|
369
|
+
|
370
|
+
#endif //FIX_MESSAGE
|
@@ -0,0 +1,188 @@
|
|
1
|
+
/* -*- C++ -*- */
|
2
|
+
|
3
|
+
/****************************************************************************
|
4
|
+
** Copyright (c) 2001-2014
|
5
|
+
**
|
6
|
+
** This file is part of the QuickFIX FIX Engine
|
7
|
+
**
|
8
|
+
** This file may be distributed under the terms of the quickfixengine.org
|
9
|
+
** license as defined by quickfixengine.org and appearing in the file
|
10
|
+
** LICENSE included in the packaging of this file.
|
11
|
+
**
|
12
|
+
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
13
|
+
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
14
|
+
**
|
15
|
+
** See http://www.quickfixengine.org/LICENSE for licensing information.
|
16
|
+
**
|
17
|
+
** Contact ask@quickfixengine.org if any conditions of this licensing are
|
18
|
+
** not clear to you.
|
19
|
+
**
|
20
|
+
****************************************************************************/
|
21
|
+
|
22
|
+
#ifndef FIX_MESSAGECRACKER_H
|
23
|
+
#define FIX_MESSAGECRACKER_H
|
24
|
+
|
25
|
+
#include "fix40/MessageCracker.h"
|
26
|
+
#include "fix41/MessageCracker.h"
|
27
|
+
#include "fix42/MessageCracker.h"
|
28
|
+
#include "fix43/MessageCracker.h"
|
29
|
+
#include "fix44/MessageCracker.h"
|
30
|
+
#include "fix50/MessageCracker.h"
|
31
|
+
#include "fix50sp1/MessageCracker.h"
|
32
|
+
#include "fix50sp2/MessageCracker.h"
|
33
|
+
#include "fixt11/MessageCracker.h"
|
34
|
+
#include "Values.h"
|
35
|
+
#include "Session.h"
|
36
|
+
|
37
|
+
namespace FIX
|
38
|
+
{
|
39
|
+
/** Takes in a generic Message and produces an object that represents
|
40
|
+
* its specific version and message type.
|
41
|
+
*/
|
42
|
+
class MessageCracker
|
43
|
+
:
|
44
|
+
public FIX40::MessageCracker,
|
45
|
+
public FIX41::MessageCracker,
|
46
|
+
public FIX42::MessageCracker,
|
47
|
+
public FIX43::MessageCracker,
|
48
|
+
public FIX44::MessageCracker,
|
49
|
+
public FIX50::MessageCracker,
|
50
|
+
public FIX50SP1::MessageCracker,
|
51
|
+
public FIX50SP2::MessageCracker,
|
52
|
+
public FIXT11::MessageCracker
|
53
|
+
{
|
54
|
+
public:
|
55
|
+
void crack( const Message& message,
|
56
|
+
const SessionID& sessionID )
|
57
|
+
{
|
58
|
+
const FIX::BeginString& beginString =
|
59
|
+
FIELD_GET_REF( message.getHeader(), BeginString );
|
60
|
+
|
61
|
+
crack( message, sessionID, beginString );
|
62
|
+
}
|
63
|
+
|
64
|
+
void crack( const Message& message,
|
65
|
+
const SessionID& sessionID,
|
66
|
+
const BeginString& beginString )
|
67
|
+
{
|
68
|
+
if ( beginString == BeginString_FIX40 )
|
69
|
+
((FIX40::MessageCracker&)(*this)).crack((const FIX40::Message&) message, sessionID);
|
70
|
+
else if ( beginString == BeginString_FIX41 )
|
71
|
+
((FIX41::MessageCracker&)(*this)).crack((const FIX41::Message&) message, sessionID);
|
72
|
+
else if ( beginString == BeginString_FIX42 )
|
73
|
+
((FIX42::MessageCracker&)(*this)).crack((const FIX42::Message&) message, sessionID);
|
74
|
+
else if ( beginString == BeginString_FIX43 )
|
75
|
+
((FIX43::MessageCracker&)(*this)).crack((const FIX43::Message&) message, sessionID);
|
76
|
+
else if ( beginString == BeginString_FIX44 )
|
77
|
+
((FIX44::MessageCracker&)(*this)).crack((const FIX44::Message&) message, sessionID);
|
78
|
+
else if ( beginString == BeginString_FIXT11 )
|
79
|
+
{
|
80
|
+
if( message.isAdmin() )
|
81
|
+
{
|
82
|
+
((FIXT11::MessageCracker&)(*this)).crack((const FIXT11::Message&) message, sessionID);
|
83
|
+
}
|
84
|
+
else
|
85
|
+
{
|
86
|
+
ApplVerID applVerID;
|
87
|
+
if(!message.getHeader().getFieldIfSet(applVerID))
|
88
|
+
{
|
89
|
+
Session* pSession = Session::lookupSession( sessionID );
|
90
|
+
applVerID = pSession->getSenderDefaultApplVerID();
|
91
|
+
}
|
92
|
+
|
93
|
+
crack( message, sessionID, applVerID );
|
94
|
+
}
|
95
|
+
}
|
96
|
+
}
|
97
|
+
|
98
|
+
void crack( const Message& message,
|
99
|
+
const SessionID& sessionID,
|
100
|
+
const ApplVerID& applVerID )
|
101
|
+
{
|
102
|
+
if ( applVerID == ApplVerID_FIX40 )
|
103
|
+
((FIX40::MessageCracker&)(*this)).crack((const FIX40::Message&) message, sessionID);
|
104
|
+
if ( applVerID == ApplVerID_FIX41 )
|
105
|
+
((FIX41::MessageCracker&)(*this)).crack((const FIX41::Message&) message, sessionID);
|
106
|
+
if ( applVerID == ApplVerID_FIX42 )
|
107
|
+
((FIX42::MessageCracker&)(*this)).crack((const FIX42::Message&) message, sessionID);
|
108
|
+
if ( applVerID == ApplVerID_FIX43 )
|
109
|
+
((FIX43::MessageCracker&)(*this)).crack((const FIX43::Message&) message, sessionID);
|
110
|
+
if ( applVerID == ApplVerID_FIX44 )
|
111
|
+
((FIX44::MessageCracker&)(*this)).crack((const FIX44::Message&) message, sessionID);
|
112
|
+
if ( applVerID == ApplVerID_FIX50 )
|
113
|
+
((FIX50::MessageCracker&)(*this)).crack((const FIX50::Message&) message, sessionID);
|
114
|
+
if ( applVerID == ApplVerID_FIX50SP1 )
|
115
|
+
((FIX50SP1::MessageCracker&)(*this)).crack((const FIX50SP1::Message&) message, sessionID);
|
116
|
+
if ( applVerID == ApplVerID_FIX50SP2 )
|
117
|
+
((FIX50SP2::MessageCracker&)(*this)).crack((const FIX50SP2::Message&) message, sessionID);
|
118
|
+
}
|
119
|
+
|
120
|
+
void crack( Message& message,
|
121
|
+
const SessionID& sessionID )
|
122
|
+
{
|
123
|
+
const FIX::BeginString& beginString =
|
124
|
+
FIELD_GET_REF( message.getHeader(), BeginString );
|
125
|
+
|
126
|
+
crack( message, sessionID, beginString );
|
127
|
+
}
|
128
|
+
|
129
|
+
void crack( Message& message,
|
130
|
+
const SessionID& sessionID,
|
131
|
+
const BeginString& beginString )
|
132
|
+
{
|
133
|
+
if ( beginString == BeginString_FIX40 )
|
134
|
+
((FIX40::MessageCracker&)(*this)).crack((FIX40::Message&) message, sessionID);
|
135
|
+
else if ( beginString == BeginString_FIX41 )
|
136
|
+
((FIX41::MessageCracker&)(*this)).crack((FIX41::Message&) message, sessionID);
|
137
|
+
else if ( beginString == BeginString_FIX42 )
|
138
|
+
((FIX42::MessageCracker&)(*this)).crack((FIX42::Message&) message, sessionID);
|
139
|
+
else if ( beginString == BeginString_FIX43 )
|
140
|
+
((FIX43::MessageCracker&)(*this)).crack((FIX43::Message&) message, sessionID);
|
141
|
+
else if ( beginString == BeginString_FIX44 )
|
142
|
+
((FIX44::MessageCracker&)(*this)).crack((FIX44::Message&) message, sessionID);
|
143
|
+
else if ( beginString == BeginString_FIXT11 )
|
144
|
+
{
|
145
|
+
if( message.isAdmin() )
|
146
|
+
{
|
147
|
+
((FIXT11::MessageCracker&)(*this)).crack((FIXT11::Message&) message, sessionID);
|
148
|
+
}
|
149
|
+
else
|
150
|
+
{
|
151
|
+
ApplVerID applVerID;
|
152
|
+
if(!message.getHeader().getFieldIfSet(applVerID))
|
153
|
+
{
|
154
|
+
Session* pSession = Session::lookupSession( sessionID );
|
155
|
+
applVerID = pSession->getSenderDefaultApplVerID();
|
156
|
+
}
|
157
|
+
|
158
|
+
crack( message, sessionID, applVerID );
|
159
|
+
}
|
160
|
+
}
|
161
|
+
}
|
162
|
+
|
163
|
+
void crack( Message& message,
|
164
|
+
const SessionID& sessionID,
|
165
|
+
const ApplVerID& applVerID )
|
166
|
+
{
|
167
|
+
if ( applVerID == ApplVerID_FIX40 )
|
168
|
+
((FIX40::MessageCracker&)(*this)).crack((FIX40::Message&) message, sessionID);
|
169
|
+
if ( applVerID == ApplVerID_FIX41 )
|
170
|
+
((FIX41::MessageCracker&)(*this)).crack((FIX41::Message&) message, sessionID);
|
171
|
+
if ( applVerID == ApplVerID_FIX42 )
|
172
|
+
((FIX42::MessageCracker&)(*this)).crack((FIX42::Message&) message, sessionID);
|
173
|
+
if ( applVerID == ApplVerID_FIX43 )
|
174
|
+
((FIX43::MessageCracker&)(*this)).crack((FIX43::Message&) message, sessionID);
|
175
|
+
if ( applVerID == ApplVerID_FIX44 )
|
176
|
+
((FIX44::MessageCracker&)(*this)).crack((FIX44::Message&) message, sessionID);
|
177
|
+
if ( applVerID == ApplVerID_FIX50 )
|
178
|
+
((FIX50::MessageCracker&)(*this)).crack((FIX50::Message&) message, sessionID);
|
179
|
+
if ( applVerID == ApplVerID_FIX50SP1 )
|
180
|
+
((FIX50SP1::MessageCracker&)(*this)).crack((FIX50SP1::Message&) message, sessionID);
|
181
|
+
if ( applVerID == ApplVerID_FIX50SP2 )
|
182
|
+
((FIX50SP2::MessageCracker&)(*this)).crack((FIX50SP2::Message&) message, sessionID);
|
183
|
+
}
|
184
|
+
|
185
|
+
};
|
186
|
+
}
|
187
|
+
|
188
|
+
#endif //FIX_MESSAGECRACKER_H
|
@@ -0,0 +1,105 @@
|
|
1
|
+
/****************************************************************************
|
2
|
+
** Copyright (c) 2001-2014
|
3
|
+
**
|
4
|
+
** This file is part of the QuickFIX FIX Engine
|
5
|
+
**
|
6
|
+
** This file may be distributed under the terms of the quickfixengine.org
|
7
|
+
** license as defined by quickfixengine.org and appearing in the file
|
8
|
+
** LICENSE included in the packaging of this file.
|
9
|
+
**
|
10
|
+
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
11
|
+
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
12
|
+
**
|
13
|
+
** See http://www.quickfixengine.org/LICENSE for licensing information.
|
14
|
+
**
|
15
|
+
** Contact ask@quickfixengine.org if any conditions of this licensing are
|
16
|
+
** not clear to you.
|
17
|
+
**
|
18
|
+
****************************************************************************/
|
19
|
+
|
20
|
+
#ifdef _MSC_VER
|
21
|
+
#include "stdafx.h"
|
22
|
+
#else
|
23
|
+
#include "config.h"
|
24
|
+
#endif
|
25
|
+
|
26
|
+
#include "MessageSorters.h"
|
27
|
+
|
28
|
+
#include <string.h>
|
29
|
+
|
30
|
+
namespace FIX
|
31
|
+
{
|
32
|
+
message_order::message_order( int first, ... )
|
33
|
+
: m_mode( group ), m_delim( 0 ), m_largest( 0 )
|
34
|
+
{
|
35
|
+
int field = first;
|
36
|
+
int size = 0;
|
37
|
+
m_largest = m_delim = first;
|
38
|
+
|
39
|
+
va_list arguments;
|
40
|
+
va_start( arguments, first );
|
41
|
+
while( field != 0 )
|
42
|
+
{
|
43
|
+
m_largest = m_largest > field ? m_largest : field;
|
44
|
+
|
45
|
+
size++;
|
46
|
+
field = va_arg( arguments, int );
|
47
|
+
}
|
48
|
+
|
49
|
+
if(size)
|
50
|
+
{
|
51
|
+
m_groupOrder = shared_array<int>::create(m_largest + 1);
|
52
|
+
|
53
|
+
va_start( arguments, first );
|
54
|
+
field = first;
|
55
|
+
int i = 0;
|
56
|
+
while( field != 0 )
|
57
|
+
{
|
58
|
+
m_groupOrder[ field ] = ++i;
|
59
|
+
field = va_arg( arguments, int );
|
60
|
+
}
|
61
|
+
}
|
62
|
+
else
|
63
|
+
{
|
64
|
+
m_largest = 0;
|
65
|
+
m_delim = 0;
|
66
|
+
}
|
67
|
+
|
68
|
+
va_end( arguments );
|
69
|
+
}
|
70
|
+
|
71
|
+
message_order::message_order( const int order[] )
|
72
|
+
: m_mode( group ), m_delim( 0 ), m_largest( 0 )
|
73
|
+
{
|
74
|
+
int size = 0;
|
75
|
+
while( order[size] != 0 ) { ++size; }
|
76
|
+
setOrder(size, order);
|
77
|
+
}
|
78
|
+
|
79
|
+
message_order& message_order::operator=( const message_order& rhs )
|
80
|
+
{
|
81
|
+
m_mode = rhs.m_mode;
|
82
|
+
m_delim = rhs.m_delim;
|
83
|
+
m_largest = rhs.m_largest;
|
84
|
+
m_groupOrder = rhs.m_groupOrder;
|
85
|
+
|
86
|
+
return *this;
|
87
|
+
}
|
88
|
+
|
89
|
+
void message_order::setOrder( int size, const int order[] )
|
90
|
+
{
|
91
|
+
if(size < 1) return;
|
92
|
+
m_largest = m_delim = order[0];
|
93
|
+
|
94
|
+
// collect all fields and find the largest field number
|
95
|
+
for (int i = 1; i < size; ++i )
|
96
|
+
{
|
97
|
+
int field = order[i];
|
98
|
+
m_largest = m_largest > field ? m_largest : field;
|
99
|
+
}
|
100
|
+
|
101
|
+
m_groupOrder = shared_array<int>::create(m_largest + 1);
|
102
|
+
for (int i = 0; i < size; ++i )
|
103
|
+
m_groupOrder[ order[ i ] ] = i + 1;
|
104
|
+
}
|
105
|
+
}
|