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.
- checksums.yaml +7 -0
- data/ext/quickfix/Acceptor.cpp +257 -0
- data/ext/quickfix/Acceptor.h +127 -0
- data/ext/quickfix/Allocator.h +9 -0
- data/ext/quickfix/Application.h +137 -0
- data/ext/quickfix/DOMDocument.h +70 -0
- data/ext/quickfix/DataDictionary.cpp +679 -0
- data/ext/quickfix/DataDictionary.h +607 -0
- data/ext/quickfix/DataDictionaryProvider.cpp +66 -0
- data/ext/quickfix/DataDictionaryProvider.h +67 -0
- data/ext/quickfix/DatabaseConnectionID.h +98 -0
- data/ext/quickfix/DatabaseConnectionPool.h +84 -0
- data/ext/quickfix/Dictionary.cpp +157 -0
- data/ext/quickfix/Dictionary.h +89 -0
- data/ext/quickfix/Event.h +89 -0
- data/ext/quickfix/Except.h +39 -0
- data/ext/quickfix/Exceptions.h +257 -0
- data/ext/quickfix/Field.h +654 -0
- data/ext/quickfix/FieldConvertors.cpp +86 -0
- data/ext/quickfix/FieldConvertors.h +800 -0
- data/ext/quickfix/FieldMap.cpp +254 -0
- data/ext/quickfix/FieldMap.h +327 -0
- data/ext/quickfix/FieldNumbers.h +44 -0
- data/ext/quickfix/FieldTypes.cpp +62 -0
- data/ext/quickfix/FieldTypes.h +817 -0
- data/ext/quickfix/Fields.h +30 -0
- data/ext/quickfix/FileLog.cpp +176 -0
- data/ext/quickfix/FileLog.h +110 -0
- data/ext/quickfix/FileStore.cpp +369 -0
- data/ext/quickfix/FileStore.h +131 -0
- data/ext/quickfix/FixCommonFields.h +13 -0
- data/ext/quickfix/FixFieldNumbers.h +6132 -0
- data/ext/quickfix/FixFields.h +6133 -0
- data/ext/quickfix/FixValues.h +5790 -0
- data/ext/quickfix/Group.cpp +44 -0
- data/ext/quickfix/Group.h +78 -0
- data/ext/quickfix/HostDetailsProvider.cpp +79 -0
- data/ext/quickfix/HostDetailsProvider.h +44 -0
- data/ext/quickfix/HtmlBuilder.h +178 -0
- data/ext/quickfix/HttpConnection.cpp +914 -0
- data/ext/quickfix/HttpConnection.h +74 -0
- data/ext/quickfix/HttpMessage.cpp +229 -0
- data/ext/quickfix/HttpMessage.h +112 -0
- data/ext/quickfix/HttpParser.cpp +49 -0
- data/ext/quickfix/HttpParser.h +49 -0
- data/ext/quickfix/HttpServer.cpp +152 -0
- data/ext/quickfix/HttpServer.h +76 -0
- data/ext/quickfix/Initiator.cpp +310 -0
- data/ext/quickfix/Initiator.h +151 -0
- data/ext/quickfix/Log.cpp +71 -0
- data/ext/quickfix/Log.h +254 -0
- data/ext/quickfix/Message.cpp +617 -0
- data/ext/quickfix/Message.h +419 -0
- data/ext/quickfix/MessageCracker.h +171 -0
- data/ext/quickfix/MessageSorters.cpp +101 -0
- data/ext/quickfix/MessageSorters.h +185 -0
- data/ext/quickfix/MessageStore.cpp +182 -0
- data/ext/quickfix/MessageStore.h +164 -0
- data/ext/quickfix/Mutex.h +120 -0
- data/ext/quickfix/MySQLConnection.h +187 -0
- data/ext/quickfix/MySQLLog.cpp +262 -0
- data/ext/quickfix/MySQLLog.h +158 -0
- data/ext/quickfix/MySQLStore.cpp +323 -0
- data/ext/quickfix/MySQLStore.h +161 -0
- data/ext/quickfix/MySQLStubs.h +203 -0
- data/ext/quickfix/NullStore.cpp +40 -0
- data/ext/quickfix/NullStore.h +89 -0
- data/ext/quickfix/OdbcConnection.h +241 -0
- data/ext/quickfix/OdbcLog.cpp +230 -0
- data/ext/quickfix/OdbcLog.h +109 -0
- data/ext/quickfix/OdbcStore.cpp +313 -0
- data/ext/quickfix/OdbcStore.h +124 -0
- data/ext/quickfix/PUGIXML_DOMDocument.cpp +112 -0
- data/ext/quickfix/PUGIXML_DOMDocument.h +81 -0
- data/ext/quickfix/Parser.cpp +111 -0
- data/ext/quickfix/Parser.h +50 -0
- data/ext/quickfix/PostgreSQLConnection.h +163 -0
- data/ext/quickfix/PostgreSQLLog.cpp +263 -0
- data/ext/quickfix/PostgreSQLLog.h +157 -0
- data/ext/quickfix/PostgreSQLStore.cpp +327 -0
- data/ext/quickfix/PostgreSQLStore.h +160 -0
- data/ext/quickfix/PostgreSQLStubs.h +203 -0
- data/ext/quickfix/Queue.h +66 -0
- data/ext/quickfix/QuickfixRuby.cpp +131900 -0
- data/ext/quickfix/QuickfixRuby.h +56 -0
- data/ext/quickfix/Responder.h +41 -0
- data/ext/quickfix/SSLSocketAcceptor.cpp +409 -0
- data/ext/quickfix/SSLSocketAcceptor.h +186 -0
- data/ext/quickfix/SSLSocketConnection.cpp +434 -0
- data/ext/quickfix/SSLSocketConnection.h +221 -0
- data/ext/quickfix/SSLSocketInitiator.cpp +558 -0
- data/ext/quickfix/SSLSocketInitiator.h +203 -0
- data/ext/quickfix/SSLStubs.h +129 -0
- data/ext/quickfix/Session.cpp +1437 -0
- data/ext/quickfix/Session.h +343 -0
- data/ext/quickfix/SessionFactory.cpp +314 -0
- data/ext/quickfix/SessionFactory.h +84 -0
- data/ext/quickfix/SessionID.h +136 -0
- data/ext/quickfix/SessionSettings.cpp +165 -0
- data/ext/quickfix/SessionSettings.h +283 -0
- data/ext/quickfix/SessionState.h +260 -0
- data/ext/quickfix/Settings.cpp +160 -0
- data/ext/quickfix/Settings.h +56 -0
- data/ext/quickfix/SharedArray.h +274 -0
- data/ext/quickfix/SocketAcceptor.cpp +216 -0
- data/ext/quickfix/SocketAcceptor.h +77 -0
- data/ext/quickfix/SocketConnection.cpp +256 -0
- data/ext/quickfix/SocketConnection.h +102 -0
- data/ext/quickfix/SocketConnector.cpp +112 -0
- data/ext/quickfix/SocketConnector.h +76 -0
- data/ext/quickfix/SocketInitiator.cpp +241 -0
- data/ext/quickfix/SocketInitiator.h +76 -0
- data/ext/quickfix/SocketMonitor.h +26 -0
- data/ext/quickfix/SocketMonitor_UNIX.cpp +238 -0
- data/ext/quickfix/SocketMonitor_UNIX.h +101 -0
- data/ext/quickfix/SocketMonitor_WIN32.cpp +248 -0
- data/ext/quickfix/SocketMonitor_WIN32.h +99 -0
- data/ext/quickfix/SocketServer.cpp +163 -0
- data/ext/quickfix/SocketServer.h +100 -0
- data/ext/quickfix/ThreadedSSLSocketAcceptor.cpp +436 -0
- data/ext/quickfix/ThreadedSSLSocketAcceptor.h +209 -0
- data/ext/quickfix/ThreadedSSLSocketConnection.cpp +364 -0
- data/ext/quickfix/ThreadedSSLSocketConnection.h +191 -0
- data/ext/quickfix/ThreadedSSLSocketInitiator.cpp +434 -0
- data/ext/quickfix/ThreadedSSLSocketInitiator.h +193 -0
- data/ext/quickfix/ThreadedSocketAcceptor.cpp +242 -0
- data/ext/quickfix/ThreadedSocketAcceptor.h +95 -0
- data/ext/quickfix/ThreadedSocketConnection.cpp +227 -0
- data/ext/quickfix/ThreadedSocketConnection.h +89 -0
- data/ext/quickfix/ThreadedSocketInitiator.cpp +238 -0
- data/ext/quickfix/ThreadedSocketInitiator.h +78 -0
- data/ext/quickfix/TimeRange.cpp +227 -0
- data/ext/quickfix/TimeRange.h +215 -0
- data/ext/quickfix/Utility.cpp +639 -0
- data/ext/quickfix/Utility.h +255 -0
- data/ext/quickfix/UtilitySSL.cpp +1612 -0
- data/ext/quickfix/UtilitySSL.h +274 -0
- data/ext/quickfix/Values.h +63 -0
- data/ext/quickfix/config-all.h +10 -0
- data/ext/quickfix/config.h +10 -0
- data/ext/quickfix/config_unix.h +178 -0
- data/ext/quickfix/config_windows.h +0 -0
- data/ext/quickfix/dirent_windows.h +838 -0
- data/ext/quickfix/double-conversion/bignum-dtoa.cc +641 -0
- data/ext/quickfix/double-conversion/bignum-dtoa.h +84 -0
- data/ext/quickfix/double-conversion/bignum.cc +766 -0
- data/ext/quickfix/double-conversion/bignum.h +144 -0
- data/ext/quickfix/double-conversion/cached-powers.cc +176 -0
- data/ext/quickfix/double-conversion/cached-powers.h +64 -0
- data/ext/quickfix/double-conversion/diy-fp.cc +57 -0
- data/ext/quickfix/double-conversion/diy-fp.h +118 -0
- data/ext/quickfix/double-conversion/double-conversion.cc +994 -0
- data/ext/quickfix/double-conversion/double-conversion.h +543 -0
- data/ext/quickfix/double-conversion/fast-dtoa.cc +665 -0
- data/ext/quickfix/double-conversion/fast-dtoa.h +88 -0
- data/ext/quickfix/double-conversion/fixed-dtoa.cc +404 -0
- data/ext/quickfix/double-conversion/fixed-dtoa.h +56 -0
- data/ext/quickfix/double-conversion/ieee.h +402 -0
- data/ext/quickfix/double-conversion/strtod.cc +557 -0
- data/ext/quickfix/double-conversion/strtod.h +45 -0
- data/ext/quickfix/double-conversion/utils.h +374 -0
- data/ext/quickfix/extconf.rb +76 -0
- data/ext/quickfix/index.h +37 -0
- data/ext/quickfix/pugiconfig.hpp +77 -0
- data/ext/quickfix/pugixml.cpp +13237 -0
- data/ext/quickfix/pugixml.hpp +1516 -0
- data/ext/quickfix/scope_guard.hpp +215 -0
- data/ext/quickfix/stdint_msvc.h +254 -0
- data/ext/quickfix/strptime.h +7 -0
- data/lib/2.4/quickfix.so +0 -0
- data/lib/2.5/quickfix.so +0 -0
- data/lib/2.6/quickfix.so +0 -0
- data/lib/2.7/quickfix.so +0 -0
- data/lib/3.0/quickfix.so +0 -0
- data/lib/3.1/quickfix.so +0 -0
- data/lib/3.2/quickfix.so +0 -0
- data/lib/3.3/quickfix.so +0 -0
- data/lib/3.4/quickfix.so +0 -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 +14040 -0
- data/lib/quickfix50.rb +20051 -0
- data/lib/quickfix50sp1.rb +23596 -0
- data/lib/quickfix50sp2.rb +412444 -0
- data/lib/quickfix_fields.rb +79393 -0
- data/lib/quickfix_ruby.rb +82 -0
- data/lib/quickfixt11.rb +65 -0
- data/spec/FIX40.xml +862 -0
- data/spec/FIX41.xml +1282 -0
- data/spec/FIX42.xml +2743 -0
- data/spec/FIX43.xml +4230 -0
- data/spec/FIX44.xml +6600 -0
- data/spec/FIX50.xml +8142 -0
- data/spec/FIX50SP1.xml +9506 -0
- data/spec/FIX50SP2.xml +26069 -0
- data/spec/FIXT11.xml +252 -0
- data/test/DataDictionaryTestCase.rb +268 -0
- data/test/DictionaryTestCase.rb +112 -0
- data/test/FieldBaseTestCase.rb +24 -0
- data/test/MessageStoreTestCase.rb +19 -0
- data/test/MessageTestCase.rb +368 -0
- data/test/SessionSettingsTestCase.rb +41 -0
- metadata +247 -0
@@ -0,0 +1,313 @@
|
|
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 "FieldConvertors.h"
|
29
|
+
#include "OdbcStore.h"
|
30
|
+
#include "Parser.h"
|
31
|
+
#include "SessionID.h"
|
32
|
+
#include "SessionSettings.h"
|
33
|
+
#include "Utility.h"
|
34
|
+
#include "strptime.h"
|
35
|
+
#include <fstream>
|
36
|
+
|
37
|
+
namespace FIX {
|
38
|
+
|
39
|
+
const std::string OdbcStoreFactory::DEFAULT_USER = "sa";
|
40
|
+
const std::string OdbcStoreFactory::DEFAULT_PASSWORD = "";
|
41
|
+
const std::string OdbcStoreFactory::DEFAULT_CONNECTION_STRING = "DATABASE=quickfix;DRIVER={SQL Server};SERVER=(local);";
|
42
|
+
|
43
|
+
OdbcStore::OdbcStore(
|
44
|
+
const UtcTimeStamp &now,
|
45
|
+
const SessionID &sessionID,
|
46
|
+
const std::string &user,
|
47
|
+
const std::string &password,
|
48
|
+
const std::string &connectionString)
|
49
|
+
: m_cache(now),
|
50
|
+
m_sessionID(sessionID) {
|
51
|
+
m_pConnection = new OdbcConnection(user, password, connectionString);
|
52
|
+
populateCache();
|
53
|
+
}
|
54
|
+
|
55
|
+
OdbcStore::~OdbcStore() { delete m_pConnection; }
|
56
|
+
|
57
|
+
void OdbcStore::populateCache() {
|
58
|
+
std::stringstream queryString;
|
59
|
+
|
60
|
+
queryString << "SELECT creation_time, incoming_seqnum, outgoing_seqnum FROM sessions WHERE "
|
61
|
+
<< "beginstring=" << "'" << m_sessionID.getBeginString().getValue() << "' and "
|
62
|
+
<< "sendercompid=" << "'" << m_sessionID.getSenderCompID().getValue() << "' and "
|
63
|
+
<< "targetcompid=" << "'" << m_sessionID.getTargetCompID().getValue() << "' and "
|
64
|
+
<< "session_qualifier=" << "'" << m_sessionID.getSessionQualifier() << "'";
|
65
|
+
|
66
|
+
OdbcQuery query(queryString.str());
|
67
|
+
|
68
|
+
if (!m_pConnection->execute(query)) {
|
69
|
+
throw ConfigError("Unable to query sessions table");
|
70
|
+
}
|
71
|
+
|
72
|
+
int rows = 0;
|
73
|
+
while (query.fetch()) {
|
74
|
+
rows++;
|
75
|
+
if (rows > 1) {
|
76
|
+
throw ConfigError("Multiple entries found for session in database");
|
77
|
+
}
|
78
|
+
|
79
|
+
SQL_TIMESTAMP_STRUCT creationTime;
|
80
|
+
SQLLEN creationTimeLength;
|
81
|
+
SQLGetData(query.statement(), 1, SQL_C_TYPE_TIMESTAMP, &creationTime, 0, &creationTimeLength);
|
82
|
+
SQLUBIGINT incomingSeqNum;
|
83
|
+
SQLLEN incomingSeqNumLength;
|
84
|
+
SQLGetData(query.statement(), 2, SQL_C_UBIGINT, &incomingSeqNum, 0, &incomingSeqNumLength);
|
85
|
+
|
86
|
+
SQLUBIGINT outgoingSeqNum;
|
87
|
+
SQLLEN outgoingSeqNumLength;
|
88
|
+
SQLGetData(query.statement(), 3, SQL_C_UBIGINT, &outgoingSeqNum, 0, &outgoingSeqNumLength);
|
89
|
+
|
90
|
+
UtcTimeStamp time = UtcTimeStamp::now();
|
91
|
+
time.setYMD(creationTime.year, creationTime.month, creationTime.day);
|
92
|
+
time.setHMS(creationTime.hour, creationTime.minute, creationTime.second, creationTime.fraction);
|
93
|
+
m_cache.setCreationTime(time);
|
94
|
+
m_cache.setNextTargetMsgSeqNum(incomingSeqNum);
|
95
|
+
m_cache.setNextSenderMsgSeqNum(outgoingSeqNum);
|
96
|
+
}
|
97
|
+
query.close();
|
98
|
+
|
99
|
+
if (rows == 0) {
|
100
|
+
UtcTimeStamp time = m_cache.getCreationTime();
|
101
|
+
char sqlTime[100];
|
102
|
+
int year, month, day, hour, minute, second, millis;
|
103
|
+
time.getYMD(year, month, day);
|
104
|
+
time.getHMS(hour, minute, second, millis);
|
105
|
+
STRING_SPRINTF(sqlTime, "%d-%02d-%02d %02d:%02d:%02d", year, month, day, hour, minute, second);
|
106
|
+
std::stringstream queryString2;
|
107
|
+
queryString2 << "INSERT INTO sessions (beginstring, sendercompid, targetcompid, session_qualifier,"
|
108
|
+
<< "creation_time, incoming_seqnum, outgoing_seqnum) VALUES("
|
109
|
+
<< "'" << m_sessionID.getBeginString().getValue() << "',"
|
110
|
+
<< "'" << m_sessionID.getSenderCompID().getValue() << "',"
|
111
|
+
<< "'" << m_sessionID.getTargetCompID().getValue() << "',"
|
112
|
+
<< "'" << m_sessionID.getSessionQualifier() << "',"
|
113
|
+
<< "{ts '" << sqlTime << "'}," << m_cache.getNextTargetMsgSeqNum() << ","
|
114
|
+
<< m_cache.getNextSenderMsgSeqNum() << ")";
|
115
|
+
|
116
|
+
OdbcQuery query2(queryString2.str());
|
117
|
+
if (!m_pConnection->execute(query2)) {
|
118
|
+
throw ConfigError("Unable to create session in database");
|
119
|
+
}
|
120
|
+
}
|
121
|
+
}
|
122
|
+
|
123
|
+
MessageStore *OdbcStoreFactory::create(const UtcTimeStamp &now, const SessionID &sessionID) {
|
124
|
+
if (m_useSettings) {
|
125
|
+
return create(now, sessionID, m_settings.get(sessionID));
|
126
|
+
} else if (m_useDictionary) {
|
127
|
+
return create(now, sessionID, m_dictionary);
|
128
|
+
} else {
|
129
|
+
return new OdbcStore(now, sessionID, m_user, m_password, m_connectionString);
|
130
|
+
}
|
131
|
+
}
|
132
|
+
|
133
|
+
void OdbcStoreFactory::destroy(MessageStore *pStore) { delete pStore; }
|
134
|
+
|
135
|
+
MessageStore *OdbcStoreFactory::create(
|
136
|
+
const UtcTimeStamp &now,
|
137
|
+
const SessionID &sessionID,
|
138
|
+
const Dictionary &settings) {
|
139
|
+
std::string user = DEFAULT_USER;
|
140
|
+
std::string password = DEFAULT_PASSWORD;
|
141
|
+
std::string connectionString = DEFAULT_CONNECTION_STRING;
|
142
|
+
|
143
|
+
try {
|
144
|
+
user = settings.getString(ODBC_STORE_USER);
|
145
|
+
} catch (ConfigError &) {}
|
146
|
+
|
147
|
+
try {
|
148
|
+
password = settings.getString(ODBC_STORE_PASSWORD);
|
149
|
+
} catch (ConfigError &) {}
|
150
|
+
|
151
|
+
try {
|
152
|
+
connectionString = settings.getString(ODBC_STORE_CONNECTION_STRING);
|
153
|
+
} catch (ConfigError &) {}
|
154
|
+
|
155
|
+
return new OdbcStore(now, sessionID, user, password, connectionString);
|
156
|
+
}
|
157
|
+
|
158
|
+
bool OdbcStore::set(SEQNUM msgSeqNum, const std::string &msg) EXCEPT(IOException) {
|
159
|
+
std::string msgCopy = msg;
|
160
|
+
string_replace("'", "''", msgCopy);
|
161
|
+
|
162
|
+
std::stringstream queryString;
|
163
|
+
queryString << "INSERT INTO messages "
|
164
|
+
<< "(beginstring, sendercompid, targetcompid, session_qualifier, msgseqnum, message) "
|
165
|
+
<< "VALUES ("
|
166
|
+
<< "'" << m_sessionID.getBeginString().getValue() << "',"
|
167
|
+
<< "'" << m_sessionID.getSenderCompID().getValue() << "',"
|
168
|
+
<< "'" << m_sessionID.getTargetCompID().getValue() << "',"
|
169
|
+
<< "'" << m_sessionID.getSessionQualifier() << "'," << msgSeqNum << ","
|
170
|
+
<< "'" << msgCopy << "')";
|
171
|
+
|
172
|
+
OdbcQuery query(queryString.str());
|
173
|
+
if (!m_pConnection->execute(query)) {
|
174
|
+
query.close();
|
175
|
+
std::stringstream queryString2;
|
176
|
+
queryString2 << "UPDATE messages SET message='" << msgCopy << "' WHERE "
|
177
|
+
<< "beginstring=" << "'" << m_sessionID.getBeginString().getValue() << "' and "
|
178
|
+
<< "sendercompid=" << "'" << m_sessionID.getSenderCompID().getValue() << "' and "
|
179
|
+
<< "targetcompid=" << "'" << m_sessionID.getTargetCompID().getValue() << "' and "
|
180
|
+
<< "session_qualifier=" << "'" << m_sessionID.getSessionQualifier() << "' and "
|
181
|
+
<< "msgseqnum=" << msgSeqNum;
|
182
|
+
OdbcQuery query2(queryString2.str());
|
183
|
+
if (!m_pConnection->execute(query2)) {
|
184
|
+
query2.throwException();
|
185
|
+
}
|
186
|
+
}
|
187
|
+
return true;
|
188
|
+
}
|
189
|
+
|
190
|
+
void OdbcStore::get(SEQNUM begin, SEQNUM end, std::vector<std::string> &result) const EXCEPT(IOException) {
|
191
|
+
result.clear();
|
192
|
+
std::stringstream queryString;
|
193
|
+
queryString << "SELECT message FROM messages WHERE "
|
194
|
+
<< "beginstring=" << "'" << m_sessionID.getBeginString().getValue() << "' and "
|
195
|
+
<< "sendercompid=" << "'" << m_sessionID.getSenderCompID().getValue() << "' and "
|
196
|
+
<< "targetcompid=" << "'" << m_sessionID.getTargetCompID().getValue() << "' and "
|
197
|
+
<< "session_qualifier=" << "'" << m_sessionID.getSessionQualifier() << "' and "
|
198
|
+
<< "msgseqnum>=" << begin << " and " << "msgseqnum<=" << end << " "
|
199
|
+
<< "ORDER BY msgseqnum";
|
200
|
+
|
201
|
+
OdbcQuery query(queryString.str());
|
202
|
+
|
203
|
+
if (!m_pConnection->execute(query)) {
|
204
|
+
query.throwException();
|
205
|
+
}
|
206
|
+
|
207
|
+
while (query.fetch()) {
|
208
|
+
std::string message;
|
209
|
+
SQLVARCHAR messageBuffer[4096];
|
210
|
+
SQLLEN messageLength;
|
211
|
+
|
212
|
+
while (odbcSuccess(SQLGetData(query.statement(), 1, SQL_C_CHAR, &messageBuffer, 4095, &messageLength))) {
|
213
|
+
messageBuffer[messageLength] = 0;
|
214
|
+
message += (char *)messageBuffer;
|
215
|
+
}
|
216
|
+
|
217
|
+
result.push_back(message);
|
218
|
+
}
|
219
|
+
}
|
220
|
+
|
221
|
+
SEQNUM OdbcStore::getNextSenderMsgSeqNum() const EXCEPT(IOException) { return m_cache.getNextSenderMsgSeqNum(); }
|
222
|
+
|
223
|
+
SEQNUM OdbcStore::getNextTargetMsgSeqNum() const EXCEPT(IOException) { return m_cache.getNextTargetMsgSeqNum(); }
|
224
|
+
|
225
|
+
void OdbcStore::setNextSenderMsgSeqNum(SEQNUM value) EXCEPT(IOException) {
|
226
|
+
std::stringstream queryString;
|
227
|
+
queryString << "UPDATE sessions SET outgoing_seqnum=" << value << " WHERE "
|
228
|
+
<< "beginstring=" << "'" << m_sessionID.getBeginString().getValue() << "' and "
|
229
|
+
<< "sendercompid=" << "'" << m_sessionID.getSenderCompID().getValue() << "' and "
|
230
|
+
<< "targetcompid=" << "'" << m_sessionID.getTargetCompID().getValue() << "' and "
|
231
|
+
<< "session_qualifier=" << "'" << m_sessionID.getSessionQualifier() << "'";
|
232
|
+
OdbcQuery query(queryString.str());
|
233
|
+
if (!m_pConnection->execute(query)) {
|
234
|
+
query.throwException();
|
235
|
+
}
|
236
|
+
m_cache.setNextSenderMsgSeqNum(value);
|
237
|
+
}
|
238
|
+
|
239
|
+
void OdbcStore::setNextTargetMsgSeqNum(SEQNUM value) EXCEPT(IOException) {
|
240
|
+
std::stringstream queryString;
|
241
|
+
queryString << "UPDATE sessions SET incoming_seqnum=" << value << " WHERE "
|
242
|
+
<< "beginstring=" << "'" << m_sessionID.getBeginString().getValue() << "' and "
|
243
|
+
<< "sendercompid=" << "'" << m_sessionID.getSenderCompID().getValue() << "' and "
|
244
|
+
<< "targetcompid=" << "'" << m_sessionID.getTargetCompID().getValue() << "' and "
|
245
|
+
<< "session_qualifier=" << "'" << m_sessionID.getSessionQualifier() << "'";
|
246
|
+
|
247
|
+
OdbcQuery query(queryString.str());
|
248
|
+
if (!m_pConnection->execute(query)) {
|
249
|
+
query.throwException();
|
250
|
+
}
|
251
|
+
|
252
|
+
m_cache.setNextTargetMsgSeqNum(value);
|
253
|
+
}
|
254
|
+
|
255
|
+
void OdbcStore::incrNextSenderMsgSeqNum() EXCEPT(IOException) {
|
256
|
+
m_cache.incrNextSenderMsgSeqNum();
|
257
|
+
setNextSenderMsgSeqNum(m_cache.getNextSenderMsgSeqNum());
|
258
|
+
}
|
259
|
+
|
260
|
+
void OdbcStore::incrNextTargetMsgSeqNum() EXCEPT(IOException) {
|
261
|
+
m_cache.incrNextTargetMsgSeqNum();
|
262
|
+
setNextTargetMsgSeqNum(m_cache.getNextTargetMsgSeqNum());
|
263
|
+
}
|
264
|
+
|
265
|
+
UtcTimeStamp OdbcStore::getCreationTime() const EXCEPT(IOException) { return m_cache.getCreationTime(); }
|
266
|
+
|
267
|
+
void OdbcStore::reset(const UtcTimeStamp &now) EXCEPT(IOException) {
|
268
|
+
std::stringstream queryString;
|
269
|
+
queryString << "DELETE FROM messages WHERE "
|
270
|
+
<< "beginstring=" << "'" << m_sessionID.getBeginString().getValue() << "' and "
|
271
|
+
<< "sendercompid=" << "'" << m_sessionID.getSenderCompID().getValue() << "' and "
|
272
|
+
<< "targetcompid=" << "'" << m_sessionID.getTargetCompID().getValue() << "' and "
|
273
|
+
<< "session_qualifier=" << "'" << m_sessionID.getSessionQualifier() << "'";
|
274
|
+
|
275
|
+
OdbcQuery query(queryString.str());
|
276
|
+
if (!m_pConnection->execute(query)) {
|
277
|
+
query.throwException();
|
278
|
+
}
|
279
|
+
query.close();
|
280
|
+
|
281
|
+
m_cache.reset(now);
|
282
|
+
UtcTimeStamp time = m_cache.getCreationTime();
|
283
|
+
|
284
|
+
int year, month, day, hour, minute, second, millis;
|
285
|
+
time.getYMD(year, month, day);
|
286
|
+
time.getHMS(hour, minute, second, millis);
|
287
|
+
|
288
|
+
char sqlTime[100];
|
289
|
+
STRING_SPRINTF(sqlTime, "%d-%02d-%02d %02d:%02d:%02d", year, month, day, hour, minute, second);
|
290
|
+
|
291
|
+
std::stringstream queryString2;
|
292
|
+
queryString2 << "UPDATE sessions SET creation_time={ts '" << sqlTime << "'}, "
|
293
|
+
<< "incoming_seqnum=" << m_cache.getNextTargetMsgSeqNum() << ", "
|
294
|
+
<< "outgoing_seqnum=" << m_cache.getNextSenderMsgSeqNum() << " 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 query2(queryString2.str());
|
301
|
+
if (!m_pConnection->execute(query2)) {
|
302
|
+
query2.throwException();
|
303
|
+
}
|
304
|
+
}
|
305
|
+
|
306
|
+
void OdbcStore::refresh() EXCEPT(IOException) {
|
307
|
+
m_cache.reset(UtcTimeStamp::now());
|
308
|
+
populateCache();
|
309
|
+
}
|
310
|
+
|
311
|
+
} // namespace FIX
|
312
|
+
|
313
|
+
#endif
|
@@ -0,0 +1,124 @@
|
|
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 "MessageStore.h"
|
35
|
+
#include "OdbcConnection.h"
|
36
|
+
#include "SessionSettings.h"
|
37
|
+
#include <fstream>
|
38
|
+
#include <string>
|
39
|
+
|
40
|
+
namespace FIX {
|
41
|
+
/// Creates a Odbc based implementation of MessageStore.
|
42
|
+
class OdbcStoreFactory : public MessageStoreFactory {
|
43
|
+
public:
|
44
|
+
static const std::string DEFAULT_USER;
|
45
|
+
static const std::string DEFAULT_PASSWORD;
|
46
|
+
static const std::string DEFAULT_CONNECTION_STRING;
|
47
|
+
|
48
|
+
OdbcStoreFactory(const SessionSettings &settings)
|
49
|
+
: m_settings(settings),
|
50
|
+
m_useSettings(true),
|
51
|
+
m_useDictionary(false) {}
|
52
|
+
|
53
|
+
OdbcStoreFactory(const Dictionary &dictionary)
|
54
|
+
: m_dictionary(dictionary),
|
55
|
+
m_useSettings(false),
|
56
|
+
m_useDictionary(true) {}
|
57
|
+
|
58
|
+
OdbcStoreFactory(const std::string &user, const std::string &password, const std::string &connectionString)
|
59
|
+
: m_user(user),
|
60
|
+
m_password(password),
|
61
|
+
m_connectionString(connectionString),
|
62
|
+
m_useSettings(false),
|
63
|
+
m_useDictionary(false) {}
|
64
|
+
|
65
|
+
OdbcStoreFactory()
|
66
|
+
: m_user(DEFAULT_USER),
|
67
|
+
m_password(DEFAULT_PASSWORD),
|
68
|
+
m_connectionString(DEFAULT_CONNECTION_STRING),
|
69
|
+
m_useSettings(false),
|
70
|
+
m_useDictionary(false) {}
|
71
|
+
|
72
|
+
MessageStore *create(const UtcTimeStamp &, const SessionID &);
|
73
|
+
void destroy(MessageStore *);
|
74
|
+
|
75
|
+
private:
|
76
|
+
MessageStore *create(const UtcTimeStamp &, const SessionID &sessionID, const Dictionary &);
|
77
|
+
|
78
|
+
Dictionary m_dictionary;
|
79
|
+
SessionSettings m_settings;
|
80
|
+
std::string m_user;
|
81
|
+
std::string m_password;
|
82
|
+
std::string m_connectionString;
|
83
|
+
bool m_useSettings;
|
84
|
+
bool m_useDictionary;
|
85
|
+
};
|
86
|
+
/*! @} */
|
87
|
+
|
88
|
+
/// Odbc based implementation of MessageStore.
|
89
|
+
class OdbcStore : public MessageStore {
|
90
|
+
public:
|
91
|
+
OdbcStore(
|
92
|
+
const UtcTimeStamp &now,
|
93
|
+
const SessionID &sessionID,
|
94
|
+
const std::string &user,
|
95
|
+
const std::string &password,
|
96
|
+
const std::string &connectionString);
|
97
|
+
~OdbcStore();
|
98
|
+
|
99
|
+
bool set(SEQNUM, const std::string &) EXCEPT(IOException);
|
100
|
+
void get(SEQNUM, SEQNUM, std::vector<std::string> &) const EXCEPT(IOException);
|
101
|
+
|
102
|
+
SEQNUM getNextSenderMsgSeqNum() const EXCEPT(IOException);
|
103
|
+
SEQNUM getNextTargetMsgSeqNum() const EXCEPT(IOException);
|
104
|
+
void setNextSenderMsgSeqNum(SEQNUM value) EXCEPT(IOException);
|
105
|
+
void setNextTargetMsgSeqNum(SEQNUM value) EXCEPT(IOException);
|
106
|
+
void incrNextSenderMsgSeqNum() EXCEPT(IOException);
|
107
|
+
void incrNextTargetMsgSeqNum() EXCEPT(IOException);
|
108
|
+
|
109
|
+
UtcTimeStamp getCreationTime() const EXCEPT(IOException);
|
110
|
+
|
111
|
+
void reset(const UtcTimeStamp &now) EXCEPT(IOException);
|
112
|
+
void refresh() EXCEPT(IOException);
|
113
|
+
|
114
|
+
private:
|
115
|
+
void populateCache();
|
116
|
+
|
117
|
+
MemoryStore m_cache;
|
118
|
+
SessionID m_sessionID;
|
119
|
+
OdbcConnection *m_pConnection;
|
120
|
+
};
|
121
|
+
} // namespace FIX
|
122
|
+
|
123
|
+
#endif
|
124
|
+
#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() EXCEPT ( 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_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() EXCEPT ( 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
|