quickfix_ruby_ud 2.0.7

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 (196) 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/quickfix40.rb +274 -0
  171. data/lib/quickfix41.rb +351 -0
  172. data/lib/quickfix42.rb +1184 -0
  173. data/lib/quickfix43.rb +3504 -0
  174. data/lib/quickfix44.rb +14040 -0
  175. data/lib/quickfix50.rb +20051 -0
  176. data/lib/quickfix50sp1.rb +23596 -0
  177. data/lib/quickfix50sp2.rb +412444 -0
  178. data/lib/quickfix_fields.rb +79393 -0
  179. data/lib/quickfix_ruby.rb +82 -0
  180. data/lib/quickfixt11.rb +65 -0
  181. data/spec/FIX40.xml +862 -0
  182. data/spec/FIX41.xml +1282 -0
  183. data/spec/FIX42.xml +2743 -0
  184. data/spec/FIX43.xml +4230 -0
  185. data/spec/FIX44.xml +6600 -0
  186. data/spec/FIX50.xml +8142 -0
  187. data/spec/FIX50SP1.xml +9506 -0
  188. data/spec/FIX50SP2.xml +26069 -0
  189. data/spec/FIXT11.xml +252 -0
  190. data/test/DataDictionaryTestCase.rb +268 -0
  191. data/test/DictionaryTestCase.rb +112 -0
  192. data/test/FieldBaseTestCase.rb +24 -0
  193. data/test/MessageStoreTestCase.rb +19 -0
  194. data/test/MessageTestCase.rb +368 -0
  195. data/test/SessionSettingsTestCase.rb +41 -0
  196. metadata +236 -0
@@ -0,0 +1,84 @@
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_SESSIONFACTORY_H
23
+ #define FIX_SESSIONFACTORY_H
24
+
25
+ #ifdef _MSC_VER
26
+ #pragma warning(disable : 4503 4355 4786 4290)
27
+ #endif
28
+
29
+ #include "Dictionary.h"
30
+ #include "Exceptions.h"
31
+ #include "Log.h"
32
+
33
+ namespace FIX {
34
+ class SessionID;
35
+ class Session;
36
+ class Application;
37
+ class MessageStoreFactory;
38
+ class DataDictionaryProvider;
39
+
40
+ /** Responsible for creating Session objects. This factory will use
41
+ * QuickFIX SessionID, Dictionary settings, MessageStoreFactory, and
42
+ * optional LogFactory to create all the required sessions for an
43
+ * Application.
44
+ */
45
+ class SessionFactory {
46
+ public:
47
+ SessionFactory(Application &application, MessageStoreFactory &messageStoreFactory, LogFactory *pLogFactory)
48
+ : m_application(application),
49
+ m_messageStoreFactory(messageStoreFactory),
50
+ m_pLogFactory(pLogFactory) {}
51
+
52
+ ~SessionFactory();
53
+
54
+ Session *create(const SessionID &sessionID, const Dictionary &settings) EXCEPT(ConfigError);
55
+ void destroy(Session *pSession);
56
+
57
+ private:
58
+ typedef std::map<std::string, std::shared_ptr<DataDictionary>> Dictionaries;
59
+
60
+ std::shared_ptr<DataDictionary> createDataDictionary(
61
+ const SessionID &sessionID,
62
+ const Dictionary &settings,
63
+ const std::string &settingsKey) EXCEPT(ConfigError);
64
+
65
+ void processFixtDataDictionaries(
66
+ const SessionID &sessionID,
67
+ const Dictionary &settings,
68
+ DataDictionaryProvider &provider) EXCEPT(ConfigError);
69
+
70
+ void processFixDataDictionary(
71
+ const SessionID &sessionID,
72
+ const Dictionary &settings,
73
+ DataDictionaryProvider &provider) EXCEPT(ConfigError);
74
+
75
+ std::string toApplVerID(const std::string &value);
76
+
77
+ Application &m_application;
78
+ MessageStoreFactory &m_messageStoreFactory;
79
+ LogFactory *m_pLogFactory;
80
+ Dictionaries m_dictionaries;
81
+ };
82
+ } // namespace FIX
83
+
84
+ #endif
@@ -0,0 +1,136 @@
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_SESSIONID_H
23
+ #define FIX_SESSIONID_H
24
+
25
+ #include "Fields.h"
26
+
27
+ namespace FIX {
28
+ /// Unique session id consists of BeginString, SenderCompID and TargetCompID.
29
+ class SessionID {
30
+ public:
31
+ SessionID() { toString(m_frozenString); }
32
+
33
+ SessionID(
34
+ const std::string &beginString,
35
+ const std::string &senderCompID,
36
+ const std::string &targetCompID,
37
+ const std::string &sessionQualifier = "")
38
+ : m_beginString(BeginString(beginString)),
39
+ m_senderCompID(SenderCompID(senderCompID)),
40
+ m_targetCompID(TargetCompID(targetCompID)),
41
+ m_sessionQualifier(sessionQualifier),
42
+ m_isFIXT(false) {
43
+ toString(m_frozenString);
44
+ if (beginString.substr(0, 4) == "FIXT") {
45
+ m_isFIXT = true;
46
+ }
47
+ }
48
+
49
+ const BeginString &getBeginString() const { return m_beginString; }
50
+ const SenderCompID &getSenderCompID() const { return m_senderCompID; }
51
+ const TargetCompID &getTargetCompID() const { return m_targetCompID; }
52
+ const std::string &getSessionQualifier() const { return m_sessionQualifier; }
53
+ const bool isFIXT() const { return m_isFIXT; }
54
+
55
+ /// Get a string representation of the SessionID
56
+ std::string toString() const { return m_frozenString; }
57
+
58
+ // Return a reference for a high-performance scenario
59
+ const std::string &toStringFrozen() const { return m_frozenString; }
60
+
61
+ /// Build from string representation of SessionID
62
+ void fromString(const std::string &str) {
63
+ std::string::size_type first = str.find_first_of(':');
64
+ std::string::size_type second = str.find("->");
65
+ std::string::size_type third = str.find_last_of(':');
66
+ if (first == std::string::npos) {
67
+ return;
68
+ }
69
+ if (second == std::string::npos) {
70
+ return;
71
+ }
72
+ m_beginString = str.substr(0, first);
73
+ m_senderCompID = str.substr(first + 1, second - first - 1);
74
+ if (first == third) {
75
+ m_targetCompID = str.substr(second + 2);
76
+ m_sessionQualifier = "";
77
+ } else {
78
+ m_targetCompID = str.substr(second + 2, third - second - 2);
79
+ m_sessionQualifier = str.substr(third + 1);
80
+ }
81
+ toString(m_frozenString);
82
+ }
83
+
84
+ /// Get a string representation without making a copy
85
+ std::string &toString(std::string &str) const {
86
+ str = getBeginString().getValue() + ":" + getSenderCompID().getValue() + "->" + getTargetCompID().getValue();
87
+ if (m_sessionQualifier.size()) {
88
+ str += ":" + m_sessionQualifier;
89
+ }
90
+ return str;
91
+ }
92
+
93
+ friend bool operator<(const SessionID &, const SessionID &);
94
+ friend bool operator==(const SessionID &, const SessionID &);
95
+ friend bool operator!=(const SessionID &, const SessionID &);
96
+ friend std::ostream &operator<<(std::ostream &, const SessionID &);
97
+ friend std::istream &operator>>(std::istream &, SessionID &);
98
+
99
+ SessionID operator~() const {
100
+ return SessionID(m_beginString, SenderCompID(m_targetCompID), TargetCompID(m_senderCompID), m_sessionQualifier);
101
+ }
102
+
103
+ private:
104
+ BeginString m_beginString;
105
+ SenderCompID m_senderCompID;
106
+ TargetCompID m_targetCompID;
107
+ std::string m_sessionQualifier;
108
+ bool m_isFIXT;
109
+ std::string m_frozenString;
110
+ };
111
+ /*! @} */
112
+
113
+ inline bool operator<(const SessionID &lhs, const SessionID &rhs) {
114
+ return lhs.toStringFrozen() < rhs.toStringFrozen();
115
+ }
116
+
117
+ inline bool operator==(const SessionID &lhs, const SessionID &rhs) {
118
+ return lhs.toStringFrozen() == rhs.toStringFrozen();
119
+ }
120
+
121
+ inline bool operator!=(const SessionID &lhs, const SessionID &rhs) { return !(lhs == rhs); }
122
+
123
+ inline std::ostream &operator<<(std::ostream &stream, const SessionID &sessionID) {
124
+ stream << sessionID.toStringFrozen();
125
+ return stream;
126
+ }
127
+
128
+ inline std::istream &operator>>(std::istream &stream, SessionID &sessionID) {
129
+ std::string str;
130
+ stream >> str;
131
+ sessionID.fromString(str);
132
+ return stream;
133
+ }
134
+
135
+ } // namespace FIX
136
+ #endif // FIX_SESSIONID_H
@@ -0,0 +1,165 @@
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 "SessionSettings.h"
27
+ #include "Settings.h"
28
+ #include "Values.h"
29
+ #include <fstream>
30
+
31
+ namespace FIX {
32
+ SessionSettings::SessionSettings(std::istream &stream, bool resolveEnvVars) EXCEPT(ConfigError)
33
+ : m_resolveEnvVars(resolveEnvVars) {
34
+ stream >> *this;
35
+ }
36
+
37
+ SessionSettings::SessionSettings(const std::string &file, bool resolveEnvVars) EXCEPT(ConfigError)
38
+ : m_resolveEnvVars(resolveEnvVars) {
39
+ std::ifstream fstream(file.c_str());
40
+ if (!fstream.is_open()) {
41
+ throw ConfigError(("File " + file + " not found").c_str());
42
+ }
43
+ fstream >> *this;
44
+ }
45
+
46
+ std::istream &operator>>(std::istream &stream, SessionSettings &s) EXCEPT(ConfigError) {
47
+ Settings settings(s.m_resolveEnvVars);
48
+ stream >> settings;
49
+
50
+ Settings::Sections section;
51
+
52
+ section = settings.get("DEFAULT");
53
+ Dictionary def;
54
+ if (section.size()) {
55
+ def = section[0];
56
+ }
57
+ s.set(def);
58
+
59
+ section = settings.get("SESSION");
60
+ Settings::Sections::size_type session;
61
+ Dictionary dict;
62
+
63
+ for (session = 0; session < section.size(); ++session) {
64
+ dict = section[session];
65
+ dict.merge(def);
66
+
67
+ BeginString beginString(dict.getString(BEGINSTRING));
68
+ SenderCompID senderCompID(dict.getString(SENDERCOMPID));
69
+ TargetCompID targetCompID(dict.getString(TARGETCOMPID));
70
+
71
+ std::string sessionQualifier;
72
+ if (dict.has(SESSION_QUALIFIER)) {
73
+ sessionQualifier = dict.getString(SESSION_QUALIFIER);
74
+ }
75
+ SessionID sessionID(beginString, senderCompID, targetCompID, sessionQualifier);
76
+ s.set(sessionID, dict);
77
+ }
78
+ return stream;
79
+ }
80
+
81
+ std::ostream &operator<<(std::ostream &stream, const SessionSettings &sessionSettings) {
82
+ const Dictionary &defaults = sessionSettings.get();
83
+ if (defaults.size()) {
84
+ stream << "[DEFAULT]" << std::endl;
85
+ for (const Dictionary::value_type &defaultParam : defaults) {
86
+ stream << defaultParam.first << "=" << defaultParam.second << std::endl;
87
+ }
88
+ stream << std::endl;
89
+ }
90
+
91
+ for (const SessionID &sessionID : sessionSettings.getSessions()) {
92
+ stream << "[SESSION]" << std::endl;
93
+ const Dictionary &section = sessionSettings.get(sessionID);
94
+ if (!section.size()) {
95
+ continue;
96
+ }
97
+
98
+ for (const Dictionary::value_type &sectionParam : section) {
99
+ if (defaults.has(sectionParam.first) && defaults.getString(sectionParam.first) == sectionParam.second) {
100
+ continue;
101
+ }
102
+ stream << sectionParam.first << "=" << sectionParam.second << std::endl;
103
+ }
104
+ stream << std::endl;
105
+ }
106
+
107
+ return stream;
108
+ }
109
+
110
+ const bool SessionSettings::has(const SessionID &sessionID) const {
111
+ return m_settings.find(sessionID) != m_settings.end();
112
+ }
113
+
114
+ const Dictionary &SessionSettings::get(const SessionID &sessionID) const EXCEPT(ConfigError) {
115
+ Dictionaries::const_iterator i;
116
+ i = m_settings.find(sessionID);
117
+ if (i == m_settings.end()) {
118
+ throw ConfigError("Session not found");
119
+ }
120
+ return i->second;
121
+ }
122
+
123
+ void SessionSettings::set(const SessionID &sessionID, Dictionary settings) EXCEPT(ConfigError) {
124
+ if (has(sessionID)) {
125
+ throw ConfigError("Duplicate Session " + sessionID.toString());
126
+ }
127
+
128
+ settings.setString(BEGINSTRING, sessionID.getBeginString());
129
+ settings.setString(SENDERCOMPID, sessionID.getSenderCompID());
130
+ settings.setString(TARGETCOMPID, sessionID.getTargetCompID());
131
+
132
+ settings.merge(m_defaults);
133
+ validate(settings);
134
+ m_settings[sessionID] = settings;
135
+ }
136
+
137
+ void SessionSettings::set(const Dictionary &defaults) EXCEPT(ConfigError) {
138
+ m_defaults = defaults;
139
+ for (Dictionaries::value_type &setting : m_settings) {
140
+ setting.second.merge(defaults);
141
+ }
142
+ }
143
+
144
+ std::set<SessionID> SessionSettings::getSessions() const {
145
+ std::set<SessionID> result;
146
+ for (const Dictionaries::value_type &setting : m_settings) {
147
+ result.insert(setting.first);
148
+ }
149
+ return result;
150
+ }
151
+
152
+ void SessionSettings::validate(const Dictionary &dictionary) const EXCEPT(ConfigError) {
153
+ std::string beginString = dictionary.getString(BEGINSTRING);
154
+ if (beginString != BeginString_FIX40 && beginString != BeginString_FIX41 && beginString != BeginString_FIX42
155
+ && beginString != BeginString_FIX43 && beginString != BeginString_FIX44 && beginString != BeginString_FIXT11) {
156
+ throw ConfigError(std::string(BEGINSTRING) + " must be FIX.4.0 to FIX.4.4 or FIXT.1.1");
157
+ }
158
+
159
+ std::string connectionType = dictionary.getString(CONNECTION_TYPE);
160
+ if (connectionType != "initiator" && connectionType != "acceptor") {
161
+ throw ConfigError(std::string(CONNECTION_TYPE) + " must be 'initiator' or 'acceptor'");
162
+ }
163
+ }
164
+
165
+ } // namespace FIX
@@ -0,0 +1,283 @@
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_SESSIONSETTINGS_H
23
+ #define FIX_SESSIONSETTINGS_H
24
+
25
+ #ifdef _MSC_VER
26
+ #pragma warning(disable : 4503 4355 4786 4290)
27
+ #endif
28
+
29
+ #include "Dictionary.h"
30
+ #include "Exceptions.h"
31
+ #include "SessionID.h"
32
+ #include <map>
33
+ #include <set>
34
+
35
+ namespace FIX {
36
+ const char BEGINSTRING[] = "BeginString";
37
+ const char SENDERCOMPID[] = "SenderCompID";
38
+ const char TARGETCOMPID[] = "TargetCompID";
39
+ const char SESSION_QUALIFIER[] = "SessionQualifier";
40
+ const char DEFAULT_APPLVERID[] = "DefaultApplVerID";
41
+ const char CONNECTION_TYPE[] = "ConnectionType";
42
+ const char USE_DATA_DICTIONARY[] = "UseDataDictionary";
43
+ const char SEND_RESETSEQNUMFLAG[] = "SendResetSeqNumFlag";
44
+ const char SEND_REDUNDANT_RESENDREQUESTS[] = "SendRedundantResendRequests";
45
+ const char SEND_NEXT_EXPECTED_MSG_SEQ_NUM[] = "SendNextExpectedMsgSeqNum";
46
+ const char DATA_DICTIONARY[] = "DataDictionary";
47
+ const char TRANSPORT_DATA_DICTIONARY[] = "TransportDataDictionary";
48
+ const char APP_DATA_DICTIONARY[] = "AppDataDictionary";
49
+ const char USE_LOCAL_TIME[] = "UseLocalTime";
50
+ const char START_TIME[] = "StartTime";
51
+ const char END_TIME[] = "EndTime";
52
+ const char START_DAY[] = "StartDay";
53
+ const char END_DAY[] = "EndDay";
54
+ const char NON_STOP_SESSION[] = "NonStopSession";
55
+ const char LOGON_TIME[] = "LogonTime";
56
+ const char LOGOUT_TIME[] = "LogoutTime";
57
+ const char LOGON_DAY[] = "LogonDay";
58
+ const char LOGOUT_DAY[] = "LogoutDay";
59
+ const char CHECK_COMPID[] = "CheckCompID";
60
+ const char CHECK_LATENCY[] = "CheckLatency";
61
+ const char MAX_LATENCY[] = "MaxLatency";
62
+ const char HEARTBTINT[] = "HeartBtInt";
63
+ const char SOCKET_ACCEPT_PORT[] = "SocketAcceptPort";
64
+ const char SOCKET_REUSE_ADDRESS[] = "SocketReuseAddress";
65
+ const char SOCKET_CONNECT_HOST[] = "SocketConnectHost";
66
+ const char SOCKET_CONNECT_PORT[] = "SocketConnectPort";
67
+ const char SOCKET_CONNECT_SOURCE_HOST[] = "SocketConnectSourceHost";
68
+ const char SOCKET_CONNECT_SOURCE_PORT[] = "SocketConnectSourcePort";
69
+ const char SOCKET_NODELAY[] = "SocketNodelay";
70
+ const char SOCKET_SEND_BUFFER_SIZE[] = "SocketSendBufferSize";
71
+ const char SOCKET_RECEIVE_BUFFER_SIZE[] = "SocketReceiveBufferSize";
72
+ const char HOST_SELECTION_POLICY[] = "HostSelectionPolicy";
73
+ const char HOST_SELECTION_POLICY_PRIORITY_START_OVER_INTERVAL[] = "HostSelectionPolicyPriorityStartOverInterval";
74
+ const char RECONNECT_INTERVAL[] = "ReconnectInterval";
75
+ const char VALIDATE_LENGTH_AND_CHECKSUM[] = "ValidateLengthAndChecksum";
76
+ const char VALIDATE_FIELDS_OUT_OF_ORDER[] = "ValidateFieldsOutOfOrder";
77
+ const char VALIDATE_FIELDS_HAVE_VALUES[] = "ValidateFieldsHaveValues";
78
+ const char VALIDATE_USER_DEFINED_FIELDS[] = "ValidateUserDefinedFields";
79
+ const char ALLOW_UNKNOWN_MSG_FIELDS[] = "AllowUnknownMsgFields";
80
+ const char PRESERVE_MESSAGE_FIELDS_ORDER[] = "PreserveMessageFieldsOrder";
81
+ const char LOGON_TIMEOUT[] = "LogonTimeout";
82
+ const char LOGOUT_TIMEOUT[] = "LogoutTimeout";
83
+ const char FILE_STORE_PATH[] = "FileStorePath";
84
+ const char MYSQL_STORE_USECONNECTIONPOOL[] = "MySQLStoreUseConnectionPool";
85
+ const char MYSQL_STORE_DATABASE[] = "MySQLStoreDatabase";
86
+ const char MYSQL_STORE_USER[] = "MySQLStoreUser";
87
+ const char MYSQL_STORE_PASSWORD[] = "MySQLStorePassword";
88
+ const char MYSQL_STORE_HOST[] = "MySQLStoreHost";
89
+ const char MYSQL_STORE_PORT[] = "MySQLStorePort";
90
+ const char POSTGRESQL_STORE_USECONNECTIONPOOL[] = "PostgreSQLStoreUseConnectionPool";
91
+ const char POSTGRESQL_STORE_DATABASE[] = "PostgreSQLStoreDatabase";
92
+ const char POSTGRESQL_STORE_USER[] = "PostgreSQLStoreUser";
93
+ const char POSTGRESQL_STORE_PASSWORD[] = "PostgreSQLStorePassword";
94
+ const char POSTGRESQL_STORE_HOST[] = "PostgreSQLStoreHost";
95
+ const char POSTGRESQL_STORE_PORT[] = "PostgreSQLStorePort";
96
+ const char ODBC_STORE_USER[] = "OdbcStoreUser";
97
+ const char ODBC_STORE_PASSWORD[] = "OdbcStorePassword";
98
+ const char ODBC_STORE_CONNECTION_STRING[] = "OdbcStoreConnectionString";
99
+ const char FILE_LOG_PATH[] = "FileLogPath";
100
+ const char FILE_LOG_BACKUP_PATH[] = "FileLogBackupPath";
101
+ const char SCREEN_LOG_SHOW_INCOMING[] = "ScreenLogShowIncoming";
102
+ const char SCREEN_LOG_SHOW_OUTGOING[] = "ScreenLogShowOutgoing";
103
+ const char SCREEN_LOG_SHOW_EVENTS[] = "ScreenLogShowEvents";
104
+ const char MYSQL_LOG_USECONNECTIONPOOL[] = "MySQLLogUseConnectionPool";
105
+ const char MYSQL_LOG_DATABASE[] = "MySQLLogDatabase";
106
+ const char MYSQL_LOG_USER[] = "MySQLLogUser";
107
+ const char MYSQL_LOG_PASSWORD[] = "MySQLLogPassword";
108
+ const char MYSQL_LOG_HOST[] = "MySQLLogHost";
109
+ const char MYSQL_LOG_PORT[] = "MySQLLogPort";
110
+ const char MYSQL_LOG_INCOMING_TABLE[] = "MySQLLogIncomingTable";
111
+ const char MYSQL_LOG_OUTGOING_TABLE[] = "MySQLLogOutgoingTable";
112
+ const char MYSQL_LOG_EVENT_TABLE[] = "MySQLLogEventTable";
113
+ const char POSTGRESQL_LOG_USECONNECTIONPOOL[] = "PostgreSQLLogUseConnectionPool";
114
+ const char POSTGRESQL_LOG_DATABASE[] = "PostgreSQLLogDatabase";
115
+ const char POSTGRESQL_LOG_USER[] = "PostgreSQLLogUser";
116
+ const char POSTGRESQL_LOG_PASSWORD[] = "PostgreSQLLogPassword";
117
+ const char POSTGRESQL_LOG_HOST[] = "PostgreSQLLogHost";
118
+ const char POSTGRESQL_LOG_PORT[] = "PostgreSQLLogPort";
119
+ const char POSTGRESQL_LOG_INCOMING_TABLE[] = "PostgreSQLLogIncomingTable";
120
+ const char POSTGRESQL_LOG_OUTGOING_TABLE[] = "PostgreSQLLogOutgoingTable";
121
+ const char POSTGRESQL_LOG_EVENT_TABLE[] = "PostgreSQLLogEventTable";
122
+ const char ODBC_LOG_USER[] = "OdbcLogUser";
123
+ const char ODBC_LOG_PASSWORD[] = "OdbcLogPassword";
124
+ const char ODBC_LOG_CONNECTION_STRING[] = "OdbcLogConnectionString";
125
+ const char ODBC_LOG_INCOMING_TABLE[] = "OdbcLogIncomingTable";
126
+ const char ODBC_LOG_OUTGOING_TABLE[] = "OdbcLogOutgoingTable";
127
+ const char ODBC_LOG_EVENT_TABLE[] = "OdbcLogEventTable";
128
+ const char RESET_ON_LOGON[] = "ResetOnLogon";
129
+ const char RESET_ON_LOGOUT[] = "ResetOnLogout";
130
+ const char RESET_ON_DISCONNECT[] = "ResetOnDisconnect";
131
+ const char REFRESH_ON_LOGON[] = "RefreshOnLogon";
132
+ const char MILLISECONDS_IN_TIMESTAMP[] = "MillisecondsInTimeStamp";
133
+ const char TIMESTAMP_PRECISION[] = "TimestampPrecision";
134
+ const char HTTP_ACCEPT_PORT[] = "HttpAcceptPort";
135
+ const char PERSIST_MESSAGES[] = "PersistMessages";
136
+ const char SERVER_CERTIFICATE_FILE[] = "ServerCertificateFile";
137
+ const char SERVER_CERTIFICATE_KEY_FILE[] = "ServerCertificateKeyFile";
138
+ const char CLIENT_CERTIFICATE_FILE[] = "ClientCertificateFile";
139
+ const char CLIENT_CERTIFICATE_KEY_FILE[] = "ClientCertificateKeyFile";
140
+ const char CERTIFICATE_AUTHORITIES_FILE[] = "CertificationAuthoritiesFile";
141
+ const char CERTIFICATE_AUTHORITIES_DIRECTORY[] = "CertificationAuthoritiesDirectory";
142
+ const char CERTIFICATE_REVOCATION_LIST_FILE[] = "CertificateRevocationListFile";
143
+ const char CERTIFICATE_REVOCATION_LIST_DIRECTORY[] = "CertificateRevocationListDirectory";
144
+ const char CERTIFICATE_VERIFY_LEVEL[] = "CertificateVerifyLevel";
145
+ const char ALLOWED_REMOTE_ADDRESSES[] = "AllowedRemoteAddresses";
146
+ /*
147
+ # This directive can be used to control the SSL protocol flavors the application
148
+ # should use when establishing its environment.
149
+ #
150
+ # The available (case-insensitive) protocols are:
151
+ #
152
+ # SSLv2
153
+ #
154
+ # This is the Secure Sockets Layer (SSL) protocol, version 2.0. It is the
155
+ # original SSL protocol as designed by Netscape Corporation.
156
+ #
157
+ # SSLv3
158
+ #
159
+ # This is the Secure Sockets Layer (SSL) protocol, version 3.0. It is the
160
+ # successor to SSLv2 and the currently (as of February 1999) de-facto
161
+ # standardized SSL protocol from Netscape Corporation. It's supported by
162
+ # almost all popular browsers.
163
+ #
164
+ # TLSv1
165
+ #
166
+ # This is the Transport Layer Security (TLS) protocol, version 1.0.
167
+ #
168
+ # TLSv1_1
169
+ #
170
+ # This is the Transport Layer Security (TLS) protocol, version 1.1.
171
+ #
172
+ # TLSv1_2
173
+ #
174
+ # This is the Transport Layer Security (TLS) protocol, version 1.2.
175
+ #
176
+ # all
177
+ #
178
+ # This is a shortcut for `+SSLv2 +SSLv3 +TLSv1 +TLSv1_1 +TLSv1_2' and a convenient way for
179
+ # enabling all protocols except one when used in combination with the minus
180
+ # sign on a protocol as the example above shows.
181
+ #
182
+ # Example:
183
+ #
184
+ # enable all but not SSLv2
185
+ # SSL_PROTOCOL = all -SSLv2
186
+ #
187
+ # `all -SSLv2` is the default value when the parameter is not specified.
188
+
189
+ */
190
+ const char SSL_PROTOCOL[] = "SSLProtocol";
191
+ /*
192
+ # DISCLAIMER: This setting only work for TLSv1.2 and below
193
+ # see: https://www.openssl.org/docs/man1.1.1/man3/SSL_CTX_set_cipher_list.html
194
+ #
195
+ # This complex directive uses a colon-separated cipher-spec string consisting
196
+ # of OpenSSL cipher specifications to configure the Cipher Suite the client is
197
+ # permitted to negotiate in the SSL handshake phase. Notice that this directive
198
+ # can be used both in per-server and per-directory context. In per-server
199
+ # context it applies to the standard SSL handshake when a connection is
200
+ # established. In per-directory context it forces a SSL renegotation with the
201
+ # reconfigured Cipher Suite after the HTTP request was read but before the HTTP
202
+ # response is sent.
203
+ #
204
+ # An SSL cipher specification in cipher-spec is composed of 4 major attributes
205
+ # plus a few extra minor ones:
206
+ #
207
+ # Key Exchange Algorithm:
208
+ # RSA or Diffie-Hellman variants.
209
+ #
210
+ # Authentication Algorithm:
211
+ # RSA, Diffie-Hellman, DSS or none.
212
+ #
213
+ # Cipher/Encryption Algorithm:
214
+ # DES, Triple-DES, RC4, RC2, IDEA or none.
215
+ #
216
+ # MAC Digest Algorithm:
217
+ # MD5, SHA or SHA1.
218
+ #
219
+ # For more details refer to mod_ssl documentation.
220
+ #
221
+ # Example: RC4+RSA:+HIGH:
222
+ */
223
+ const char SSL_CIPHER_SUITE[] = "SSLCipherSuite";
224
+ /*
225
+ # DISCLAIMER: This setting only work for TLSv1.3 and upper
226
+ # see: https://www.openssl.org/docs/man1.1.1/man3/SSL_CTX_set_ciphersuites.html
227
+ #
228
+ # This is a simple colon (":") separated list of TLSv1.3 ciphersuite names in
229
+ # order of preference. Valid TLSv1.3 ciphersuite names are:
230
+ # TLS_AES_128_GCM_SHA256
231
+ # TLS_AES_256_GCM_SHA384
232
+ # TLS_CHACHA20_POLY1305_SHA256
233
+ # TLS_AES_128_CCM_SHA256
234
+ # TLS_AES_128_CCM_8_SHA256
235
+ #
236
+ # An empty list is permissible. The default value for the this setting is:
237
+ # "TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256:TLS_AES_128_GCM_SHA256"
238
+ */
239
+ const char TLS_CIPHER_SUITES[] = "TLSCipherSuites";
240
+
241
+ /// Container for setting dictionaries mapped to sessions.
242
+ class SessionSettings {
243
+ public:
244
+ SessionSettings() { m_resolveEnvVars = false; }
245
+ SessionSettings(std::istream &stream, bool resolveEnvVars = false) EXCEPT(ConfigError);
246
+ SessionSettings(const std::string &file, bool resolveEnvVars = false) EXCEPT(ConfigError);
247
+
248
+ /// Check if session setings are present
249
+ const bool has(const SessionID &) const;
250
+
251
+ /// Get a dictionary for a session.
252
+ const Dictionary &get(const SessionID &) const EXCEPT(ConfigError);
253
+ /// Set a dictionary for a session
254
+ void set(const SessionID &, Dictionary) EXCEPT(ConfigError);
255
+
256
+ /// Get global default settings
257
+ const Dictionary &get() const { return m_defaults; }
258
+ /// Set global default settings
259
+ void set(const Dictionary &defaults) EXCEPT(ConfigError);
260
+
261
+ /// Number of session settings
262
+ size_t size() const { return m_settings.size(); }
263
+
264
+ typedef std::map<SessionID, Dictionary> Dictionaries;
265
+ std::set<SessionID> getSessions() const;
266
+
267
+ private:
268
+ void validate(const Dictionary &) const EXCEPT(ConfigError);
269
+
270
+ Dictionaries m_settings;
271
+ Dictionary m_defaults;
272
+ bool m_resolveEnvVars; // while reading, replace $var, $(var) and ${var} by environment variable var
273
+
274
+ friend std::istream &operator>>(std::istream &, SessionSettings &) EXCEPT(ConfigError);
275
+ friend std::ostream &operator<<(std::ostream &, const SessionSettings &);
276
+ };
277
+ /*! @} */
278
+
279
+ std::istream &operator>>(std::istream &, SessionSettings &) EXCEPT(ConfigError);
280
+ std::ostream &operator<<(std::ostream &, const SessionSettings &);
281
+ } // namespace FIX
282
+
283
+ #endif // FIX_SESSIONSETTINGS_H