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,800 @@
|
|
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_FIELDCONVERTORS_H
|
23
|
+
#define FIX_FIELDCONVERTORS_H
|
24
|
+
|
25
|
+
#include "Exceptions.h"
|
26
|
+
#include "FieldTypes.h"
|
27
|
+
#include "Utility.h"
|
28
|
+
#include "config-all.h"
|
29
|
+
#include <assert.h>
|
30
|
+
#include <cstdio>
|
31
|
+
#include <iomanip>
|
32
|
+
#include <iterator>
|
33
|
+
#include <limits>
|
34
|
+
#include <sstream>
|
35
|
+
#include <string>
|
36
|
+
|
37
|
+
namespace FIX {
|
38
|
+
|
39
|
+
typedef int signed_int;
|
40
|
+
typedef int64_t signed_int64;
|
41
|
+
typedef unsigned int unsigned_int;
|
42
|
+
typedef uint64_t unsigned_int64;
|
43
|
+
|
44
|
+
template <typename T> inline typename std::make_unsigned<T>::type _UNSIGNED_VALUE_OF(const T x) {
|
45
|
+
return x < 0 ? -(typename std::make_unsigned<T>::type)(x) : (typename std::make_unsigned<T>::type)(x);
|
46
|
+
}
|
47
|
+
|
48
|
+
#define UNSIGNED_VALUE_OF(x) \
|
49
|
+
PRAGMA_PUSH(4146) \
|
50
|
+
_UNSIGNED_VALUE_OF(x) \
|
51
|
+
PRAGMA_POP
|
52
|
+
|
53
|
+
#define IS_SPACE(x) (x == ' ')
|
54
|
+
#define IS_DIGIT(x) (unsigned_int(x - '0') < 10)
|
55
|
+
|
56
|
+
template <typename T> inline int number_of_symbols_in(const T value) {
|
57
|
+
typename std::make_unsigned<T>::type number = UNSIGNED_VALUE_OF(value);
|
58
|
+
|
59
|
+
int symbols = 0;
|
60
|
+
|
61
|
+
while (number > 9999) {
|
62
|
+
symbols += 4;
|
63
|
+
number /= 10000;
|
64
|
+
}
|
65
|
+
|
66
|
+
// small tweak to make comparison times consistent
|
67
|
+
// always 2 comparisons instead of [1 - 4]
|
68
|
+
if (number > 99) {
|
69
|
+
if (number > 999) {
|
70
|
+
symbols += 4;
|
71
|
+
} else {
|
72
|
+
symbols += 3;
|
73
|
+
}
|
74
|
+
} else {
|
75
|
+
if (number > 9) {
|
76
|
+
symbols += 2;
|
77
|
+
} else {
|
78
|
+
symbols += 1;
|
79
|
+
}
|
80
|
+
}
|
81
|
+
|
82
|
+
if (value < 0) {
|
83
|
+
symbols += 1;
|
84
|
+
}
|
85
|
+
|
86
|
+
return symbols;
|
87
|
+
}
|
88
|
+
|
89
|
+
static const char digit_pairs[201] = {"00010203040506070809"
|
90
|
+
"10111213141516171819"
|
91
|
+
"20212223242526272829"
|
92
|
+
"30313233343536373839"
|
93
|
+
"40414243444546474849"
|
94
|
+
"50515253545556575859"
|
95
|
+
"60616263646566676869"
|
96
|
+
"70717273747576777879"
|
97
|
+
"80818283848586878889"
|
98
|
+
"90919293949596979899"};
|
99
|
+
|
100
|
+
template <typename T> inline char *integer_to_string(char *buf, const size_t len, const T t) {
|
101
|
+
const bool isNegative = t < 0;
|
102
|
+
char *p = buf + len;
|
103
|
+
|
104
|
+
typename std::make_unsigned<T>::type number = UNSIGNED_VALUE_OF(t);
|
105
|
+
|
106
|
+
while (number > 99) {
|
107
|
+
unsigned_int pos = number % 100;
|
108
|
+
number /= 100;
|
109
|
+
|
110
|
+
*--p = digit_pairs[2 * pos + 1];
|
111
|
+
*--p = digit_pairs[2 * pos];
|
112
|
+
}
|
113
|
+
|
114
|
+
if (number > 9) {
|
115
|
+
*--p = digit_pairs[2 * number + 1];
|
116
|
+
*--p = digit_pairs[2 * number];
|
117
|
+
} else {
|
118
|
+
*--p = '0' + char(number);
|
119
|
+
}
|
120
|
+
|
121
|
+
if (isNegative) {
|
122
|
+
*--p = '-';
|
123
|
+
}
|
124
|
+
|
125
|
+
return p;
|
126
|
+
}
|
127
|
+
|
128
|
+
template <typename T>
|
129
|
+
inline char *integer_to_string_padded(char *buf, const size_t len, const T t, const char paddingChar = '0') {
|
130
|
+
char *p = integer_to_string(buf, len, t);
|
131
|
+
while (p > buf) {
|
132
|
+
*--p = paddingChar;
|
133
|
+
}
|
134
|
+
return p;
|
135
|
+
}
|
136
|
+
|
137
|
+
inline char *size_to_string(char *buf, const size_t len, size_t t) {
|
138
|
+
char *p = buf + len;
|
139
|
+
|
140
|
+
size_t number = t;
|
141
|
+
|
142
|
+
while (number > 99) {
|
143
|
+
size_t pos = number % 100;
|
144
|
+
number /= 100;
|
145
|
+
|
146
|
+
*--p = digit_pairs[2 * pos + 1];
|
147
|
+
*--p = digit_pairs[2 * pos];
|
148
|
+
}
|
149
|
+
|
150
|
+
if (number > 9) {
|
151
|
+
*--p = digit_pairs[2 * number + 1];
|
152
|
+
*--p = digit_pairs[2 * number];
|
153
|
+
} else {
|
154
|
+
*--p = '0' + char(number);
|
155
|
+
}
|
156
|
+
|
157
|
+
return p;
|
158
|
+
}
|
159
|
+
|
160
|
+
template <typename T> T clamp_of(const T &value, const T &lowerBound, const T &upperBound) {
|
161
|
+
assert(lowerBound <= upperBound);
|
162
|
+
if (value < lowerBound) {
|
163
|
+
return lowerBound;
|
164
|
+
} else {
|
165
|
+
return (value > upperBound) ? upperBound : value;
|
166
|
+
}
|
167
|
+
}
|
168
|
+
|
169
|
+
/// Empty converter is a no-op.
|
170
|
+
struct EmptyConvertor {
|
171
|
+
static const std::string &convert(const std::string &value) { return value; }
|
172
|
+
};
|
173
|
+
|
174
|
+
typedef EmptyConvertor StringConvertor;
|
175
|
+
|
176
|
+
/// Converts integers to/from a string
|
177
|
+
template <typename T> struct IntTConvertor {
|
178
|
+
static_assert(std::is_integral<T>::value, "An integer type is required.");
|
179
|
+
|
180
|
+
typedef T value_type;
|
181
|
+
|
182
|
+
static const T VALUE_MIN = (std::numeric_limits<T>::min)();
|
183
|
+
static const T VALUE_MAX = (std::numeric_limits<T>::max)();
|
184
|
+
static const T OVERFLOW_MAX = VALUE_MAX / 10;
|
185
|
+
|
186
|
+
static std::string convert(T value) {
|
187
|
+
// buffer is big enough for significant digits and extra digit,
|
188
|
+
// minus and null
|
189
|
+
char buffer[std::numeric_limits<T>::digits10 + 2];
|
190
|
+
const char *const start = integer_to_string(buffer, sizeof(buffer), value);
|
191
|
+
return std::string(start, buffer + sizeof(buffer) - start);
|
192
|
+
}
|
193
|
+
|
194
|
+
static bool convert(std::string::const_iterator str, std::string::const_iterator end, T &result) {
|
195
|
+
bool isNegative = false;
|
196
|
+
typename std::make_unsigned<T>::type x = 0, nx = 0;
|
197
|
+
|
198
|
+
if (str == end) {
|
199
|
+
return false;
|
200
|
+
}
|
201
|
+
|
202
|
+
if (*str == '-' && std::is_unsigned<T>::value) {
|
203
|
+
return false;
|
204
|
+
}
|
205
|
+
|
206
|
+
if (*str == '-') {
|
207
|
+
isNegative = true;
|
208
|
+
if (++str == end) {
|
209
|
+
return false;
|
210
|
+
}
|
211
|
+
}
|
212
|
+
|
213
|
+
do {
|
214
|
+
if (x > OVERFLOW_MAX) {
|
215
|
+
return false; // overflow
|
216
|
+
}
|
217
|
+
const unsigned char c = *str - '0';
|
218
|
+
if (c > 9) {
|
219
|
+
return false;
|
220
|
+
}
|
221
|
+
nx = 10 * x + c;
|
222
|
+
if (nx < x) {
|
223
|
+
return false; // overflow
|
224
|
+
}
|
225
|
+
x = nx;
|
226
|
+
} while (++str != end);
|
227
|
+
|
228
|
+
if (isNegative) {
|
229
|
+
if (nx > UNSIGNED_VALUE_OF(VALUE_MIN)) {
|
230
|
+
return false; // overflow
|
231
|
+
}
|
232
|
+
} else if (nx > VALUE_MAX) {
|
233
|
+
return false; // overflow
|
234
|
+
}
|
235
|
+
|
236
|
+
PRAGMA_PUSH(4146);
|
237
|
+
if (isNegative) {
|
238
|
+
x = -x;
|
239
|
+
}
|
240
|
+
PRAGMA_POP;
|
241
|
+
|
242
|
+
result = x;
|
243
|
+
return true;
|
244
|
+
}
|
245
|
+
|
246
|
+
static bool convert(const std::string &value, T &result) { return convert(value.begin(), value.end(), result); }
|
247
|
+
|
248
|
+
static T convert(const std::string &value) EXCEPT(FieldConvertError) {
|
249
|
+
T result = 0;
|
250
|
+
if (!convert(value.begin(), value.end(), result)) {
|
251
|
+
throw FieldConvertError(value);
|
252
|
+
} else {
|
253
|
+
return result;
|
254
|
+
}
|
255
|
+
}
|
256
|
+
};
|
257
|
+
|
258
|
+
/// Converts integer to/from a string
|
259
|
+
typedef IntTConvertor<signed_int> IntConvertor;
|
260
|
+
|
261
|
+
/// Converts 64-bit integer to/from a string
|
262
|
+
typedef IntTConvertor<signed_int64> Int64Convertor;
|
263
|
+
|
264
|
+
/// Converts 64-bit unsigned integer to/from a string
|
265
|
+
typedef IntTConvertor<unsigned_int64> UInt64Convertor;
|
266
|
+
|
267
|
+
/// Converts checksum to/from a string
|
268
|
+
struct CheckSumConvertor {
|
269
|
+
static std::string convert(int value) EXCEPT(FieldConvertError) {
|
270
|
+
if (value > 255 || value < 0) {
|
271
|
+
throw FieldConvertError();
|
272
|
+
}
|
273
|
+
char result[3];
|
274
|
+
integer_to_string_padded(result, sizeof(result), value);
|
275
|
+
return std::string(result, sizeof(result));
|
276
|
+
}
|
277
|
+
|
278
|
+
static bool convert(const std::string &value, int &result) { return IntConvertor::convert(value, result); }
|
279
|
+
|
280
|
+
static int convert(const std::string &value) EXCEPT(FieldConvertError) { return IntConvertor::convert(value); }
|
281
|
+
};
|
282
|
+
|
283
|
+
/// Converts double to/from a string
|
284
|
+
struct DoubleConvertor {
|
285
|
+
|
286
|
+
private:
|
287
|
+
static double fast_strtod(const char *buffer, int size, int *processed_chars);
|
288
|
+
|
289
|
+
static int fast_dtoa(char *buffer, int size, double value, int significant_digits);
|
290
|
+
|
291
|
+
static int fast_fixed_dtoa(char *buffer, int size, double value, int significant_digits);
|
292
|
+
|
293
|
+
public:
|
294
|
+
static const int SIGNIFICANT_DIGITS = 15;
|
295
|
+
static const int BUFFFER_SIZE = 32;
|
296
|
+
|
297
|
+
static std::string convert(double value, int padding = 0, int significant_digits = SIGNIFICANT_DIGITS) {
|
298
|
+
char result[BUFFFER_SIZE];
|
299
|
+
char *end = 0;
|
300
|
+
|
301
|
+
int size;
|
302
|
+
if (value == 0 || value > 0.0001 || value < -0.0001) {
|
303
|
+
size = fast_dtoa(result, BUFFFER_SIZE, value, significant_digits);
|
304
|
+
if (size == 0) {
|
305
|
+
return std::string();
|
306
|
+
}
|
307
|
+
|
308
|
+
if (padding > 0) {
|
309
|
+
char *point = result;
|
310
|
+
end = result + size - 1;
|
311
|
+
while (*point != '.' && *point != 0) {
|
312
|
+
point++;
|
313
|
+
}
|
314
|
+
|
315
|
+
if (*point == 0) {
|
316
|
+
end = point;
|
317
|
+
*point = '.';
|
318
|
+
++size;
|
319
|
+
}
|
320
|
+
int needed = padding - (int)(end - point);
|
321
|
+
|
322
|
+
if (needed > 0) {
|
323
|
+
memset(++end, '0', needed);
|
324
|
+
size += needed;
|
325
|
+
}
|
326
|
+
}
|
327
|
+
} else {
|
328
|
+
size = fast_fixed_dtoa(result, BUFFFER_SIZE, value, significant_digits);
|
329
|
+
if (size == 0) {
|
330
|
+
return std::string();
|
331
|
+
}
|
332
|
+
|
333
|
+
// strip trailing 0's
|
334
|
+
end = result + size - 1;
|
335
|
+
|
336
|
+
if (padding > 0) {
|
337
|
+
int discard = significant_digits - padding;
|
338
|
+
|
339
|
+
while ((*end == '0') && (discard-- > 0)) {
|
340
|
+
--end;
|
341
|
+
--size;
|
342
|
+
}
|
343
|
+
} else {
|
344
|
+
while (*end == '0') {
|
345
|
+
--end;
|
346
|
+
--size;
|
347
|
+
}
|
348
|
+
}
|
349
|
+
}
|
350
|
+
|
351
|
+
return std::string(result, size);
|
352
|
+
}
|
353
|
+
|
354
|
+
static bool convert(const std::string &value, double &result) {
|
355
|
+
const char *i = value.c_str();
|
356
|
+
|
357
|
+
// Catch null strings
|
358
|
+
if (!*i) {
|
359
|
+
return false;
|
360
|
+
}
|
361
|
+
// Eat leading '-' and recheck for null string
|
362
|
+
if (*i == '-' && !*++i) {
|
363
|
+
return false;
|
364
|
+
}
|
365
|
+
|
366
|
+
bool haveDigit = false;
|
367
|
+
|
368
|
+
if (IS_DIGIT(*i)) {
|
369
|
+
haveDigit = true;
|
370
|
+
while (IS_DIGIT(*++i))
|
371
|
+
;
|
372
|
+
}
|
373
|
+
|
374
|
+
if (*i == '.' && IS_DIGIT(*++i)) {
|
375
|
+
haveDigit = true;
|
376
|
+
while (IS_DIGIT(*++i))
|
377
|
+
;
|
378
|
+
}
|
379
|
+
|
380
|
+
if (*i || !haveDigit) {
|
381
|
+
return false;
|
382
|
+
}
|
383
|
+
|
384
|
+
int processed_chars;
|
385
|
+
const size_t total_length = value.length();
|
386
|
+
result = fast_strtod(value.c_str(), static_cast<int>(total_length), &processed_chars);
|
387
|
+
|
388
|
+
return true;
|
389
|
+
}
|
390
|
+
|
391
|
+
static double convert(const std::string &value) EXCEPT(FieldConvertError) {
|
392
|
+
double result = 0.0;
|
393
|
+
if (!convert(value, result)) {
|
394
|
+
throw FieldConvertError(value);
|
395
|
+
} else {
|
396
|
+
return result;
|
397
|
+
}
|
398
|
+
}
|
399
|
+
};
|
400
|
+
|
401
|
+
/// Converts character to/from a string
|
402
|
+
struct CharConvertor {
|
403
|
+
static std::string convert(char value) {
|
404
|
+
if (value == '\0') {
|
405
|
+
return "";
|
406
|
+
}
|
407
|
+
return std::string(1, value);
|
408
|
+
}
|
409
|
+
|
410
|
+
static bool convert(const std::string &value, char &result) {
|
411
|
+
if (value.size() != 1) {
|
412
|
+
return false;
|
413
|
+
}
|
414
|
+
result = value[0];
|
415
|
+
return true;
|
416
|
+
}
|
417
|
+
|
418
|
+
static char convert(const std::string &value) EXCEPT(FieldConvertError) {
|
419
|
+
char result = '\0';
|
420
|
+
if (!convert(value, result)) {
|
421
|
+
throw FieldConvertError(value);
|
422
|
+
} else {
|
423
|
+
return result;
|
424
|
+
}
|
425
|
+
}
|
426
|
+
};
|
427
|
+
|
428
|
+
/// Converts boolean to/from a string
|
429
|
+
struct BoolConvertor {
|
430
|
+
static std::string convert(bool value) {
|
431
|
+
const char ch = value ? 'Y' : 'N';
|
432
|
+
return std::string(1, ch);
|
433
|
+
}
|
434
|
+
|
435
|
+
static bool convert(const std::string &value, bool &result) {
|
436
|
+
if (value.size() != 1) {
|
437
|
+
return false;
|
438
|
+
}
|
439
|
+
switch (value[0]) {
|
440
|
+
case 'Y':
|
441
|
+
result = true;
|
442
|
+
break;
|
443
|
+
case 'N':
|
444
|
+
result = false;
|
445
|
+
break;
|
446
|
+
default:
|
447
|
+
return false;
|
448
|
+
}
|
449
|
+
|
450
|
+
return true;
|
451
|
+
}
|
452
|
+
|
453
|
+
static bool convert(const std::string &value) EXCEPT(FieldConvertError) {
|
454
|
+
bool result = false;
|
455
|
+
if (!convert(value, result)) {
|
456
|
+
throw FieldConvertError(value);
|
457
|
+
} else {
|
458
|
+
return result;
|
459
|
+
}
|
460
|
+
}
|
461
|
+
};
|
462
|
+
|
463
|
+
/// Converts a UtcTimeStamp to/from a string
|
464
|
+
struct UtcTimeStampConvertor {
|
465
|
+
static std::string convert(const UtcTimeStamp &value, int precision = 0) EXCEPT(FieldConvertError) {
|
466
|
+
char result[17 + 10]; // Maximum
|
467
|
+
int year, month, day, hour, minute, second, fraction;
|
468
|
+
|
469
|
+
precision = clamp_of(precision, 0, 9);
|
470
|
+
|
471
|
+
value.getYMD(year, month, day);
|
472
|
+
value.getHMS(hour, minute, second, fraction, precision);
|
473
|
+
|
474
|
+
integer_to_string_padded(result, 4, year);
|
475
|
+
integer_to_string_padded(result + 4, 2, month);
|
476
|
+
integer_to_string_padded(result + 6, 2, day);
|
477
|
+
result[8] = '-';
|
478
|
+
integer_to_string_padded(result + 9, 2, hour);
|
479
|
+
result[11] = ':';
|
480
|
+
integer_to_string_padded(result + 12, 2, minute);
|
481
|
+
result[14] = ':';
|
482
|
+
integer_to_string_padded(result + 15, 2, second);
|
483
|
+
|
484
|
+
if (precision) {
|
485
|
+
result[17] = '.';
|
486
|
+
integer_to_string_padded(result + 18, precision, fraction);
|
487
|
+
}
|
488
|
+
|
489
|
+
return std::string(result, precision ? (17 + 1 + precision) : 17);
|
490
|
+
}
|
491
|
+
|
492
|
+
static UtcTimeStamp convert(const std::string &value) EXCEPT(FieldConvertError) {
|
493
|
+
size_t length = value.size();
|
494
|
+
if (length < 17 || length > 27) {
|
495
|
+
throw FieldConvertError(value);
|
496
|
+
}
|
497
|
+
|
498
|
+
size_t i = 0;
|
499
|
+
int c = 0;
|
500
|
+
for (c = 0; c < 8; ++c) {
|
501
|
+
if (!IS_DIGIT(value[i++])) {
|
502
|
+
throw FieldConvertError(value);
|
503
|
+
}
|
504
|
+
}
|
505
|
+
if (value[i++] != '-') {
|
506
|
+
throw FieldConvertError(value);
|
507
|
+
}
|
508
|
+
for (c = 0; c < 2; ++c) {
|
509
|
+
if (!IS_DIGIT(value[i++])) {
|
510
|
+
throw FieldConvertError(value);
|
511
|
+
}
|
512
|
+
}
|
513
|
+
if (value[i++] != ':') {
|
514
|
+
throw FieldConvertError(value);
|
515
|
+
}
|
516
|
+
for (c = 0; c < 2; ++c) {
|
517
|
+
if (!IS_DIGIT(value[i++])) {
|
518
|
+
throw FieldConvertError(value);
|
519
|
+
}
|
520
|
+
}
|
521
|
+
if (value[i++] != ':') {
|
522
|
+
throw FieldConvertError(value);
|
523
|
+
}
|
524
|
+
for (c = 0; c < 2; ++c) {
|
525
|
+
if (!IS_DIGIT(value[i++])) {
|
526
|
+
throw FieldConvertError(value);
|
527
|
+
}
|
528
|
+
}
|
529
|
+
|
530
|
+
int year, mon, mday, hour, min, sec;
|
531
|
+
|
532
|
+
i = 0;
|
533
|
+
|
534
|
+
year = value[i++] - '0';
|
535
|
+
year = 10 * year + value[i++] - '0';
|
536
|
+
year = 10 * year + value[i++] - '0';
|
537
|
+
year = 10 * year + value[i++] - '0';
|
538
|
+
|
539
|
+
mon = value[i++] - '0';
|
540
|
+
mon = 10 * mon + value[i++] - '0';
|
541
|
+
if (mon < 1 || 12 < mon) {
|
542
|
+
throw FieldConvertError(value);
|
543
|
+
}
|
544
|
+
|
545
|
+
mday = value[i++] - '0';
|
546
|
+
mday = 10 * mday + value[i++] - '0';
|
547
|
+
if (mday < 1 || 31 < mday) {
|
548
|
+
throw FieldConvertError(value);
|
549
|
+
}
|
550
|
+
|
551
|
+
++i; // skip '-'
|
552
|
+
|
553
|
+
hour = value[i++] - '0';
|
554
|
+
hour = 10 * hour + value[i++] - '0';
|
555
|
+
// No check for >= 0 as no '-' are converted here
|
556
|
+
if (23 < hour) {
|
557
|
+
throw FieldConvertError(value);
|
558
|
+
}
|
559
|
+
|
560
|
+
++i; // skip ':'
|
561
|
+
|
562
|
+
min = value[i++] - '0';
|
563
|
+
min = 10 * min + value[i++] - '0';
|
564
|
+
// No check for >= 0 as no '-' are converted here
|
565
|
+
if (59 < min) {
|
566
|
+
throw FieldConvertError(value);
|
567
|
+
}
|
568
|
+
|
569
|
+
++i; // skip ':'
|
570
|
+
|
571
|
+
sec = value[i++] - '0';
|
572
|
+
sec = 10 * sec + value[i++] - '0';
|
573
|
+
|
574
|
+
// No check for >= 0 as no '-' are converted here
|
575
|
+
if (60 < sec) {
|
576
|
+
throw FieldConvertError(value);
|
577
|
+
}
|
578
|
+
|
579
|
+
if (length == 17) {
|
580
|
+
return UtcTimeStamp(hour, min, sec, 0, mday, mon, year);
|
581
|
+
}
|
582
|
+
|
583
|
+
if (value[i++] != '.') {
|
584
|
+
throw FieldConvertError(value);
|
585
|
+
}
|
586
|
+
|
587
|
+
int fraction = 0;
|
588
|
+
for (; i < length; ++i) {
|
589
|
+
char ch = value[i];
|
590
|
+
if (!IS_DIGIT(ch)) {
|
591
|
+
throw FieldConvertError(value);
|
592
|
+
}
|
593
|
+
fraction = (fraction * 10) + ch - '0';
|
594
|
+
}
|
595
|
+
|
596
|
+
return UtcTimeStamp(hour, min, sec, fraction, mday, mon, year, static_cast<int>(length - 17 - 1));
|
597
|
+
}
|
598
|
+
};
|
599
|
+
|
600
|
+
/// Converts a UtcTimeOnly to/from a string
|
601
|
+
struct UtcTimeOnlyConvertor {
|
602
|
+
static std::string convert(const UtcTimeOnly &value, int precision = 0) EXCEPT(FieldConvertError) {
|
603
|
+
char result[8 + 10]; // Maximum
|
604
|
+
int hour, minute, second, fraction;
|
605
|
+
|
606
|
+
precision = clamp_of(precision, 0, 9);
|
607
|
+
|
608
|
+
value.getHMS(hour, minute, second, fraction, precision);
|
609
|
+
|
610
|
+
integer_to_string_padded(result, 2, hour);
|
611
|
+
result[2] = ':';
|
612
|
+
integer_to_string_padded(result + 3, 2, minute);
|
613
|
+
result[5] = ':';
|
614
|
+
integer_to_string_padded(result + 6, 2, second);
|
615
|
+
|
616
|
+
if (precision) {
|
617
|
+
result[8] = '.';
|
618
|
+
integer_to_string_padded(result + 9, precision, fraction);
|
619
|
+
}
|
620
|
+
|
621
|
+
return std::string(result, precision ? (8 + 1 + precision) : 8);
|
622
|
+
}
|
623
|
+
|
624
|
+
static UtcTimeOnly convert(const std::string &value) EXCEPT(FieldConvertError) {
|
625
|
+
size_t length = value.size();
|
626
|
+
if (length < 8 || length > 18) {
|
627
|
+
throw FieldConvertError(value);
|
628
|
+
}
|
629
|
+
|
630
|
+
size_t i = 0;
|
631
|
+
int c = 0;
|
632
|
+
for (c = 0; c < 2; ++c) {
|
633
|
+
if (!IS_DIGIT(value[i++])) {
|
634
|
+
throw FieldConvertError(value);
|
635
|
+
}
|
636
|
+
}
|
637
|
+
if (value[i++] != ':') {
|
638
|
+
throw FieldConvertError(value);
|
639
|
+
}
|
640
|
+
for (c = 0; c < 2; ++c) {
|
641
|
+
if (!IS_DIGIT(value[i++])) {
|
642
|
+
throw FieldConvertError(value);
|
643
|
+
}
|
644
|
+
}
|
645
|
+
if (value[i++] != ':') {
|
646
|
+
throw FieldConvertError(value);
|
647
|
+
}
|
648
|
+
for (c = 0; c < 2; ++c) {
|
649
|
+
if (!IS_DIGIT(value[i++])) {
|
650
|
+
throw FieldConvertError(value);
|
651
|
+
}
|
652
|
+
}
|
653
|
+
|
654
|
+
int hour, min, sec;
|
655
|
+
|
656
|
+
i = 0;
|
657
|
+
|
658
|
+
hour = value[i++] - '0';
|
659
|
+
hour = 10 * hour + value[i++] - '0';
|
660
|
+
// No check for >= 0 as no '-' are converted here
|
661
|
+
if (23 < hour) {
|
662
|
+
throw FieldConvertError(value);
|
663
|
+
}
|
664
|
+
|
665
|
+
++i; // skip ':'
|
666
|
+
|
667
|
+
min = value[i++] - '0';
|
668
|
+
min = 10 * min + value[i++] - '0';
|
669
|
+
// No check for >= 0 as no '-' are converted here
|
670
|
+
if (59 < min) {
|
671
|
+
throw FieldConvertError(value);
|
672
|
+
}
|
673
|
+
|
674
|
+
++i; // skip ':'
|
675
|
+
|
676
|
+
sec = value[i++] - '0';
|
677
|
+
sec = 10 * sec + value[i++] - '0';
|
678
|
+
|
679
|
+
// No check for >= 0 as no '-' are converted here
|
680
|
+
if (60 < sec) {
|
681
|
+
throw FieldConvertError(value);
|
682
|
+
}
|
683
|
+
|
684
|
+
if (length == 8) {
|
685
|
+
return UtcTimeOnly(hour, min, sec, 0);
|
686
|
+
}
|
687
|
+
|
688
|
+
if (value[i++] != '.') {
|
689
|
+
throw FieldConvertError(value);
|
690
|
+
}
|
691
|
+
|
692
|
+
int fraction = 0;
|
693
|
+
for (; i < length; ++i) {
|
694
|
+
char ch = value[i];
|
695
|
+
if (!IS_DIGIT(ch)) {
|
696
|
+
throw FieldConvertError(value);
|
697
|
+
}
|
698
|
+
fraction = (fraction * 10) + ch - '0';
|
699
|
+
}
|
700
|
+
|
701
|
+
return UtcTimeOnly(hour, min, sec, fraction, static_cast<int>(length - 8 - 1));
|
702
|
+
}
|
703
|
+
};
|
704
|
+
|
705
|
+
/// Converts a UtcDate to/from a string
|
706
|
+
struct UtcDateConvertor {
|
707
|
+
static std::string convert(const UtcDate &value) EXCEPT(FieldConvertError) {
|
708
|
+
int year, month, day;
|
709
|
+
value.getYMD(year, month, day);
|
710
|
+
|
711
|
+
char result[8];
|
712
|
+
|
713
|
+
integer_to_string_padded(result, 4, year);
|
714
|
+
integer_to_string_padded(result + 4, 2, month);
|
715
|
+
integer_to_string_padded(result + 6, 2, day);
|
716
|
+
|
717
|
+
return std::string(result, sizeof(result));
|
718
|
+
}
|
719
|
+
|
720
|
+
static UtcDate convert(const std::string &value) EXCEPT(FieldConvertError) {
|
721
|
+
if (value.size() != 8) {
|
722
|
+
throw FieldConvertError(value);
|
723
|
+
}
|
724
|
+
|
725
|
+
int i = 0;
|
726
|
+
for (int c = 0; c < 8; ++c) {
|
727
|
+
if (!IS_DIGIT(value[i++])) {
|
728
|
+
throw FieldConvertError(value);
|
729
|
+
}
|
730
|
+
}
|
731
|
+
|
732
|
+
int year, mon, mday;
|
733
|
+
|
734
|
+
i = 0;
|
735
|
+
|
736
|
+
year = value[i++] - '0';
|
737
|
+
year = 10 * year + value[i++] - '0';
|
738
|
+
year = 10 * year + value[i++] - '0';
|
739
|
+
year = 10 * year + value[i++] - '0';
|
740
|
+
|
741
|
+
mon = value[i++] - '0';
|
742
|
+
mon = 10 * mon + value[i++] - '0';
|
743
|
+
if (mon < 1 || 12 < mon) {
|
744
|
+
throw FieldConvertError(value);
|
745
|
+
}
|
746
|
+
|
747
|
+
mday = value[i++] - '0';
|
748
|
+
mday = 10 * mday + value[i++] - '0';
|
749
|
+
if (mday < 1 || 31 < mday) {
|
750
|
+
throw FieldConvertError(value);
|
751
|
+
}
|
752
|
+
|
753
|
+
return UtcDateOnly(mday, mon, year);
|
754
|
+
}
|
755
|
+
};
|
756
|
+
|
757
|
+
typedef UtcDateConvertor UtcDateOnlyConvertor;
|
758
|
+
|
759
|
+
typedef StringConvertor STRING_CONVERTOR;
|
760
|
+
typedef CharConvertor CHAR_CONVERTOR;
|
761
|
+
typedef DoubleConvertor PRICE_CONVERTOR;
|
762
|
+
typedef IntConvertor INT_CONVERTOR;
|
763
|
+
typedef Int64Convertor INT64_CONVERTOR;
|
764
|
+
typedef DoubleConvertor AMT_CONVERTOR;
|
765
|
+
typedef DoubleConvertor QTY_CONVERTOR;
|
766
|
+
typedef StringConvertor CURRENCY_CONVERTOR;
|
767
|
+
typedef StringConvertor MULTIPLEVALUESTRING_CONVERTOR;
|
768
|
+
typedef StringConvertor MULTIPLESTRINGVALUE_CONVERTOR;
|
769
|
+
typedef StringConvertor MULTIPLECHARVALUE_CONVERTOR;
|
770
|
+
typedef StringConvertor EXCHANGE_CONVERTOR;
|
771
|
+
typedef UtcTimeStampConvertor UTCTIMESTAMP_CONVERTOR;
|
772
|
+
typedef BoolConvertor BOOLEAN_CONVERTOR;
|
773
|
+
typedef StringConvertor LOCALMKTTIME_CONVERTOR;
|
774
|
+
typedef StringConvertor LOCALMKTDATE_CONVERTOR;
|
775
|
+
typedef StringConvertor DATA_CONVERTOR;
|
776
|
+
typedef DoubleConvertor FLOAT_CONVERTOR;
|
777
|
+
typedef DoubleConvertor PRICEOFFSET_CONVERTOR;
|
778
|
+
typedef StringConvertor MONTHYEAR_CONVERTOR;
|
779
|
+
typedef StringConvertor DAYOFMONTH_CONVERTOR;
|
780
|
+
typedef UtcDateConvertor UTCDATE_CONVERTOR;
|
781
|
+
typedef UtcTimeOnlyConvertor UTCTIMEONLY_CONVERTOR;
|
782
|
+
typedef IntConvertor NUMINGROUP_CONVERTOR;
|
783
|
+
typedef DoubleConvertor PERCENTAGE_CONVERTOR;
|
784
|
+
typedef UInt64Convertor SEQNUM_CONVERTOR;
|
785
|
+
typedef IntConvertor TAGNUM_CONVERTOR;
|
786
|
+
typedef IntConvertor LENGTH_CONVERTOR;
|
787
|
+
typedef StringConvertor COUNTRY_CONVERTOR;
|
788
|
+
typedef StringConvertor TZTIMEONLY_CONVERTOR;
|
789
|
+
typedef StringConvertor TZTIMESTAMP_CONVERTOR;
|
790
|
+
typedef StringConvertor XMLDATA_CONVERTOR;
|
791
|
+
typedef StringConvertor LANGUAGE_CONVERTOR;
|
792
|
+
typedef StringConvertor XID_CONVERTOR;
|
793
|
+
typedef StringConvertor XIDREF_CONVERTOR;
|
794
|
+
typedef CheckSumConvertor CHECKSUM_CONVERTOR;
|
795
|
+
} // namespace FIX
|
796
|
+
|
797
|
+
#undef PRAGMA_POP
|
798
|
+
#undef PRAGMA_PUSH
|
799
|
+
|
800
|
+
#endif // FIX_FIELDCONVERTORS_H
|