quickfix_ruby_ud 2.0.7-aarch64-linux

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (205) hide show
  1. checksums.yaml +7 -0
  2. data/ext/quickfix/Acceptor.cpp +257 -0
  3. data/ext/quickfix/Acceptor.h +127 -0
  4. data/ext/quickfix/Allocator.h +9 -0
  5. data/ext/quickfix/Application.h +137 -0
  6. data/ext/quickfix/DOMDocument.h +70 -0
  7. data/ext/quickfix/DataDictionary.cpp +679 -0
  8. data/ext/quickfix/DataDictionary.h +607 -0
  9. data/ext/quickfix/DataDictionaryProvider.cpp +66 -0
  10. data/ext/quickfix/DataDictionaryProvider.h +67 -0
  11. data/ext/quickfix/DatabaseConnectionID.h +98 -0
  12. data/ext/quickfix/DatabaseConnectionPool.h +84 -0
  13. data/ext/quickfix/Dictionary.cpp +157 -0
  14. data/ext/quickfix/Dictionary.h +89 -0
  15. data/ext/quickfix/Event.h +89 -0
  16. data/ext/quickfix/Except.h +39 -0
  17. data/ext/quickfix/Exceptions.h +257 -0
  18. data/ext/quickfix/Field.h +654 -0
  19. data/ext/quickfix/FieldConvertors.cpp +86 -0
  20. data/ext/quickfix/FieldConvertors.h +800 -0
  21. data/ext/quickfix/FieldMap.cpp +254 -0
  22. data/ext/quickfix/FieldMap.h +327 -0
  23. data/ext/quickfix/FieldNumbers.h +44 -0
  24. data/ext/quickfix/FieldTypes.cpp +62 -0
  25. data/ext/quickfix/FieldTypes.h +817 -0
  26. data/ext/quickfix/Fields.h +30 -0
  27. data/ext/quickfix/FileLog.cpp +176 -0
  28. data/ext/quickfix/FileLog.h +110 -0
  29. data/ext/quickfix/FileStore.cpp +369 -0
  30. data/ext/quickfix/FileStore.h +131 -0
  31. data/ext/quickfix/FixCommonFields.h +13 -0
  32. data/ext/quickfix/FixFieldNumbers.h +6132 -0
  33. data/ext/quickfix/FixFields.h +6133 -0
  34. data/ext/quickfix/FixValues.h +5790 -0
  35. data/ext/quickfix/Group.cpp +44 -0
  36. data/ext/quickfix/Group.h +78 -0
  37. data/ext/quickfix/HostDetailsProvider.cpp +79 -0
  38. data/ext/quickfix/HostDetailsProvider.h +44 -0
  39. data/ext/quickfix/HtmlBuilder.h +178 -0
  40. data/ext/quickfix/HttpConnection.cpp +914 -0
  41. data/ext/quickfix/HttpConnection.h +74 -0
  42. data/ext/quickfix/HttpMessage.cpp +229 -0
  43. data/ext/quickfix/HttpMessage.h +112 -0
  44. data/ext/quickfix/HttpParser.cpp +49 -0
  45. data/ext/quickfix/HttpParser.h +49 -0
  46. data/ext/quickfix/HttpServer.cpp +152 -0
  47. data/ext/quickfix/HttpServer.h +76 -0
  48. data/ext/quickfix/Initiator.cpp +310 -0
  49. data/ext/quickfix/Initiator.h +151 -0
  50. data/ext/quickfix/Log.cpp +71 -0
  51. data/ext/quickfix/Log.h +254 -0
  52. data/ext/quickfix/Message.cpp +617 -0
  53. data/ext/quickfix/Message.h +419 -0
  54. data/ext/quickfix/MessageCracker.h +171 -0
  55. data/ext/quickfix/MessageSorters.cpp +101 -0
  56. data/ext/quickfix/MessageSorters.h +185 -0
  57. data/ext/quickfix/MessageStore.cpp +182 -0
  58. data/ext/quickfix/MessageStore.h +164 -0
  59. data/ext/quickfix/Mutex.h +120 -0
  60. data/ext/quickfix/MySQLConnection.h +187 -0
  61. data/ext/quickfix/MySQLLog.cpp +262 -0
  62. data/ext/quickfix/MySQLLog.h +158 -0
  63. data/ext/quickfix/MySQLStore.cpp +323 -0
  64. data/ext/quickfix/MySQLStore.h +161 -0
  65. data/ext/quickfix/MySQLStubs.h +203 -0
  66. data/ext/quickfix/NullStore.cpp +40 -0
  67. data/ext/quickfix/NullStore.h +89 -0
  68. data/ext/quickfix/OdbcConnection.h +241 -0
  69. data/ext/quickfix/OdbcLog.cpp +230 -0
  70. data/ext/quickfix/OdbcLog.h +109 -0
  71. data/ext/quickfix/OdbcStore.cpp +313 -0
  72. data/ext/quickfix/OdbcStore.h +124 -0
  73. data/ext/quickfix/PUGIXML_DOMDocument.cpp +112 -0
  74. data/ext/quickfix/PUGIXML_DOMDocument.h +81 -0
  75. data/ext/quickfix/Parser.cpp +111 -0
  76. data/ext/quickfix/Parser.h +50 -0
  77. data/ext/quickfix/PostgreSQLConnection.h +163 -0
  78. data/ext/quickfix/PostgreSQLLog.cpp +263 -0
  79. data/ext/quickfix/PostgreSQLLog.h +157 -0
  80. data/ext/quickfix/PostgreSQLStore.cpp +327 -0
  81. data/ext/quickfix/PostgreSQLStore.h +160 -0
  82. data/ext/quickfix/PostgreSQLStubs.h +203 -0
  83. data/ext/quickfix/Queue.h +66 -0
  84. data/ext/quickfix/QuickfixRuby.cpp +131900 -0
  85. data/ext/quickfix/QuickfixRuby.h +56 -0
  86. data/ext/quickfix/Responder.h +41 -0
  87. data/ext/quickfix/SSLSocketAcceptor.cpp +409 -0
  88. data/ext/quickfix/SSLSocketAcceptor.h +186 -0
  89. data/ext/quickfix/SSLSocketConnection.cpp +434 -0
  90. data/ext/quickfix/SSLSocketConnection.h +221 -0
  91. data/ext/quickfix/SSLSocketInitiator.cpp +558 -0
  92. data/ext/quickfix/SSLSocketInitiator.h +203 -0
  93. data/ext/quickfix/SSLStubs.h +129 -0
  94. data/ext/quickfix/Session.cpp +1437 -0
  95. data/ext/quickfix/Session.h +343 -0
  96. data/ext/quickfix/SessionFactory.cpp +314 -0
  97. data/ext/quickfix/SessionFactory.h +84 -0
  98. data/ext/quickfix/SessionID.h +136 -0
  99. data/ext/quickfix/SessionSettings.cpp +165 -0
  100. data/ext/quickfix/SessionSettings.h +283 -0
  101. data/ext/quickfix/SessionState.h +260 -0
  102. data/ext/quickfix/Settings.cpp +160 -0
  103. data/ext/quickfix/Settings.h +56 -0
  104. data/ext/quickfix/SharedArray.h +274 -0
  105. data/ext/quickfix/SocketAcceptor.cpp +216 -0
  106. data/ext/quickfix/SocketAcceptor.h +77 -0
  107. data/ext/quickfix/SocketConnection.cpp +256 -0
  108. data/ext/quickfix/SocketConnection.h +102 -0
  109. data/ext/quickfix/SocketConnector.cpp +112 -0
  110. data/ext/quickfix/SocketConnector.h +76 -0
  111. data/ext/quickfix/SocketInitiator.cpp +241 -0
  112. data/ext/quickfix/SocketInitiator.h +76 -0
  113. data/ext/quickfix/SocketMonitor.h +26 -0
  114. data/ext/quickfix/SocketMonitor_UNIX.cpp +238 -0
  115. data/ext/quickfix/SocketMonitor_UNIX.h +101 -0
  116. data/ext/quickfix/SocketMonitor_WIN32.cpp +248 -0
  117. data/ext/quickfix/SocketMonitor_WIN32.h +99 -0
  118. data/ext/quickfix/SocketServer.cpp +163 -0
  119. data/ext/quickfix/SocketServer.h +100 -0
  120. data/ext/quickfix/ThreadedSSLSocketAcceptor.cpp +436 -0
  121. data/ext/quickfix/ThreadedSSLSocketAcceptor.h +209 -0
  122. data/ext/quickfix/ThreadedSSLSocketConnection.cpp +364 -0
  123. data/ext/quickfix/ThreadedSSLSocketConnection.h +191 -0
  124. data/ext/quickfix/ThreadedSSLSocketInitiator.cpp +434 -0
  125. data/ext/quickfix/ThreadedSSLSocketInitiator.h +193 -0
  126. data/ext/quickfix/ThreadedSocketAcceptor.cpp +242 -0
  127. data/ext/quickfix/ThreadedSocketAcceptor.h +95 -0
  128. data/ext/quickfix/ThreadedSocketConnection.cpp +227 -0
  129. data/ext/quickfix/ThreadedSocketConnection.h +89 -0
  130. data/ext/quickfix/ThreadedSocketInitiator.cpp +238 -0
  131. data/ext/quickfix/ThreadedSocketInitiator.h +78 -0
  132. data/ext/quickfix/TimeRange.cpp +227 -0
  133. data/ext/quickfix/TimeRange.h +215 -0
  134. data/ext/quickfix/Utility.cpp +639 -0
  135. data/ext/quickfix/Utility.h +255 -0
  136. data/ext/quickfix/UtilitySSL.cpp +1612 -0
  137. data/ext/quickfix/UtilitySSL.h +274 -0
  138. data/ext/quickfix/Values.h +63 -0
  139. data/ext/quickfix/config-all.h +10 -0
  140. data/ext/quickfix/config.h +10 -0
  141. data/ext/quickfix/config_unix.h +178 -0
  142. data/ext/quickfix/config_windows.h +0 -0
  143. data/ext/quickfix/dirent_windows.h +838 -0
  144. data/ext/quickfix/double-conversion/bignum-dtoa.cc +641 -0
  145. data/ext/quickfix/double-conversion/bignum-dtoa.h +84 -0
  146. data/ext/quickfix/double-conversion/bignum.cc +766 -0
  147. data/ext/quickfix/double-conversion/bignum.h +144 -0
  148. data/ext/quickfix/double-conversion/cached-powers.cc +176 -0
  149. data/ext/quickfix/double-conversion/cached-powers.h +64 -0
  150. data/ext/quickfix/double-conversion/diy-fp.cc +57 -0
  151. data/ext/quickfix/double-conversion/diy-fp.h +118 -0
  152. data/ext/quickfix/double-conversion/double-conversion.cc +994 -0
  153. data/ext/quickfix/double-conversion/double-conversion.h +543 -0
  154. data/ext/quickfix/double-conversion/fast-dtoa.cc +665 -0
  155. data/ext/quickfix/double-conversion/fast-dtoa.h +88 -0
  156. data/ext/quickfix/double-conversion/fixed-dtoa.cc +404 -0
  157. data/ext/quickfix/double-conversion/fixed-dtoa.h +56 -0
  158. data/ext/quickfix/double-conversion/ieee.h +402 -0
  159. data/ext/quickfix/double-conversion/strtod.cc +557 -0
  160. data/ext/quickfix/double-conversion/strtod.h +45 -0
  161. data/ext/quickfix/double-conversion/utils.h +374 -0
  162. data/ext/quickfix/extconf.rb +76 -0
  163. data/ext/quickfix/index.h +37 -0
  164. data/ext/quickfix/pugiconfig.hpp +77 -0
  165. data/ext/quickfix/pugixml.cpp +13237 -0
  166. data/ext/quickfix/pugixml.hpp +1516 -0
  167. data/ext/quickfix/scope_guard.hpp +215 -0
  168. data/ext/quickfix/stdint_msvc.h +254 -0
  169. data/ext/quickfix/strptime.h +7 -0
  170. data/lib/2.4/quickfix.so +0 -0
  171. data/lib/2.5/quickfix.so +0 -0
  172. data/lib/2.6/quickfix.so +0 -0
  173. data/lib/2.7/quickfix.so +0 -0
  174. data/lib/3.0/quickfix.so +0 -0
  175. data/lib/3.1/quickfix.so +0 -0
  176. data/lib/3.2/quickfix.so +0 -0
  177. data/lib/3.3/quickfix.so +0 -0
  178. data/lib/3.4/quickfix.so +0 -0
  179. data/lib/quickfix40.rb +274 -0
  180. data/lib/quickfix41.rb +351 -0
  181. data/lib/quickfix42.rb +1184 -0
  182. data/lib/quickfix43.rb +3504 -0
  183. data/lib/quickfix44.rb +14040 -0
  184. data/lib/quickfix50.rb +20051 -0
  185. data/lib/quickfix50sp1.rb +23596 -0
  186. data/lib/quickfix50sp2.rb +412444 -0
  187. data/lib/quickfix_fields.rb +79393 -0
  188. data/lib/quickfix_ruby.rb +82 -0
  189. data/lib/quickfixt11.rb +65 -0
  190. data/spec/FIX40.xml +862 -0
  191. data/spec/FIX41.xml +1282 -0
  192. data/spec/FIX42.xml +2743 -0
  193. data/spec/FIX43.xml +4230 -0
  194. data/spec/FIX44.xml +6600 -0
  195. data/spec/FIX50.xml +8142 -0
  196. data/spec/FIX50SP1.xml +9506 -0
  197. data/spec/FIX50SP2.xml +26069 -0
  198. data/spec/FIXT11.xml +252 -0
  199. data/test/DataDictionaryTestCase.rb +268 -0
  200. data/test/DictionaryTestCase.rb +112 -0
  201. data/test/FieldBaseTestCase.rb +24 -0
  202. data/test/MessageStoreTestCase.rb +19 -0
  203. data/test/MessageTestCase.rb +368 -0
  204. data/test/SessionSettingsTestCase.rb +41 -0
  205. metadata +247 -0
@@ -0,0 +1,40 @@
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 "NullStore.h"
27
+
28
+ namespace FIX {
29
+
30
+ MessageStore *NullStoreFactory::create(const UtcTimeStamp &now, const SessionID &) { return new NullStore(now); }
31
+
32
+ void NullStoreFactory::destroy(MessageStore *pStore) { delete pStore; }
33
+
34
+ bool NullStore::set(SEQNUM msgSeqNum, const std::string &msg) EXCEPT(IOException) { return true; }
35
+
36
+ void NullStore::get(SEQNUM begin, SEQNUM end, std::vector<std::string> &messages) const EXCEPT(IOException) {
37
+ messages.clear();
38
+ }
39
+
40
+ } // namespace FIX
@@ -0,0 +1,89 @@
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_NULLSTORE_H
23
+ #define FIX_NULLSTORE_H
24
+
25
+ #ifdef _MSC_VER
26
+ #pragma warning(disable : 4503 4355 4786 4290)
27
+ #endif
28
+
29
+ #include "MessageStore.h"
30
+ #include "SessionSettings.h"
31
+ #include <string>
32
+
33
+ namespace FIX {
34
+ class Session;
35
+
36
+ /**
37
+ * Null implementation of MessageStore.
38
+ *
39
+ * Will not actually store messages. Useful for admin-only or market
40
+ * data-only applications.
41
+ */
42
+ class NullStoreFactory : public MessageStoreFactory {
43
+ public:
44
+ MessageStore *create(const UtcTimeStamp &, const SessionID &);
45
+ void destroy(MessageStore *);
46
+ };
47
+ /*! @} */
48
+
49
+ /**
50
+ * Null implementation of MessageStore.
51
+ *
52
+ * Will not actually store messages. Useful for admin-only or market
53
+ * data-only applications.
54
+ */
55
+ class NullStore : public MessageStore {
56
+ public:
57
+ NullStore(const UtcTimeStamp &now)
58
+ : m_nextSenderMsgSeqNum(1),
59
+ m_nextTargetMsgSeqNum(1),
60
+ m_creationTime(now) {}
61
+
62
+ bool set(SEQNUM, const std::string &) EXCEPT(IOException);
63
+ void get(SEQNUM, SEQNUM, std::vector<std::string> &) const EXCEPT(IOException);
64
+
65
+ SEQNUM getNextSenderMsgSeqNum() const EXCEPT(IOException) { return m_nextSenderMsgSeqNum; }
66
+ SEQNUM getNextTargetMsgSeqNum() const EXCEPT(IOException) { return m_nextTargetMsgSeqNum; }
67
+ void setNextSenderMsgSeqNum(SEQNUM value) EXCEPT(IOException) { m_nextSenderMsgSeqNum = value; }
68
+ void setNextTargetMsgSeqNum(SEQNUM value) EXCEPT(IOException) { m_nextTargetMsgSeqNum = value; }
69
+ void incrNextSenderMsgSeqNum() EXCEPT(IOException) { ++m_nextSenderMsgSeqNum; }
70
+ void incrNextTargetMsgSeqNum() EXCEPT(IOException) { ++m_nextTargetMsgSeqNum; }
71
+
72
+ void setCreationTime(const UtcTimeStamp &creationTime) EXCEPT(IOException) { m_creationTime = creationTime; }
73
+ UtcTimeStamp getCreationTime() const EXCEPT(IOException) { return m_creationTime; }
74
+
75
+ void reset(const UtcTimeStamp &now) EXCEPT(IOException) {
76
+ m_nextSenderMsgSeqNum = 1;
77
+ m_nextTargetMsgSeqNum = 1;
78
+ m_creationTime = now;
79
+ }
80
+ void refresh() EXCEPT(IOException) {}
81
+
82
+ private:
83
+ SEQNUM m_nextSenderMsgSeqNum;
84
+ SEQNUM m_nextTargetMsgSeqNum;
85
+ UtcTimeStamp m_creationTime;
86
+ };
87
+ } // namespace FIX
88
+
89
+ #endif // FIX_NULLSTORE_H
@@ -0,0 +1,241 @@
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 OdbcConnection.h included, but HAVE_ODBC not defined
24
+ #endif
25
+
26
+ #ifdef HAVE_ODBC
27
+ #ifndef FIX_ODBCCONNECTION_H
28
+ #define FIX_ODBCCONNECTION_H
29
+
30
+ #ifdef _MSC_VER
31
+ #pragma warning(disable : 4503 4355 4786 4290)
32
+ #pragma comment(lib, "Odbc32")
33
+ #endif
34
+
35
+ #include "DatabaseConnectionID.h"
36
+ #include "DatabaseConnectionPool.h"
37
+ #include "Exceptions.h"
38
+ #include "Mutex.h"
39
+ #include "Utility.h"
40
+ #include <sql.h>
41
+ #include <sqlext.h>
42
+ #include <sqltypes.h>
43
+ #include <sstream>
44
+
45
+ namespace FIX {
46
+
47
+ inline std::string odbcError(SQLSMALLINT statementType, SQLHANDLE handle) {
48
+ SQLCHAR state[6];
49
+ SQLINTEGER error;
50
+ SQLCHAR text[SQL_MAX_MESSAGE_LENGTH];
51
+ SQLSMALLINT textLength;
52
+ RETCODE result = SQLGetDiagRec(statementType, handle, 1, state, &error, text, sizeof(text), &textLength);
53
+ if (result == SQL_SUCCESS || result == SQL_SUCCESS_WITH_INFO) {
54
+ return std::string((char *)text);
55
+ }
56
+ return "";
57
+ }
58
+
59
+ inline bool odbcSuccess(RETCODE result) { return result == SQL_SUCCESS || result == SQL_SUCCESS_WITH_INFO; }
60
+
61
+ class OdbcQuery {
62
+ public:
63
+ OdbcQuery(const std::string &query)
64
+ : m_statement(0),
65
+ m_result(0),
66
+ m_query(query) {}
67
+
68
+ ~OdbcQuery() { close(); }
69
+
70
+ void close() {
71
+ if (m_statement) {
72
+ SQLFreeHandle(SQL_HANDLE_STMT, m_statement);
73
+ m_statement = 0;
74
+ m_result = 0;
75
+ }
76
+ }
77
+
78
+ bool execute(HDBC connection) {
79
+ if (m_statement) {
80
+ SQLFreeHandle(SQL_HANDLE_STMT, m_statement);
81
+ }
82
+ SQLAllocHandle(SQL_HANDLE_STMT, connection, &m_statement);
83
+ m_result = SQLExecDirect(m_statement, (SQLCHAR *)m_query.c_str(), (SQLINTEGER)m_query.size());
84
+ if (success() || m_result == SQL_NO_DATA) {
85
+ return true;
86
+ }
87
+ m_reason = odbcError(SQL_HANDLE_STMT, m_statement);
88
+ SQLFreeHandle(SQL_HANDLE_STMT, m_statement);
89
+ m_statement = 0;
90
+ return success();
91
+ }
92
+
93
+ bool success() { return odbcSuccess(m_result); }
94
+
95
+ /*int rows()
96
+ {
97
+ return (int)mysql_num_rows( m_result );
98
+ }*/
99
+
100
+ const std::string &reason() { return m_reason; }
101
+
102
+ bool fetch() { return odbcSuccess(SQLFetch(m_statement)); }
103
+
104
+ /*char* getValue( int row, int column )
105
+ {
106
+ if( m_rows.empty() )
107
+ {
108
+ MYSQL_ROW row = 0;
109
+ while( row = mysql_fetch_row( m_result ) )
110
+ m_rows.push_back(row);
111
+ }
112
+ return m_rows[row][column];
113
+ }*/
114
+
115
+ HSTMT statement() { return m_statement; }
116
+
117
+ void throwException() EXCEPT(IOException) {
118
+ if (!success()) {
119
+ throw IOException("Query failed [" + m_query + "] " + reason());
120
+ }
121
+ }
122
+
123
+ private:
124
+ HSTMT m_statement;
125
+ RETCODE m_result;
126
+ std::string m_query;
127
+ std::string m_reason;
128
+ };
129
+
130
+ class OdbcConnection {
131
+ public:
132
+ OdbcConnection(const DatabaseConnectionID &id)
133
+ : m_environment(0),
134
+ m_connection(0),
135
+ m_connectionID(id) {
136
+ connect();
137
+ }
138
+
139
+ OdbcConnection(const std::string &user, const std::string &password, const std::string &connectionString)
140
+ : m_environment(0),
141
+ m_connection(0),
142
+ m_connectionID("", user, password, connectionString, 0) {
143
+ connect();
144
+ }
145
+
146
+ ~OdbcConnection() {
147
+ if (m_connection) {
148
+ SQLDisconnect(m_connection);
149
+ SQLFreeHandle(SQL_HANDLE_DBC, m_connection);
150
+ SQLFreeHandle(SQL_HANDLE_ENV, m_environment);
151
+ }
152
+ }
153
+
154
+ const DatabaseConnectionID &connectionID() { return m_connectionID; }
155
+
156
+ bool connected() {
157
+ Locker locker(m_mutex);
158
+ return m_connected;
159
+ }
160
+
161
+ bool reconnect() {
162
+ Locker locker(m_mutex);
163
+ SQLDisconnect(m_connection);
164
+ SQLFreeHandle(SQL_HANDLE_DBC, m_connection);
165
+ m_connection = 0;
166
+ connect();
167
+ return true;
168
+ }
169
+
170
+ bool execute(OdbcQuery &pQuery) {
171
+ Locker locker(m_mutex);
172
+ if (!pQuery.execute(m_connection)) {
173
+ reconnect();
174
+ return pQuery.execute(m_connection);
175
+ }
176
+ return true;
177
+ }
178
+
179
+ private:
180
+ void connect() {
181
+ m_connected = false;
182
+
183
+ RETCODE result;
184
+ if (!m_environment) {
185
+ result = SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &m_environment);
186
+ if (!odbcSuccess(result)) {
187
+ throw ConfigError("Unable to allocate ODBC environment");
188
+ }
189
+
190
+ result = SQLSetEnvAttr(m_environment, SQL_ATTR_ODBC_VERSION, (void *)SQL_OV_ODBC3, 0);
191
+ if (!odbcSuccess(result)) {
192
+ throw ConfigError("Unable to find ODBC version 3.0");
193
+ }
194
+ }
195
+
196
+ result = SQLAllocHandle(SQL_HANDLE_DBC, m_environment, &m_connection);
197
+ if (!odbcSuccess(result)) {
198
+ throw ConfigError("Unable to allocate ODBC connection");
199
+ }
200
+
201
+ std::stringstream connectionStream;
202
+ std::string connectionString = m_connectionID.getHost();
203
+ if (m_connectionID.getHost().find("UID=") == std::string::npos) {
204
+ connectionStream << "UID=" << m_connectionID.getUser() << ";";
205
+ }
206
+ if (m_connectionID.getHost().find("PWD=") == std::string::npos) {
207
+ connectionStream << "PWD=" << m_connectionID.getPassword() << ";";
208
+ }
209
+ connectionStream << m_connectionID.getHost();
210
+ connectionString = connectionStream.str();
211
+
212
+ SQLCHAR connectionStringOut[255];
213
+
214
+ result = SQLDriverConnect(
215
+ m_connection,
216
+ NULL,
217
+ (SQLCHAR *)connectionString.c_str(),
218
+ SQL_NTS,
219
+ connectionStringOut,
220
+ 255,
221
+ 0,
222
+ SQL_DRIVER_NOPROMPT);
223
+
224
+ if (!odbcSuccess(result)) {
225
+ std::string error = odbcError(SQL_HANDLE_DBC, m_connection);
226
+ throw ConfigError(error);
227
+ }
228
+
229
+ m_connected = true;
230
+ }
231
+
232
+ HENV m_environment;
233
+ HDBC m_connection;
234
+ bool m_connected;
235
+ DatabaseConnectionID m_connectionID;
236
+ Mutex m_mutex;
237
+ };
238
+ } // namespace FIX
239
+
240
+ #endif
241
+ #endif
@@ -0,0 +1,230 @@
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
+ #include "OdbcLog.h"
29
+ #include "SessionID.h"
30
+ #include "SessionSettings.h"
31
+ #include "Utility.h"
32
+ #include "strptime.h"
33
+ #include <fstream>
34
+
35
+ namespace FIX {
36
+
37
+ const std::string OdbcLogFactory::DEFAULT_USER = "sa";
38
+ const std::string OdbcLogFactory::DEFAULT_PASSWORD = "";
39
+ const std::string OdbcLogFactory::DEFAULT_CONNECTION_STRING = "DATABASE=quickfix;DRIVER={SQL Server};SERVER=(local);";
40
+
41
+ OdbcLog::OdbcLog(
42
+ const SessionID &s,
43
+ const std::string &user,
44
+ const std::string &password,
45
+ const std::string &connectionString) {
46
+ init();
47
+ m_pSessionID = new SessionID(s);
48
+ m_pConnection = new OdbcConnection(user, password, connectionString);
49
+ }
50
+
51
+ OdbcLog::OdbcLog(const std::string &user, const std::string &password, const std::string &connectionString)
52
+ : m_pSessionID(0) {
53
+ init();
54
+ m_pConnection = new OdbcConnection(user, password, connectionString);
55
+ }
56
+
57
+ void OdbcLog::init() {
58
+ setIncomingTable("messages_log");
59
+ setOutgoingTable("messages_log");
60
+ setEventTable("event_log");
61
+ }
62
+
63
+ OdbcLog::~OdbcLog() {
64
+ delete m_pSessionID;
65
+ delete m_pConnection;
66
+ }
67
+
68
+ OdbcLogFactory::OdbcLogFactory(
69
+ const std::string &user,
70
+ const std::string &password,
71
+ const std::string &connectionString)
72
+ : m_user(user),
73
+ m_password(password),
74
+ m_connectionString(connectionString),
75
+ m_useSettings(false) {}
76
+
77
+ OdbcLogFactory::OdbcLogFactory()
78
+ : m_user(DEFAULT_USER),
79
+ m_password(DEFAULT_PASSWORD),
80
+ m_connectionString(DEFAULT_CONNECTION_STRING),
81
+ m_useSettings(false) {}
82
+
83
+ OdbcLogFactory::~OdbcLogFactory() {}
84
+
85
+ Log *OdbcLogFactory::create() {
86
+ std::string database;
87
+ std::string user;
88
+ std::string connectionString;
89
+
90
+ init(m_settings.get(), database, user, connectionString);
91
+ OdbcLog *result = new OdbcLog(database, user, connectionString);
92
+ initLog(m_settings.get(), *result);
93
+ return result;
94
+ }
95
+
96
+ Log *OdbcLogFactory::create(const SessionID &s) {
97
+ std::string database;
98
+ std::string user;
99
+ std::string connectionString;
100
+
101
+ Dictionary settings;
102
+ if (m_settings.has(s)) {
103
+ settings = m_settings.get(s);
104
+ }
105
+
106
+ init(settings, database, user, connectionString);
107
+ OdbcLog *result = new OdbcLog(s, database, user, connectionString);
108
+ initLog(settings, *result);
109
+ return result;
110
+ }
111
+
112
+ void OdbcLogFactory::init(
113
+ const Dictionary &settings,
114
+ std::string &user,
115
+ std::string &password,
116
+ std::string &connectionString) {
117
+ user = DEFAULT_USER;
118
+ password = DEFAULT_PASSWORD;
119
+ connectionString = DEFAULT_CONNECTION_STRING;
120
+
121
+ if (m_useSettings) {
122
+ try {
123
+ user = settings.getString(ODBC_LOG_USER);
124
+ } catch (ConfigError &) {}
125
+
126
+ try {
127
+ password = settings.getString(ODBC_LOG_PASSWORD);
128
+ } catch (ConfigError &) {}
129
+
130
+ try {
131
+ connectionString = settings.getString(ODBC_LOG_CONNECTION_STRING);
132
+ } catch (ConfigError &) {}
133
+ } else {
134
+ user = m_user;
135
+ password = m_password;
136
+ connectionString = m_connectionString;
137
+ }
138
+ }
139
+
140
+ void OdbcLogFactory::initLog(const Dictionary &settings, OdbcLog &log) {
141
+ try {
142
+ log.setIncomingTable(settings.getString(ODBC_LOG_INCOMING_TABLE));
143
+ } catch (ConfigError &) {}
144
+
145
+ try {
146
+ log.setOutgoingTable(settings.getString(ODBC_LOG_OUTGOING_TABLE));
147
+ } catch (ConfigError &) {}
148
+
149
+ try {
150
+ log.setEventTable(settings.getString(ODBC_LOG_EVENT_TABLE));
151
+ } catch (ConfigError &) {}
152
+ }
153
+
154
+ void OdbcLogFactory::destroy(Log *pLog) { delete pLog; }
155
+
156
+ void OdbcLog::clear() {
157
+ std::stringstream whereClause;
158
+
159
+ whereClause << "WHERE ";
160
+
161
+ if (m_pSessionID) {
162
+ whereClause << "BeginString = '" << m_pSessionID->getBeginString().getValue() << "' "
163
+ << "AND SenderCompID = '" << m_pSessionID->getSenderCompID().getValue() << "' "
164
+ << "AND TargetCompID = '" << m_pSessionID->getTargetCompID().getValue() << "' ";
165
+
166
+ if (m_pSessionID->getSessionQualifier().size()) {
167
+ whereClause << "AND SessionQualifier = '" << m_pSessionID->getSessionQualifier() << "'";
168
+ }
169
+ } else {
170
+ whereClause << "BeginString = NULL AND SenderCompID = NULL && TargetCompID = NULL";
171
+ }
172
+
173
+ std::stringstream incomingQuery;
174
+ std::stringstream outgoingQuery;
175
+ std::stringstream eventQuery;
176
+
177
+ incomingQuery << "DELETE FROM " << m_incomingTable << " " << whereClause.str();
178
+ outgoingQuery << "DELETE FROM " << m_outgoingTable << " " << whereClause.str();
179
+ eventQuery << "DELETE FROM " << m_eventTable << " " << whereClause.str();
180
+
181
+ OdbcQuery incoming(incomingQuery.str());
182
+ OdbcQuery outgoing(outgoingQuery.str());
183
+ OdbcQuery event(eventQuery.str());
184
+ m_pConnection->execute(incoming);
185
+ m_pConnection->execute(outgoing);
186
+ m_pConnection->execute(event);
187
+ }
188
+
189
+ void OdbcLog::backup() {}
190
+
191
+ void OdbcLog::insert(const std::string &table, const std::string value) {
192
+ UtcTimeStamp time = UtcTimeStamp::now();
193
+ int year, month, day, hour, minute, second, millis;
194
+ time.getYMD(year, month, day);
195
+ time.getHMS(hour, minute, second, millis);
196
+
197
+ char sqlTime[100];
198
+ STRING_SPRINTF(sqlTime, "%d-%02d-%02d %02d:%02d:%02d.%003d", year, month, day, hour, minute, second, millis);
199
+
200
+ std::string valueCopy = value;
201
+ string_replace("'", "''", valueCopy);
202
+
203
+ std::stringstream queryString;
204
+ queryString << "INSERT INTO " << table << " "
205
+ << "(time, beginstring, sendercompid, targetcompid, session_qualifier, text) "
206
+ << "VALUES ("
207
+ << "{ts '" << sqlTime << "'},";
208
+
209
+ if (m_pSessionID) {
210
+ queryString << "'" << m_pSessionID->getBeginString().getValue() << "',"
211
+ << "'" << m_pSessionID->getSenderCompID().getValue() << "',"
212
+ << "'" << m_pSessionID->getTargetCompID().getValue() << "',";
213
+ if (m_pSessionID->getSessionQualifier() == "") {
214
+ queryString << "NULL" << ",";
215
+ } else {
216
+ queryString << "'" << m_pSessionID->getSessionQualifier() << "',";
217
+ }
218
+ } else {
219
+ queryString << "NULL, NULL, NULL, NULL, ";
220
+ }
221
+
222
+ queryString << "'" << valueCopy << "')";
223
+
224
+ OdbcQuery query(queryString.str());
225
+ m_pConnection->execute(query);
226
+ }
227
+
228
+ } // namespace FIX
229
+
230
+ #endif
@@ -0,0 +1,109 @@
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 OdbcLog.h included, but HAVE_ODBC not defined
24
+ #endif
25
+
26
+ #ifdef HAVE_ODBC
27
+ #ifndef FIX_ODBCLOG_H
28
+ #define FIX_ODBCLOG_H
29
+
30
+ #ifdef _MSC_VER
31
+ #pragma warning(disable : 4503 4355 4786 4290)
32
+ #endif
33
+
34
+ #include "Log.h"
35
+ #include "OdbcConnection.h"
36
+ #include "SessionSettings.h"
37
+ #include <fstream>
38
+ #include <string>
39
+
40
+ namespace FIX {
41
+ /// ODBC based implementation of Log.
42
+ class OdbcLog : public Log {
43
+ public:
44
+ OdbcLog(
45
+ const SessionID &s,
46
+ const std::string &user,
47
+ const std::string &password,
48
+ const std::string &connectionString);
49
+ OdbcLog(const std::string &user, const std::string &password, const std::string &connectionString);
50
+
51
+ ~OdbcLog();
52
+
53
+ void clear();
54
+ void backup();
55
+ void setIncomingTable(const std::string &incomingTable) { m_incomingTable = incomingTable; }
56
+ void setOutgoingTable(const std::string &outgoingTable) { m_outgoingTable = outgoingTable; }
57
+ void setEventTable(const std::string &eventTable) { m_eventTable = eventTable; }
58
+
59
+ void onIncoming(const std::string &value) { insert(m_incomingTable, value); }
60
+ void onOutgoing(const std::string &value) { insert(m_outgoingTable, value); }
61
+ void onEvent(const std::string &value) { insert(m_eventTable, value); }
62
+
63
+ private:
64
+ void init();
65
+ void insert(const std::string &table, const std::string value);
66
+
67
+ std::string m_incomingTable;
68
+ std::string m_outgoingTable;
69
+ std::string m_eventTable;
70
+ OdbcConnection *m_pConnection;
71
+ SessionID *m_pSessionID;
72
+ };
73
+
74
+ /// Creates a ODBC based implementation of Log.
75
+ class OdbcLogFactory : public LogFactory {
76
+ public:
77
+ static const std::string DEFAULT_USER;
78
+ static const std::string DEFAULT_PASSWORD;
79
+ static const std::string DEFAULT_CONNECTION_STRING;
80
+
81
+ OdbcLogFactory(const SessionSettings &settings)
82
+ : m_settings(settings),
83
+ m_useSettings(true) {}
84
+
85
+ OdbcLogFactory(const std::string &user, const std::string &password, const std::string &connectionString);
86
+
87
+ OdbcLogFactory();
88
+
89
+ ~OdbcLogFactory();
90
+
91
+ Log *create();
92
+ Log *create(const SessionID &);
93
+ void destroy(Log *);
94
+
95
+ private:
96
+ void init(const Dictionary &settings, std::string &user, std::string &password, std::string &connectionString);
97
+
98
+ void initLog(const Dictionary &settings, OdbcLog &log);
99
+
100
+ SessionSettings m_settings;
101
+ std::string m_user;
102
+ std::string m_password;
103
+ std::string m_connectionString;
104
+ bool m_useSettings;
105
+ };
106
+ } // namespace FIX
107
+
108
+ #endif
109
+ #endif