quickfix_ruby_ud 2.0.7-x86_64-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,260 @@
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_SESSIONSTATE_H
23
+ #define FIX_SESSIONSTATE_H
24
+
25
+ #ifdef _MSC_VER
26
+ #pragma warning(disable : 4503 4355 4786 4290)
27
+ #endif
28
+
29
+ #include "FieldTypes.h"
30
+ #include "Log.h"
31
+ #include "MessageStore.h"
32
+ #include "Mutex.h"
33
+
34
+ namespace FIX {
35
+ /// Maintains all of state for the Session class.
36
+ class SessionState : public MessageStore, public Log {
37
+ typedef std::map<SEQNUM, Message> Messages;
38
+
39
+ public:
40
+ SessionState(const UtcTimeStamp &now)
41
+ : m_enabled(true),
42
+ m_receivedLogon(false),
43
+ m_sentLogout(false),
44
+ m_sentLogon(false),
45
+ m_sentReset(false),
46
+ m_receivedReset(false),
47
+ m_initiate(false),
48
+ m_logonTimeout(10),
49
+ m_logoutTimeout(2),
50
+ m_testRequest(0),
51
+ m_lastSentTime(now),
52
+ m_lastReceivedTime(now),
53
+ m_pStore(0),
54
+ m_pLog(0) {}
55
+
56
+ bool enabled() const { return m_enabled; }
57
+ void enabled(bool value) { m_enabled = value; }
58
+
59
+ bool receivedLogon() const { return m_receivedLogon; }
60
+ void receivedLogon(bool value) { m_receivedLogon = value; }
61
+
62
+ bool sentLogout() const { return m_sentLogout; }
63
+ void sentLogout(bool value) { m_sentLogout = value; }
64
+
65
+ bool sentLogon() const { return m_sentLogon; }
66
+ void sentLogon(bool value) { m_sentLogon = value; }
67
+
68
+ bool receivedReset() const { return m_receivedReset; }
69
+ void receivedReset(bool value) { m_receivedReset = value; }
70
+
71
+ bool sentReset() const { return m_sentReset; }
72
+ void sentReset(bool value) { m_sentReset = value; }
73
+
74
+ bool initiate() const { return m_initiate; }
75
+ void initiate(bool value) { m_initiate = value; }
76
+
77
+ int logonTimeout() const { return m_logonTimeout; }
78
+ void logonTimeout(int value) { m_logonTimeout = value; }
79
+
80
+ int logoutTimeout() const { return m_logoutTimeout; }
81
+ void logoutTimeout(int value) { m_logoutTimeout = value; }
82
+
83
+ int testRequest() const { return m_testRequest; }
84
+ void testRequest(int value) { m_testRequest = value; }
85
+
86
+ bool resendRequested() const { return !(m_resendRange.first == 0 && m_resendRange.second == 0); }
87
+
88
+ typedef std::pair<SEQNUM, SEQNUM> ResendRange;
89
+
90
+ ResendRange resendRange() const { return m_resendRange; }
91
+ void resendRange(SEQNUM begin, SEQNUM end) { m_resendRange = std::make_pair(begin, end); }
92
+
93
+ MessageStore *store() { return m_pStore; }
94
+ void store(MessageStore *pValue) { m_pStore = pValue; }
95
+ Log *log() { return m_pLog ? m_pLog : &m_nullLog; }
96
+ void log(Log *pValue) { m_pLog = pValue; }
97
+
98
+ void heartBtInt(const HeartBtInt &value) { m_heartBtInt = value; }
99
+ HeartBtInt &heartBtInt() { return m_heartBtInt; }
100
+ const HeartBtInt &heartBtInt() const { return m_heartBtInt; }
101
+
102
+ void lastSentTime(const UtcTimeStamp &value) { m_lastSentTime = value; }
103
+ UtcTimeStamp &lastSentTime() { return m_lastSentTime; }
104
+ const UtcTimeStamp &lastSentTime() const { return m_lastSentTime; }
105
+
106
+ void lastReceivedTime(const UtcTimeStamp &value) { m_lastReceivedTime = value; }
107
+ UtcTimeStamp &lastReceivedTime() { return m_lastReceivedTime; }
108
+ const UtcTimeStamp &lastReceivedTime() const { return m_lastReceivedTime; }
109
+
110
+ bool shouldSendLogon() const { return initiate() && !sentLogon(); }
111
+ bool alreadySentLogon() const { return initiate() && sentLogon(); }
112
+ bool logonTimedOut(const UtcTimeStamp &now) const { return now - lastReceivedTime() >= logonTimeout(); }
113
+ bool logoutTimedOut(const UtcTimeStamp &now) const {
114
+ return sentLogout() && ((now - lastSentTime()) >= logoutTimeout());
115
+ }
116
+ bool withinHeartBeat(const UtcTimeStamp &now) const {
117
+ return ((now - lastSentTime()) < heartBtInt()) && ((now - lastReceivedTime()) < heartBtInt());
118
+ }
119
+ bool timedOut(const UtcTimeStamp &now) const { return (now - lastReceivedTime()) >= (2.4 * (double)heartBtInt()); }
120
+ bool needHeartbeat(const UtcTimeStamp &now) const {
121
+ return ((now - lastSentTime()) >= heartBtInt()) && !testRequest();
122
+ }
123
+ bool needTestRequest(const UtcTimeStamp &now) const {
124
+ return (now - lastReceivedTime()) >= ((1.2 * ((double)testRequest() + 1)) * (double)heartBtInt());
125
+ }
126
+
127
+ std::string logoutReason() const {
128
+ Locker l(m_mutex);
129
+ return m_logoutReason;
130
+ }
131
+ void logoutReason(const std::string &value) {
132
+ Locker l(m_mutex);
133
+ m_logoutReason = value;
134
+ }
135
+
136
+ void queue(SEQNUM msgSeqNum, const Message &message) {
137
+ Locker l(m_mutex);
138
+ m_queue[msgSeqNum] = message;
139
+ }
140
+ bool retrieve(SEQNUM msgSeqNum, Message &message) {
141
+ Locker l(m_mutex);
142
+ Messages::iterator i = m_queue.find(msgSeqNum);
143
+ if (i != m_queue.end()) {
144
+ message = i->second;
145
+ m_queue.erase(i);
146
+ return true;
147
+ }
148
+ return false;
149
+ }
150
+ void clearQueue() {
151
+ Locker l(m_mutex);
152
+ m_queue.clear();
153
+ }
154
+
155
+ bool set(SEQNUM s, const std::string &m) EXCEPT(IOException) {
156
+ Locker l(m_mutex);
157
+ return m_pStore->set(s, m);
158
+ }
159
+ void get(SEQNUM b, SEQNUM e, std::vector<std::string> &m) const EXCEPT(IOException) {
160
+ Locker l(m_mutex);
161
+ m_pStore->get(b, e, m);
162
+ }
163
+ SEQNUM getNextSenderMsgSeqNum() const EXCEPT(IOException) {
164
+ Locker l(m_mutex);
165
+ return m_pStore->getNextSenderMsgSeqNum();
166
+ }
167
+ SEQNUM getNextTargetMsgSeqNum() const EXCEPT(IOException) {
168
+ Locker l(m_mutex);
169
+ return m_pStore->getNextTargetMsgSeqNum();
170
+ }
171
+ void setNextSenderMsgSeqNum(SEQNUM n) EXCEPT(IOException) {
172
+ Locker l(m_mutex);
173
+ m_pStore->setNextSenderMsgSeqNum(n);
174
+ }
175
+ void setNextTargetMsgSeqNum(SEQNUM n) EXCEPT(IOException) {
176
+ Locker l(m_mutex);
177
+ m_pStore->setNextTargetMsgSeqNum(n);
178
+ }
179
+ void incrNextSenderMsgSeqNum() EXCEPT(IOException) {
180
+ Locker l(m_mutex);
181
+ m_pStore->incrNextSenderMsgSeqNum();
182
+ }
183
+ void incrNextTargetMsgSeqNum() EXCEPT(IOException) {
184
+ Locker l(m_mutex);
185
+ m_pStore->incrNextTargetMsgSeqNum();
186
+ }
187
+ UtcTimeStamp getCreationTime() const EXCEPT(IOException) {
188
+ Locker l(m_mutex);
189
+ return m_pStore->getCreationTime();
190
+ }
191
+ void reset(const UtcTimeStamp &now) EXCEPT(IOException) {
192
+ Locker l(m_mutex);
193
+ m_pStore->reset(now);
194
+ }
195
+ void refresh() EXCEPT(IOException) {
196
+ Locker l(m_mutex);
197
+ m_pStore->refresh();
198
+ }
199
+
200
+ void clear() {
201
+ if (!m_pLog) {
202
+ return;
203
+ }
204
+ Locker l(m_mutex);
205
+ m_pLog->clear();
206
+ }
207
+ void backup() {
208
+ if (!m_pLog) {
209
+ return;
210
+ }
211
+ Locker l(m_mutex);
212
+ m_pLog->backup();
213
+ }
214
+ void onIncoming(const std::string &string) {
215
+ if (!m_pLog) {
216
+ return;
217
+ }
218
+ Locker l(m_mutex);
219
+ m_pLog->onIncoming(string);
220
+ }
221
+ void onOutgoing(const std::string &string) {
222
+ if (!m_pLog) {
223
+ return;
224
+ }
225
+ Locker l(m_mutex);
226
+ m_pLog->onOutgoing(string);
227
+ }
228
+ void onEvent(const std::string &string) {
229
+ if (!m_pLog) {
230
+ return;
231
+ }
232
+ Locker l(m_mutex);
233
+ m_pLog->onEvent(string);
234
+ }
235
+
236
+ private:
237
+ bool m_enabled;
238
+ bool m_receivedLogon;
239
+ bool m_sentLogout;
240
+ bool m_sentLogon;
241
+ bool m_sentReset;
242
+ bool m_receivedReset;
243
+ bool m_initiate;
244
+ int m_logonTimeout;
245
+ int m_logoutTimeout;
246
+ int m_testRequest;
247
+ ResendRange m_resendRange;
248
+ HeartBtInt m_heartBtInt;
249
+ UtcTimeStamp m_lastSentTime;
250
+ UtcTimeStamp m_lastReceivedTime;
251
+ std::string m_logoutReason;
252
+ Messages m_queue;
253
+ MessageStore *m_pStore;
254
+ Log *m_pLog;
255
+ NullLog m_nullLog;
256
+ mutable Mutex m_mutex;
257
+ };
258
+ } // namespace FIX
259
+
260
+ #endif // FIX_SESSIONSTATE_H
@@ -0,0 +1,160 @@
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 "Settings.h"
27
+ #include <cstring>
28
+
29
+ namespace FIX {
30
+ bool isComment(const std::string &line) {
31
+ if (line.size() == 0) {
32
+ return false;
33
+ }
34
+
35
+ return line[0] == '#';
36
+ }
37
+
38
+ bool isSection(const std::string &line) {
39
+ if (line.size() == 0) {
40
+ return false;
41
+ }
42
+
43
+ return line[0] == '[' && line[line.size() - 1] == ']';
44
+ }
45
+
46
+ std::string splitSection(const std::string &line) { return string_strip(std::string(line, 1, line.size() - 2)); }
47
+
48
+ bool isKeyValue(const std::string &line) { return line.find('=') != std::string::npos; }
49
+
50
+ std::pair<std::string, std::string> splitKeyValue(const std::string &line) {
51
+ size_t equals = line.find('=');
52
+ std::string key = std::string(line, 0, equals);
53
+ std::string value = std::string(line, equals + 1, std::string::npos);
54
+ return std::pair<std::string, std::string>(key, value);
55
+ }
56
+
57
+ std::string resolveEnvVars(const std::string &str) {
58
+ std::string resultStr;
59
+ size_t actPos = 0;
60
+ size_t sourceLen = str.length();
61
+
62
+ while (actPos < sourceLen) {
63
+ char c = str[actPos++];
64
+ if (actPos < sourceLen) {
65
+ // escape character
66
+ if (c == '\\') {
67
+ c = str[actPos++];
68
+ switch (c) {
69
+ case 't':
70
+ resultStr.append(1, '\t');
71
+ break;
72
+ case 'r':
73
+ resultStr.append(1, '\r');
74
+ break;
75
+ case 'n':
76
+ resultStr.append(1, '\n');
77
+ break;
78
+ default:
79
+ resultStr.append(1, c);
80
+ break;
81
+ }
82
+ continue;
83
+ }
84
+
85
+ // variable substitution
86
+ if (c == '$') {
87
+ bool inBraces = false;
88
+ c = str[actPos++];
89
+ if ((c == '(') || (c == '{')) {
90
+ c = str[actPos++];
91
+ inBraces = true;
92
+ }
93
+
94
+ // actPos now points at start of var name
95
+ if (actPos >= sourceLen) {
96
+ break;
97
+ }
98
+ std::string varName;
99
+ while ((actPos <= sourceLen)) {
100
+ varName.append(1, c); // this must be done before overwriting c
101
+ c = str[actPos++];
102
+ if (std::strchr(" /:;,.=\"'?#+*()[]{}$&%\t\n", c)) {
103
+ break;
104
+ }
105
+ }
106
+ if (inBraces && (actPos <= sourceLen) && ((c == ')') || (c == '}')))
107
+ ;
108
+ else {
109
+ --actPos;
110
+ }
111
+ // varName contains the name of the variable,
112
+ // actPos points to first char _after_ variable
113
+ const char *varValue = 0;
114
+ if (!varName.empty() && (0 != (varValue = getenv(varName.c_str())))) {
115
+ resultStr.append(varValue);
116
+ }
117
+ continue;
118
+ }
119
+ }
120
+
121
+ // nothing special, just copy
122
+ resultStr.append(1, c);
123
+ }
124
+
125
+ return resultStr;
126
+ }
127
+
128
+ std::istream &operator>>(std::istream &stream, Settings &s) {
129
+ char buffer[1024];
130
+ std::string line;
131
+ Settings::Sections::iterator section = s.m_sections.end();
132
+ ;
133
+
134
+ while (stream.getline(buffer, sizeof(buffer))) {
135
+ line = string_strip(buffer);
136
+ if (isComment(line)) {
137
+ continue;
138
+ } else if (isSection(line)) {
139
+ section = s.m_sections.insert(s.m_sections.end(), Dictionary(splitSection(line)));
140
+ } else if (isKeyValue(line)) {
141
+ std::pair<std::string, std::string> keyValue = splitKeyValue(line);
142
+ if (section == s.m_sections.end()) {
143
+ continue;
144
+ }
145
+ (*section).setString(keyValue.first, s.m_resolveEnvVars ? resolveEnvVars(keyValue.second) : keyValue.second);
146
+ }
147
+ }
148
+ return stream;
149
+ }
150
+
151
+ Settings::Sections Settings::get(const std::string &name) const {
152
+ Sections sections;
153
+ for (Sections::size_type i = 0; i < m_sections.size(); ++i) {
154
+ if (m_sections[i].getName() == name) {
155
+ sections.push_back(m_sections[i]);
156
+ }
157
+ }
158
+ return sections;
159
+ }
160
+ } // namespace FIX
@@ -0,0 +1,56 @@
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_SETTINGS_H
23
+ #define FIX_SETTINGS_H
24
+
25
+ #ifdef _MSC_VER
26
+ #pragma warning(disable : 4503 4355 4786 4290)
27
+ #endif
28
+
29
+ #include "Dictionary.h"
30
+ #include <iostream>
31
+ #include <map>
32
+ #include <string>
33
+ #include <vector>
34
+
35
+ namespace FIX {
36
+ /// Internal representation of QuickFIX configuration settings.
37
+ class Settings {
38
+ public:
39
+ Settings(bool resolveEnvVars = false)
40
+ : m_resolveEnvVars(resolveEnvVars) {}
41
+
42
+ typedef std::vector<Dictionary> Sections;
43
+
44
+ Sections get(const std::string &name) const;
45
+
46
+ friend std::istream &operator>>(std::istream &, Settings &);
47
+
48
+ private:
49
+ Sections m_sections;
50
+ bool m_resolveEnvVars;
51
+ };
52
+
53
+ std::istream &operator>>(std::istream &, Settings &);
54
+ } // namespace FIX
55
+
56
+ #endif // FIX_SETTINGS_H