quickfix_ruby 1.14.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (149) hide show
  1. checksums.yaml +7 -0
  2. data/ext/quickfix/Acceptor.cpp +248 -0
  3. data/ext/quickfix/Acceptor.h +127 -0
  4. data/ext/quickfix/Allocator.h +9 -0
  5. data/ext/quickfix/Application.h +127 -0
  6. data/ext/quickfix/AtomicCount.h +109 -0
  7. data/ext/quickfix/DOMDocument.h +74 -0
  8. data/ext/quickfix/DataDictionary.cpp +618 -0
  9. data/ext/quickfix/DataDictionary.h +539 -0
  10. data/ext/quickfix/DataDictionaryProvider.cpp +71 -0
  11. data/ext/quickfix/DataDictionaryProvider.h +70 -0
  12. data/ext/quickfix/DatabaseConnectionID.h +105 -0
  13. data/ext/quickfix/DatabaseConnectionPool.h +91 -0
  14. data/ext/quickfix/Dictionary.cpp +162 -0
  15. data/ext/quickfix/Dictionary.h +94 -0
  16. data/ext/quickfix/Event.h +95 -0
  17. data/ext/quickfix/Exceptions.h +299 -0
  18. data/ext/quickfix/Field.h +672 -0
  19. data/ext/quickfix/FieldConvertors.h +863 -0
  20. data/ext/quickfix/FieldMap.cpp +238 -0
  21. data/ext/quickfix/FieldMap.h +244 -0
  22. data/ext/quickfix/FieldNumbers.h +46 -0
  23. data/ext/quickfix/FieldTypes.cpp +64 -0
  24. data/ext/quickfix/FieldTypes.h +698 -0
  25. data/ext/quickfix/Fields.h +31 -0
  26. data/ext/quickfix/FileLog.cpp +200 -0
  27. data/ext/quickfix/FileLog.h +112 -0
  28. data/ext/quickfix/FileStore.cpp +332 -0
  29. data/ext/quickfix/FileStore.h +129 -0
  30. data/ext/quickfix/FixFieldNumbers.h +1537 -0
  31. data/ext/quickfix/FixFields.h +1538 -0
  32. data/ext/quickfix/FixValues.h +3281 -0
  33. data/ext/quickfix/FlexLexer.h +188 -0
  34. data/ext/quickfix/Group.cpp +64 -0
  35. data/ext/quickfix/Group.h +73 -0
  36. data/ext/quickfix/HtmlBuilder.h +186 -0
  37. data/ext/quickfix/HttpConnection.cpp +739 -0
  38. data/ext/quickfix/HttpConnection.h +78 -0
  39. data/ext/quickfix/HttpMessage.cpp +149 -0
  40. data/ext/quickfix/HttpMessage.h +133 -0
  41. data/ext/quickfix/HttpParser.cpp +49 -0
  42. data/ext/quickfix/HttpParser.h +54 -0
  43. data/ext/quickfix/HttpServer.cpp +169 -0
  44. data/ext/quickfix/HttpServer.h +78 -0
  45. data/ext/quickfix/Initiator.cpp +289 -0
  46. data/ext/quickfix/Initiator.h +149 -0
  47. data/ext/quickfix/Log.cpp +77 -0
  48. data/ext/quickfix/Log.h +179 -0
  49. data/ext/quickfix/Message.cpp +580 -0
  50. data/ext/quickfix/Message.h +370 -0
  51. data/ext/quickfix/MessageCracker.h +188 -0
  52. data/ext/quickfix/MessageSorters.cpp +105 -0
  53. data/ext/quickfix/MessageSorters.h +156 -0
  54. data/ext/quickfix/MessageStore.cpp +146 -0
  55. data/ext/quickfix/MessageStore.h +174 -0
  56. data/ext/quickfix/Mutex.h +131 -0
  57. data/ext/quickfix/MySQLConnection.h +194 -0
  58. data/ext/quickfix/MySQLLog.cpp +275 -0
  59. data/ext/quickfix/MySQLLog.h +145 -0
  60. data/ext/quickfix/MySQLStore.cpp +331 -0
  61. data/ext/quickfix/MySQLStore.h +142 -0
  62. data/ext/quickfix/NullStore.cpp +54 -0
  63. data/ext/quickfix/NullStore.h +99 -0
  64. data/ext/quickfix/OdbcConnection.h +266 -0
  65. data/ext/quickfix/OdbcLog.cpp +252 -0
  66. data/ext/quickfix/OdbcLog.h +117 -0
  67. data/ext/quickfix/OdbcStore.cpp +338 -0
  68. data/ext/quickfix/OdbcStore.h +113 -0
  69. data/ext/quickfix/PUGIXML_DOMDocument.cpp +112 -0
  70. data/ext/quickfix/PUGIXML_DOMDocument.h +81 -0
  71. data/ext/quickfix/Parser.cpp +103 -0
  72. data/ext/quickfix/Parser.h +57 -0
  73. data/ext/quickfix/PostgreSQLConnection.h +176 -0
  74. data/ext/quickfix/PostgreSQLLog.cpp +276 -0
  75. data/ext/quickfix/PostgreSQLLog.h +144 -0
  76. data/ext/quickfix/PostgreSQLStore.cpp +334 -0
  77. data/ext/quickfix/PostgreSQLStore.h +141 -0
  78. data/ext/quickfix/Queue.h +75 -0
  79. data/ext/quickfix/QuickfixRuby.cpp +252066 -0
  80. data/ext/quickfix/QuickfixRuby.h +34 -0
  81. data/ext/quickfix/Responder.h +43 -0
  82. data/ext/quickfix/Session.cpp +1487 -0
  83. data/ext/quickfix/Session.h +335 -0
  84. data/ext/quickfix/SessionFactory.cpp +274 -0
  85. data/ext/quickfix/SessionFactory.h +86 -0
  86. data/ext/quickfix/SessionID.h +170 -0
  87. data/ext/quickfix/SessionSettings.cpp +189 -0
  88. data/ext/quickfix/SessionSettings.h +171 -0
  89. data/ext/quickfix/SessionState.h +231 -0
  90. data/ext/quickfix/Settings.cpp +100 -0
  91. data/ext/quickfix/Settings.h +53 -0
  92. data/ext/quickfix/SharedArray.h +150 -0
  93. data/ext/quickfix/SocketAcceptor.cpp +222 -0
  94. data/ext/quickfix/SocketAcceptor.h +75 -0
  95. data/ext/quickfix/SocketConnection.cpp +238 -0
  96. data/ext/quickfix/SocketConnection.h +103 -0
  97. data/ext/quickfix/SocketConnector.cpp +116 -0
  98. data/ext/quickfix/SocketConnector.h +67 -0
  99. data/ext/quickfix/SocketInitiator.cpp +260 -0
  100. data/ext/quickfix/SocketInitiator.h +81 -0
  101. data/ext/quickfix/SocketMonitor.cpp +335 -0
  102. data/ext/quickfix/SocketMonitor.h +111 -0
  103. data/ext/quickfix/SocketServer.cpp +177 -0
  104. data/ext/quickfix/SocketServer.h +100 -0
  105. data/ext/quickfix/ThreadedSocketAcceptor.cpp +258 -0
  106. data/ext/quickfix/ThreadedSocketAcceptor.h +98 -0
  107. data/ext/quickfix/ThreadedSocketConnection.cpp +209 -0
  108. data/ext/quickfix/ThreadedSocketConnection.h +82 -0
  109. data/ext/quickfix/ThreadedSocketInitiator.cpp +268 -0
  110. data/ext/quickfix/ThreadedSocketInitiator.h +84 -0
  111. data/ext/quickfix/TimeRange.cpp +173 -0
  112. data/ext/quickfix/TimeRange.h +258 -0
  113. data/ext/quickfix/Utility.cpp +537 -0
  114. data/ext/quickfix/Utility.h +219 -0
  115. data/ext/quickfix/Values.h +62 -0
  116. data/ext/quickfix/config.h +0 -0
  117. data/ext/quickfix/config_windows.h +0 -0
  118. data/ext/quickfix/extconf.rb +12 -0
  119. data/ext/quickfix/index.h +37 -0
  120. data/ext/quickfix/pugiconfig.hpp +72 -0
  121. data/ext/quickfix/pugixml.cpp +10765 -0
  122. data/ext/quickfix/pugixml.hpp +1341 -0
  123. data/ext/quickfix/strptime.h +7 -0
  124. data/lib/quickfix40.rb +274 -0
  125. data/lib/quickfix41.rb +351 -0
  126. data/lib/quickfix42.rb +1184 -0
  127. data/lib/quickfix43.rb +3504 -0
  128. data/lib/quickfix44.rb +10721 -0
  129. data/lib/quickfix50.rb +13426 -0
  130. data/lib/quickfix50sp1.rb +15629 -0
  131. data/lib/quickfix50sp2.rb +17068 -0
  132. data/lib/quickfix_fields.rb +19853 -0
  133. data/lib/quickfix_ruby.rb +82 -0
  134. data/lib/quickfixt11.rb +70 -0
  135. data/spec/FIX40.xml +862 -0
  136. data/spec/FIX41.xml +1285 -0
  137. data/spec/FIX42.xml +2746 -0
  138. data/spec/FIX43.xml +4229 -0
  139. data/spec/FIX44.xml +6596 -0
  140. data/spec/FIX50.xml +8137 -0
  141. data/spec/FIX50SP1.xml +9496 -0
  142. data/spec/FIX50SP2.xml +10011 -0
  143. data/spec/FIXT11.xml +313 -0
  144. data/test/test_DataDictionaryTestCase.rb +268 -0
  145. data/test/test_DictionaryTestCase.rb +112 -0
  146. data/test/test_FieldBaseTestCase.rb +24 -0
  147. data/test/test_MessageTestCase.rb +368 -0
  148. data/test/test_SessionSettingsTestCase.rb +41 -0
  149. metadata +193 -0
@@ -0,0 +1,338 @@
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
+ #ifdef HAVE_ODBC
27
+
28
+ #ifndef SQLLEN
29
+ #define SQLLEN SQLINTEGER
30
+ #endif
31
+
32
+ #include "OdbcStore.h"
33
+ #include "SessionID.h"
34
+ #include "SessionSettings.h"
35
+ #include "FieldConvertors.h"
36
+ #include "Parser.h"
37
+ #include "Utility.h"
38
+ #include "strptime.h"
39
+ #include <fstream>
40
+
41
+ namespace FIX
42
+ {
43
+
44
+ const std::string OdbcStoreFactory::DEFAULT_USER = "sa";
45
+ const std::string OdbcStoreFactory::DEFAULT_PASSWORD = "";
46
+ const std::string OdbcStoreFactory::DEFAULT_CONNECTION_STRING
47
+ = "DATABASE=quickfix;DRIVER={SQL Server};SERVER=(local);";
48
+
49
+ OdbcStore::OdbcStore
50
+ ( const SessionID& s, const std::string& user, const std::string& password,
51
+ const std::string& connectionString )
52
+ : m_sessionID( s )
53
+ {
54
+ m_pConnection = new OdbcConnection( user, password, connectionString );
55
+ populateCache();
56
+ }
57
+
58
+ OdbcStore::~OdbcStore()
59
+ {
60
+ delete m_pConnection;
61
+ }
62
+
63
+ void OdbcStore::populateCache()
64
+ {
65
+ std::stringstream queryString;
66
+
67
+ queryString << "SELECT creation_time, incoming_seqnum, outgoing_seqnum FROM sessions WHERE "
68
+ << "beginstring=" << "'" << m_sessionID.getBeginString().getValue() << "' and "
69
+ << "sendercompid=" << "'" << m_sessionID.getSenderCompID().getValue() << "' and "
70
+ << "targetcompid=" << "'" << m_sessionID.getTargetCompID().getValue() << "' and "
71
+ << "session_qualifier=" << "'" << m_sessionID.getSessionQualifier() << "'";
72
+
73
+ OdbcQuery query( queryString.str() );
74
+
75
+ if( !m_pConnection->execute(query) )
76
+ throw ConfigError( "Unable to connect to database" );
77
+
78
+ int rows = 0;
79
+ while( query.fetch() )
80
+ {
81
+ rows++;
82
+ if( rows > 1 )
83
+ throw ConfigError( "Multiple entries found for session in database" );
84
+
85
+ SQL_TIMESTAMP_STRUCT creationTime;
86
+ SQLLEN creationTimeLength;
87
+ SQLGetData( query.statement(), 1, SQL_C_TYPE_TIMESTAMP, &creationTime, 0, &creationTimeLength );
88
+ SQLLEN incomingSeqNum;
89
+ SQLLEN incomingSeqNumLength;
90
+ SQLGetData( query.statement(), 2, SQL_C_SLONG, &incomingSeqNum, 0, &incomingSeqNumLength );
91
+
92
+ SQLLEN outgoingSeqNum;
93
+ SQLLEN outgoingSeqNumLength;
94
+ SQLGetData( query.statement(), 3, SQL_C_SLONG, &outgoingSeqNum, 0, &outgoingSeqNumLength );
95
+
96
+ UtcTimeStamp time;
97
+ time.setYMD( creationTime.year, creationTime.month, creationTime.day );
98
+ time.setHMS( creationTime.hour, creationTime.minute, creationTime.second, creationTime.fraction );
99
+ m_cache.setCreationTime( time );
100
+ m_cache.setNextTargetMsgSeqNum( incomingSeqNum );
101
+ m_cache.setNextSenderMsgSeqNum( outgoingSeqNum );
102
+ }
103
+ query.close();
104
+
105
+ if( rows == 0 )
106
+ {
107
+ UtcTimeStamp time = m_cache.getCreationTime();
108
+ char sqlTime[ 20 ];
109
+ int year, month, day, hour, minute, second, millis;
110
+ time.getYMD (year, month, day);
111
+ time.getHMS (hour, minute, second, millis);
112
+ STRING_SPRINTF (sqlTime, "%d-%02d-%02d %02d:%02d:%02d",
113
+ year, month, day, hour, minute, second);
114
+ std::stringstream queryString2;
115
+ queryString2 << "INSERT INTO sessions (beginstring, sendercompid, targetcompid, session_qualifier,"
116
+ << "creation_time, incoming_seqnum, outgoing_seqnum) VALUES("
117
+ << "'" << m_sessionID.getBeginString().getValue() << "',"
118
+ << "'" << m_sessionID.getSenderCompID().getValue() << "',"
119
+ << "'" << m_sessionID.getTargetCompID().getValue() << "',"
120
+ << "'" << m_sessionID.getSessionQualifier() << "',"
121
+ << "{ts '" << sqlTime << "'},"
122
+ << m_cache.getNextTargetMsgSeqNum() << ","
123
+ << m_cache.getNextSenderMsgSeqNum() << ")";
124
+
125
+ OdbcQuery query2( queryString2.str() );
126
+ if( !m_pConnection->execute(query2) )
127
+ throw ConfigError( "Unable to create session in database" );
128
+ }
129
+ }
130
+
131
+ MessageStore* OdbcStoreFactory::create( const SessionID& s )
132
+ {
133
+ if( m_useSettings )
134
+ return create( s, m_settings.get(s) );
135
+ else if( m_useDictionary )
136
+ return create( s, m_dictionary );
137
+ else
138
+ return new OdbcStore( s, m_user, m_password, m_connectionString );
139
+ }
140
+
141
+ void OdbcStoreFactory::destroy( MessageStore* pStore )
142
+ {
143
+ delete pStore;
144
+ }
145
+
146
+ MessageStore* OdbcStoreFactory::create( const SessionID& s, const Dictionary& settings )
147
+ {
148
+ std::string user = DEFAULT_USER;
149
+ std::string password = DEFAULT_PASSWORD;
150
+ std::string connectionString = DEFAULT_CONNECTION_STRING;
151
+
152
+ try { user = settings.getString( ODBC_STORE_USER ); }
153
+ catch( ConfigError& ) {}
154
+
155
+ try { password = settings.getString( ODBC_STORE_PASSWORD ); }
156
+ catch( ConfigError& ) {}
157
+
158
+ try { connectionString = settings.getString( ODBC_STORE_CONNECTION_STRING ); }
159
+ catch( ConfigError& ) {}
160
+
161
+ return new OdbcStore( s, user, password, connectionString );
162
+ }
163
+
164
+ bool OdbcStore::set( int msgSeqNum, const std::string& msg )
165
+ throw ( IOException )
166
+ {
167
+ std::string msgCopy = msg;
168
+ string_replace( "'", "''", msgCopy );
169
+
170
+ std::stringstream queryString;
171
+ queryString << "INSERT INTO messages "
172
+ << "(beginstring, sendercompid, targetcompid, session_qualifier, msgseqnum, message) "
173
+ << "VALUES ("
174
+ << "'" << m_sessionID.getBeginString().getValue() << "',"
175
+ << "'" << m_sessionID.getSenderCompID().getValue() << "',"
176
+ << "'" << m_sessionID.getTargetCompID().getValue() << "',"
177
+ << "'" << m_sessionID.getSessionQualifier() << "',"
178
+ << msgSeqNum << ","
179
+ << "'" << msgCopy << "')";
180
+
181
+ OdbcQuery query( queryString.str() );
182
+ if( !m_pConnection->execute(query) )
183
+ {
184
+ query.close();
185
+ std::stringstream queryString2;
186
+ queryString2 << "UPDATE messages SET message='" << msgCopy << "' WHERE "
187
+ << "beginstring=" << "'" << m_sessionID.getBeginString().getValue() << "' and "
188
+ << "sendercompid=" << "'" << m_sessionID.getSenderCompID().getValue() << "' and "
189
+ << "targetcompid=" << "'" << m_sessionID.getTargetCompID().getValue() << "' and "
190
+ << "session_qualifier=" << "'" << m_sessionID.getSessionQualifier() << "' and "
191
+ << "msgseqnum=" << msgSeqNum;
192
+ OdbcQuery query2( queryString2.str() );
193
+ if( !m_pConnection->execute(query2) )
194
+ query2.throwException();
195
+ }
196
+ return true;
197
+ }
198
+
199
+ void OdbcStore::get( int begin, int end,
200
+ std::vector < std::string > & result ) const
201
+ throw ( IOException )
202
+ {
203
+ result.clear();
204
+ std::stringstream queryString;
205
+ queryString << "SELECT message FROM messages WHERE "
206
+ << "beginstring=" << "'" << m_sessionID.getBeginString().getValue() << "' and "
207
+ << "sendercompid=" << "'" << m_sessionID.getSenderCompID().getValue() << "' and "
208
+ << "targetcompid=" << "'" << m_sessionID.getTargetCompID().getValue() << "' and "
209
+ << "session_qualifier=" << "'" << m_sessionID.getSessionQualifier() << "' and "
210
+ << "msgseqnum>=" << begin << " and " << "msgseqnum<=" << end << " "
211
+ << "ORDER BY msgseqnum";
212
+
213
+ OdbcQuery query( queryString.str() );
214
+
215
+ if( !m_pConnection->execute(query) )
216
+ query.throwException();
217
+
218
+ while( query.fetch() )
219
+ {
220
+ std::string message;
221
+ SQLVARCHAR messageBuffer[4096];
222
+ SQLLEN messageLength;
223
+
224
+ while( odbcSuccess(SQLGetData( query.statement(), 1, SQL_C_CHAR, &messageBuffer, 4095, &messageLength)) )
225
+ {
226
+ messageBuffer[messageLength] = 0;
227
+ message += (char*)messageBuffer;
228
+ }
229
+
230
+ result.push_back( message );
231
+ }
232
+ }
233
+
234
+ int OdbcStore::getNextSenderMsgSeqNum() const throw ( IOException )
235
+ {
236
+ return m_cache.getNextSenderMsgSeqNum();
237
+ }
238
+
239
+ int OdbcStore::getNextTargetMsgSeqNum() const throw ( IOException )
240
+ {
241
+ return m_cache.getNextTargetMsgSeqNum();
242
+ }
243
+
244
+ void OdbcStore::setNextSenderMsgSeqNum( int value ) throw ( IOException )
245
+ {
246
+ std::stringstream queryString;
247
+ queryString << "UPDATE sessions SET outgoing_seqnum=" << value << " WHERE "
248
+ << "beginstring=" << "'" << m_sessionID.getBeginString().getValue() << "' and "
249
+ << "sendercompid=" << "'" << m_sessionID.getSenderCompID().getValue() << "' and "
250
+ << "targetcompid=" << "'" << m_sessionID.getTargetCompID().getValue() << "' and "
251
+ << "session_qualifier=" << "'" << m_sessionID.getSessionQualifier() << "'";
252
+ OdbcQuery query( queryString.str() );
253
+ if( !m_pConnection->execute(query) )
254
+ query.throwException();
255
+ m_cache.setNextSenderMsgSeqNum( value );
256
+ }
257
+
258
+ void OdbcStore::setNextTargetMsgSeqNum( int value ) throw ( IOException )
259
+ {
260
+ std::stringstream queryString;
261
+ queryString << "UPDATE sessions SET incoming_seqnum=" << value << " WHERE "
262
+ << "beginstring=" << "'" << m_sessionID.getBeginString().getValue() << "' and "
263
+ << "sendercompid=" << "'" << m_sessionID.getSenderCompID().getValue() << "' and "
264
+ << "targetcompid=" << "'" << m_sessionID.getTargetCompID().getValue() << "' and "
265
+ << "session_qualifier=" << "'" << m_sessionID.getSessionQualifier() << "'";
266
+
267
+ OdbcQuery query( queryString.str() );
268
+ if( !m_pConnection->execute(query) )
269
+ query.throwException();
270
+
271
+ m_cache.setNextTargetMsgSeqNum( value );
272
+ }
273
+
274
+ void OdbcStore::incrNextSenderMsgSeqNum() throw ( IOException )
275
+ {
276
+ m_cache.incrNextSenderMsgSeqNum();
277
+ setNextSenderMsgSeqNum( m_cache.getNextSenderMsgSeqNum() );
278
+ }
279
+
280
+ void OdbcStore::incrNextTargetMsgSeqNum() throw ( IOException )
281
+ {
282
+ m_cache.incrNextTargetMsgSeqNum();
283
+ setNextTargetMsgSeqNum( m_cache.getNextTargetMsgSeqNum() );
284
+ }
285
+
286
+ UtcTimeStamp OdbcStore::getCreationTime() const throw ( IOException )
287
+ {
288
+ return m_cache.getCreationTime();
289
+ }
290
+
291
+ void OdbcStore::reset() throw ( IOException )
292
+ {
293
+ std::stringstream queryString;
294
+ queryString << "DELETE FROM messages WHERE "
295
+ << "beginstring=" << "'" << m_sessionID.getBeginString().getValue() << "' and "
296
+ << "sendercompid=" << "'" << m_sessionID.getSenderCompID().getValue() << "' and "
297
+ << "targetcompid=" << "'" << m_sessionID.getTargetCompID().getValue() << "' and "
298
+ << "session_qualifier=" << "'" << m_sessionID.getSessionQualifier() << "'";
299
+
300
+ OdbcQuery query( queryString.str() );
301
+ if( !m_pConnection->execute(query) )
302
+ query.throwException();
303
+ query.close();
304
+
305
+ m_cache.reset();
306
+ UtcTimeStamp time = m_cache.getCreationTime();
307
+
308
+ int year, month, day, hour, minute, second, millis;
309
+ time.getYMD( year, month, day );
310
+ time.getHMS( hour, minute, second, millis );
311
+
312
+ char sqlTime[ 20 ];
313
+ STRING_SPRINTF( sqlTime, "%d-%02d-%02d %02d:%02d:%02d",
314
+ year, month, day, hour, minute, second );
315
+
316
+ std::stringstream queryString2;
317
+ queryString2 << "UPDATE sessions SET creation_time={ts '" << sqlTime << "'}, "
318
+ << "incoming_seqnum=" << m_cache.getNextTargetMsgSeqNum() << ", "
319
+ << "outgoing_seqnum=" << m_cache.getNextSenderMsgSeqNum() << " WHERE "
320
+ << "beginstring=" << "'" << m_sessionID.getBeginString().getValue() << "' and "
321
+ << "sendercompid=" << "'" << m_sessionID.getSenderCompID().getValue() << "' and "
322
+ << "targetcompid=" << "'" << m_sessionID.getTargetCompID().getValue() << "' and "
323
+ << "session_qualifier=" << "'" << m_sessionID.getSessionQualifier() << "'";
324
+
325
+ OdbcQuery query2( queryString2.str() );
326
+ if( !m_pConnection->execute(query2) )
327
+ query2.throwException();
328
+ }
329
+
330
+ void OdbcStore::refresh() throw ( IOException )
331
+ {
332
+ m_cache.reset();
333
+ populateCache();
334
+ }
335
+
336
+ }
337
+
338
+ #endif
@@ -0,0 +1,113 @@
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 HAVE_ODBC
23
+ #error OdbcStore.h included, but HAVE_ODBC not defined
24
+ #endif
25
+
26
+ #ifdef HAVE_ODBC
27
+ #ifndef FIX_ODBCSTORE_H
28
+ #define FIX_ODBCSTORE_H
29
+
30
+ #ifdef _MSC_VER
31
+ #pragma warning( disable : 4503 4355 4786 4290 )
32
+ #endif
33
+
34
+ #include "OdbcConnection.h"
35
+ #include "MessageStore.h"
36
+ #include "SessionSettings.h"
37
+ #include <fstream>
38
+ #include <string>
39
+
40
+ namespace FIX
41
+ {
42
+ /// Creates a Odbc based implementation of MessageStore.
43
+ class OdbcStoreFactory : public MessageStoreFactory
44
+ {
45
+ public:
46
+ static const std::string DEFAULT_USER;
47
+ static const std::string DEFAULT_PASSWORD;
48
+ static const std::string DEFAULT_CONNECTION_STRING;
49
+
50
+ OdbcStoreFactory( const SessionSettings& settings )
51
+ : m_settings( settings ), m_useSettings( true ), m_useDictionary( false ) {}
52
+
53
+ OdbcStoreFactory( const Dictionary& dictionary )
54
+ : m_dictionary( dictionary ), m_useSettings( false ), m_useDictionary( true ) {}
55
+
56
+ OdbcStoreFactory( const std::string& user, const std::string& password,
57
+ const std::string& connectionString )
58
+ : m_user( user ), m_password( password ), m_connectionString( connectionString ),
59
+ m_useSettings( false ), m_useDictionary( false ) {}
60
+
61
+ OdbcStoreFactory()
62
+ : m_user( DEFAULT_USER ), m_password( DEFAULT_PASSWORD ),
63
+ m_connectionString( DEFAULT_CONNECTION_STRING ), m_useSettings( false ), m_useDictionary( false ) {}
64
+
65
+ MessageStore* create( const SessionID& );
66
+ void destroy( MessageStore* );
67
+ private:
68
+ MessageStore* create( const SessionID& s, const Dictionary& );
69
+
70
+ Dictionary m_dictionary;
71
+ SessionSettings m_settings;
72
+ std::string m_user;
73
+ std::string m_password;
74
+ std::string m_connectionString;
75
+ bool m_useSettings;
76
+ bool m_useDictionary;
77
+ };
78
+ /*! @} */
79
+
80
+ /// Odbc based implementation of MessageStore.
81
+ class OdbcStore : public MessageStore
82
+ {
83
+ public:
84
+ OdbcStore( const SessionID& s, const std::string& user, const std::string& password,
85
+ const std::string& connectionString );
86
+ ~OdbcStore();
87
+
88
+ bool set( int, const std::string& ) throw ( IOException );
89
+ void get( int, int, std::vector < std::string > & ) const throw ( IOException );
90
+
91
+ int getNextSenderMsgSeqNum() const throw ( IOException );
92
+ int getNextTargetMsgSeqNum() const throw ( IOException );
93
+ void setNextSenderMsgSeqNum( int value ) throw ( IOException );
94
+ void setNextTargetMsgSeqNum( int value ) throw ( IOException );
95
+ void incrNextSenderMsgSeqNum() throw ( IOException );
96
+ void incrNextTargetMsgSeqNum() throw ( IOException );
97
+
98
+ UtcTimeStamp getCreationTime() const throw ( IOException );
99
+
100
+ void reset() throw ( IOException );
101
+ void refresh() throw ( IOException );
102
+
103
+ private:
104
+ void populateCache();
105
+
106
+ OdbcConnection* m_pConnection;
107
+ MemoryStore m_cache;
108
+ SessionID m_sessionID;
109
+ };
110
+ }
111
+
112
+ #endif
113
+ #endif
@@ -0,0 +1,112 @@
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 "PUGIXML_DOMDocument.h"
27
+ #include <sstream>
28
+
29
+ namespace FIX
30
+ {
31
+ bool PUGIXML_DOMAttributes::get( const std::string& name, std::string& value )
32
+ {
33
+ pugi::xml_attribute result = m_pNode.attribute(name.c_str());
34
+ if( !result ) return false;
35
+ value = result.value();
36
+ return true;
37
+ }
38
+
39
+ DOMAttributes::map PUGIXML_DOMAttributes::toMap()
40
+ {
41
+ return DOMAttributes::map();
42
+ }
43
+
44
+ DOMNodePtr PUGIXML_DOMNode::getFirstChildNode()
45
+ {
46
+ pugi::xml_node pNode = m_pNode.first_child();
47
+ if( !pNode ) return DOMNodePtr();
48
+ return DOMNodePtr(new PUGIXML_DOMNode(pNode));
49
+ }
50
+
51
+ DOMNodePtr PUGIXML_DOMNode::getNextSiblingNode()
52
+ {
53
+ pugi::xml_node pNode = m_pNode.next_sibling();
54
+ if( !pNode ) return DOMNodePtr();
55
+ return DOMNodePtr(new PUGIXML_DOMNode(pNode));
56
+ }
57
+
58
+ DOMAttributesPtr PUGIXML_DOMNode::getAttributes()
59
+ {
60
+ return DOMAttributesPtr(new PUGIXML_DOMAttributes(m_pNode));
61
+ }
62
+
63
+ std::string PUGIXML_DOMNode::getName()
64
+ {
65
+ return m_pNode.name();
66
+ }
67
+
68
+ std::string PUGIXML_DOMNode::getText()
69
+ {
70
+ return m_pNode.value();
71
+ }
72
+
73
+ PUGIXML_DOMDocument::PUGIXML_DOMDocument() throw( ConfigError )
74
+ {
75
+ }
76
+
77
+ PUGIXML_DOMDocument::~PUGIXML_DOMDocument()
78
+ {
79
+ //xmlFreeDoc(m_pDoc);
80
+ }
81
+
82
+ bool PUGIXML_DOMDocument::load( std::istream& stream )
83
+ {
84
+ try
85
+ {
86
+ return m_pDoc.load(stream);
87
+ }
88
+ catch( ... ) { return false; }
89
+ }
90
+
91
+ bool PUGIXML_DOMDocument::load( const std::string& url )
92
+ {
93
+ try
94
+ {
95
+ return m_pDoc.load_file(url.c_str());
96
+ }
97
+ catch( ... ) { return false; }
98
+ }
99
+
100
+ bool PUGIXML_DOMDocument::xml( std::ostream& out )
101
+ {
102
+ return false;
103
+ }
104
+
105
+ DOMNodePtr PUGIXML_DOMDocument::getNode( const std::string& XPath )
106
+ {
107
+ pugi::xpath_node result = m_pDoc.select_single_node(XPath.c_str());
108
+ if( !result ) return DOMNodePtr();
109
+
110
+ return DOMNodePtr(new PUGIXML_DOMNode(result.node()));
111
+ }
112
+ }
@@ -0,0 +1,81 @@
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_PUGIXMLDOMDOCUMENT_H
23
+ #define FIX_PUGIXMLDOMDOCUMENT_H
24
+
25
+ #include "DOMDocument.h"
26
+ #include "Exceptions.h"
27
+ #include "pugixml.hpp"
28
+
29
+ namespace FIX
30
+ {
31
+ /// XML attribute as represented by pugixml.
32
+ class PUGIXML_DOMAttributes : public DOMAttributes
33
+ {
34
+ public:
35
+ PUGIXML_DOMAttributes( pugi::xml_node pNode )
36
+ : m_pNode(pNode) {}
37
+
38
+ bool get( const std::string&, std::string& );
39
+ DOMAttributes::map toMap();
40
+
41
+ private:
42
+ pugi::xml_node m_pNode;
43
+ };
44
+
45
+ /// XML node as represented by pugixml.
46
+ class PUGIXML_DOMNode : public DOMNode
47
+ {
48
+ public:
49
+ PUGIXML_DOMNode( pugi::xml_node pNode )
50
+ : m_pNode(pNode) {}
51
+ ~PUGIXML_DOMNode() {}
52
+
53
+ DOMNodePtr getFirstChildNode();
54
+ DOMNodePtr getNextSiblingNode();
55
+ DOMAttributesPtr getAttributes();
56
+ std::string getName();
57
+ std::string getText();
58
+
59
+ private:
60
+ pugi::xml_node m_pNode;
61
+ };
62
+
63
+ /// XML document as represented by pugixml.
64
+ class PUGIXML_DOMDocument : public DOMDocument
65
+ {
66
+ public:
67
+ PUGIXML_DOMDocument() throw( ConfigError );
68
+ ~PUGIXML_DOMDocument();
69
+
70
+ bool load( std::istream& );
71
+ bool load( const std::string& );
72
+ bool xml( std::ostream& );
73
+
74
+ DOMNodePtr getNode( const std::string& );
75
+
76
+ private:
77
+ pugi::xml_document m_pDoc;
78
+ };
79
+ }
80
+
81
+ #endif