quickfix_ruby 1.14.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (149) hide show
  1. checksums.yaml +7 -0
  2. data/ext/quickfix/Acceptor.cpp +248 -0
  3. data/ext/quickfix/Acceptor.h +127 -0
  4. data/ext/quickfix/Allocator.h +9 -0
  5. data/ext/quickfix/Application.h +127 -0
  6. data/ext/quickfix/AtomicCount.h +109 -0
  7. data/ext/quickfix/DOMDocument.h +74 -0
  8. data/ext/quickfix/DataDictionary.cpp +618 -0
  9. data/ext/quickfix/DataDictionary.h +539 -0
  10. data/ext/quickfix/DataDictionaryProvider.cpp +71 -0
  11. data/ext/quickfix/DataDictionaryProvider.h +70 -0
  12. data/ext/quickfix/DatabaseConnectionID.h +105 -0
  13. data/ext/quickfix/DatabaseConnectionPool.h +91 -0
  14. data/ext/quickfix/Dictionary.cpp +162 -0
  15. data/ext/quickfix/Dictionary.h +94 -0
  16. data/ext/quickfix/Event.h +95 -0
  17. data/ext/quickfix/Exceptions.h +299 -0
  18. data/ext/quickfix/Field.h +672 -0
  19. data/ext/quickfix/FieldConvertors.h +863 -0
  20. data/ext/quickfix/FieldMap.cpp +238 -0
  21. data/ext/quickfix/FieldMap.h +244 -0
  22. data/ext/quickfix/FieldNumbers.h +46 -0
  23. data/ext/quickfix/FieldTypes.cpp +64 -0
  24. data/ext/quickfix/FieldTypes.h +698 -0
  25. data/ext/quickfix/Fields.h +31 -0
  26. data/ext/quickfix/FileLog.cpp +200 -0
  27. data/ext/quickfix/FileLog.h +112 -0
  28. data/ext/quickfix/FileStore.cpp +332 -0
  29. data/ext/quickfix/FileStore.h +129 -0
  30. data/ext/quickfix/FixFieldNumbers.h +1537 -0
  31. data/ext/quickfix/FixFields.h +1538 -0
  32. data/ext/quickfix/FixValues.h +3281 -0
  33. data/ext/quickfix/FlexLexer.h +188 -0
  34. data/ext/quickfix/Group.cpp +64 -0
  35. data/ext/quickfix/Group.h +73 -0
  36. data/ext/quickfix/HtmlBuilder.h +186 -0
  37. data/ext/quickfix/HttpConnection.cpp +739 -0
  38. data/ext/quickfix/HttpConnection.h +78 -0
  39. data/ext/quickfix/HttpMessage.cpp +149 -0
  40. data/ext/quickfix/HttpMessage.h +133 -0
  41. data/ext/quickfix/HttpParser.cpp +49 -0
  42. data/ext/quickfix/HttpParser.h +54 -0
  43. data/ext/quickfix/HttpServer.cpp +169 -0
  44. data/ext/quickfix/HttpServer.h +78 -0
  45. data/ext/quickfix/Initiator.cpp +289 -0
  46. data/ext/quickfix/Initiator.h +149 -0
  47. data/ext/quickfix/Log.cpp +77 -0
  48. data/ext/quickfix/Log.h +179 -0
  49. data/ext/quickfix/Message.cpp +580 -0
  50. data/ext/quickfix/Message.h +370 -0
  51. data/ext/quickfix/MessageCracker.h +188 -0
  52. data/ext/quickfix/MessageSorters.cpp +105 -0
  53. data/ext/quickfix/MessageSorters.h +156 -0
  54. data/ext/quickfix/MessageStore.cpp +146 -0
  55. data/ext/quickfix/MessageStore.h +174 -0
  56. data/ext/quickfix/Mutex.h +131 -0
  57. data/ext/quickfix/MySQLConnection.h +194 -0
  58. data/ext/quickfix/MySQLLog.cpp +275 -0
  59. data/ext/quickfix/MySQLLog.h +145 -0
  60. data/ext/quickfix/MySQLStore.cpp +331 -0
  61. data/ext/quickfix/MySQLStore.h +142 -0
  62. data/ext/quickfix/NullStore.cpp +54 -0
  63. data/ext/quickfix/NullStore.h +99 -0
  64. data/ext/quickfix/OdbcConnection.h +266 -0
  65. data/ext/quickfix/OdbcLog.cpp +252 -0
  66. data/ext/quickfix/OdbcLog.h +117 -0
  67. data/ext/quickfix/OdbcStore.cpp +338 -0
  68. data/ext/quickfix/OdbcStore.h +113 -0
  69. data/ext/quickfix/PUGIXML_DOMDocument.cpp +112 -0
  70. data/ext/quickfix/PUGIXML_DOMDocument.h +81 -0
  71. data/ext/quickfix/Parser.cpp +103 -0
  72. data/ext/quickfix/Parser.h +57 -0
  73. data/ext/quickfix/PostgreSQLConnection.h +176 -0
  74. data/ext/quickfix/PostgreSQLLog.cpp +276 -0
  75. data/ext/quickfix/PostgreSQLLog.h +144 -0
  76. data/ext/quickfix/PostgreSQLStore.cpp +334 -0
  77. data/ext/quickfix/PostgreSQLStore.h +141 -0
  78. data/ext/quickfix/Queue.h +75 -0
  79. data/ext/quickfix/QuickfixRuby.cpp +252066 -0
  80. data/ext/quickfix/QuickfixRuby.h +34 -0
  81. data/ext/quickfix/Responder.h +43 -0
  82. data/ext/quickfix/Session.cpp +1487 -0
  83. data/ext/quickfix/Session.h +335 -0
  84. data/ext/quickfix/SessionFactory.cpp +274 -0
  85. data/ext/quickfix/SessionFactory.h +86 -0
  86. data/ext/quickfix/SessionID.h +170 -0
  87. data/ext/quickfix/SessionSettings.cpp +189 -0
  88. data/ext/quickfix/SessionSettings.h +171 -0
  89. data/ext/quickfix/SessionState.h +231 -0
  90. data/ext/quickfix/Settings.cpp +100 -0
  91. data/ext/quickfix/Settings.h +53 -0
  92. data/ext/quickfix/SharedArray.h +150 -0
  93. data/ext/quickfix/SocketAcceptor.cpp +222 -0
  94. data/ext/quickfix/SocketAcceptor.h +75 -0
  95. data/ext/quickfix/SocketConnection.cpp +238 -0
  96. data/ext/quickfix/SocketConnection.h +103 -0
  97. data/ext/quickfix/SocketConnector.cpp +116 -0
  98. data/ext/quickfix/SocketConnector.h +67 -0
  99. data/ext/quickfix/SocketInitiator.cpp +260 -0
  100. data/ext/quickfix/SocketInitiator.h +81 -0
  101. data/ext/quickfix/SocketMonitor.cpp +335 -0
  102. data/ext/quickfix/SocketMonitor.h +111 -0
  103. data/ext/quickfix/SocketServer.cpp +177 -0
  104. data/ext/quickfix/SocketServer.h +100 -0
  105. data/ext/quickfix/ThreadedSocketAcceptor.cpp +258 -0
  106. data/ext/quickfix/ThreadedSocketAcceptor.h +98 -0
  107. data/ext/quickfix/ThreadedSocketConnection.cpp +209 -0
  108. data/ext/quickfix/ThreadedSocketConnection.h +82 -0
  109. data/ext/quickfix/ThreadedSocketInitiator.cpp +268 -0
  110. data/ext/quickfix/ThreadedSocketInitiator.h +84 -0
  111. data/ext/quickfix/TimeRange.cpp +173 -0
  112. data/ext/quickfix/TimeRange.h +258 -0
  113. data/ext/quickfix/Utility.cpp +537 -0
  114. data/ext/quickfix/Utility.h +219 -0
  115. data/ext/quickfix/Values.h +62 -0
  116. data/ext/quickfix/config.h +0 -0
  117. data/ext/quickfix/config_windows.h +0 -0
  118. data/ext/quickfix/extconf.rb +12 -0
  119. data/ext/quickfix/index.h +37 -0
  120. data/ext/quickfix/pugiconfig.hpp +72 -0
  121. data/ext/quickfix/pugixml.cpp +10765 -0
  122. data/ext/quickfix/pugixml.hpp +1341 -0
  123. data/ext/quickfix/strptime.h +7 -0
  124. data/lib/quickfix40.rb +274 -0
  125. data/lib/quickfix41.rb +351 -0
  126. data/lib/quickfix42.rb +1184 -0
  127. data/lib/quickfix43.rb +3504 -0
  128. data/lib/quickfix44.rb +10721 -0
  129. data/lib/quickfix50.rb +13426 -0
  130. data/lib/quickfix50sp1.rb +15629 -0
  131. data/lib/quickfix50sp2.rb +17068 -0
  132. data/lib/quickfix_fields.rb +19853 -0
  133. data/lib/quickfix_ruby.rb +82 -0
  134. data/lib/quickfixt11.rb +70 -0
  135. data/spec/FIX40.xml +862 -0
  136. data/spec/FIX41.xml +1285 -0
  137. data/spec/FIX42.xml +2746 -0
  138. data/spec/FIX43.xml +4229 -0
  139. data/spec/FIX44.xml +6596 -0
  140. data/spec/FIX50.xml +8137 -0
  141. data/spec/FIX50SP1.xml +9496 -0
  142. data/spec/FIX50SP2.xml +10011 -0
  143. data/spec/FIXT11.xml +313 -0
  144. data/test/test_DataDictionaryTestCase.rb +268 -0
  145. data/test/test_DictionaryTestCase.rb +112 -0
  146. data/test/test_FieldBaseTestCase.rb +24 -0
  147. data/test/test_MessageTestCase.rb +368 -0
  148. data/test/test_SessionSettingsTestCase.rb +41 -0
  149. metadata +193 -0
@@ -0,0 +1,672 @@
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_FIELD
23
+ #define FIX_FIELD
24
+
25
+ #ifdef _MSC_VER
26
+ #pragma warning( disable : 4786 )
27
+ #endif
28
+
29
+ #include <sstream>
30
+ #include <numeric>
31
+ #include "FieldNumbers.h"
32
+ #include "FieldConvertors.h"
33
+ #include "FieldTypes.h"
34
+ #include "Utility.h"
35
+
36
+ namespace FIX
37
+ {
38
+ /**
39
+ * Base representation of all Field classes.
40
+ *
41
+ * This base class is the lowest common denominator of all fields. It
42
+ * keeps all fields in its most generic string representation with its
43
+ * integer tag.
44
+ */
45
+ class FieldBase
46
+ {
47
+
48
+ /// Class used to store field metrics like total length and checksum
49
+ class field_metrics
50
+ {
51
+ public:
52
+
53
+ field_metrics( const size_t length, const int checksum )
54
+ : m_length( length )
55
+ , m_checksum( checksum )
56
+ {}
57
+
58
+ size_t getLength() const
59
+ { return m_length; }
60
+
61
+ int getCheckSum() const
62
+ { return m_checksum; }
63
+
64
+ bool isValid() const
65
+ { return m_length > 0; }
66
+
67
+ private:
68
+
69
+ size_t m_length;
70
+ int m_checksum;
71
+ };
72
+
73
+ friend class Message;
74
+
75
+ /// Constructor which also calculates field metrics
76
+ FieldBase( int field,
77
+ std::string::const_iterator valueStart,
78
+ std::string::const_iterator valueEnd,
79
+ std::string::const_iterator tagStart,
80
+ std::string::const_iterator tagEnd )
81
+ : m_field( field )
82
+ , m_string( valueStart, valueEnd )
83
+ , m_metrics( calculateMetrics( tagStart, tagEnd ) )
84
+ {}
85
+
86
+ public:
87
+ FieldBase( int field, const std::string& string )
88
+ : m_field( field ), m_string(string), m_metrics( no_metrics() )
89
+ {}
90
+
91
+ virtual ~FieldBase() {}
92
+
93
+ void setField( int field )
94
+ {
95
+ m_field = field;
96
+ m_metrics = no_metrics();
97
+ m_data.clear();
98
+ }
99
+
100
+ void setString( const std::string& string )
101
+ {
102
+ m_string = string;
103
+ m_metrics = no_metrics();
104
+ m_data.clear();
105
+ }
106
+
107
+ /// Get the fields integer tag.
108
+ int getField() const
109
+ { return m_field; }
110
+
111
+ /// Get the string representation of the fields value.
112
+ const std::string& getString() const
113
+ { return m_string; }
114
+
115
+ /// Get the string representation of the Field (i.e.) 55=MSFT[SOH]
116
+ const std::string& getFixString() const
117
+ {
118
+ if( m_data.empty() )
119
+ encodeTo( m_data );
120
+
121
+ return m_data;
122
+ }
123
+
124
+ /// Get the length of the fields string representation
125
+ size_t getLength() const
126
+ {
127
+ calculate();
128
+ return m_metrics.getLength();
129
+ }
130
+
131
+ /// Get the total value the fields characters added together
132
+ int getTotal() const
133
+ {
134
+ calculate();
135
+ return m_metrics.getCheckSum();
136
+ }
137
+
138
+ /// Compares fields based on their tag numbers
139
+ bool operator < ( const FieldBase& field ) const
140
+ { return m_field < field.m_field; }
141
+
142
+ private:
143
+
144
+ void calculate() const
145
+ {
146
+ if( m_metrics.isValid() ) return;
147
+
148
+ m_metrics = calculateMetrics( getFixString() );
149
+ }
150
+
151
+ /// Serializes string representation of the Field to input string
152
+ void encodeTo( std::string& result ) const
153
+ {
154
+ size_t tagLength = FIX::number_of_symbols_in( m_field ) + 1;
155
+ size_t totalLength = tagLength + m_string.length() + 1;
156
+
157
+ result.resize( totalLength );
158
+
159
+ char * buf = (char*)result.c_str();
160
+ FIX::integer_to_string( buf, tagLength, m_field );
161
+
162
+ buf[tagLength - 1] = '=';
163
+ memcpy( buf + tagLength, m_string.data(), m_string.length() );
164
+ buf[totalLength - 1] = '\001';
165
+ }
166
+
167
+ static field_metrics no_metrics()
168
+ {
169
+ return field_metrics( 0, 0 );
170
+ }
171
+
172
+ /// Calculate metrics for any input string
173
+ static field_metrics calculateMetrics(
174
+ std::string::const_iterator const start,
175
+ std::string::const_iterator const end )
176
+ {
177
+ int checksum = 0;
178
+ for ( std::string::const_iterator str = start; str != end; ++str )
179
+ checksum += (unsigned char)( *str );
180
+
181
+ return field_metrics( std::distance( start, end ), checksum );
182
+ }
183
+
184
+ static field_metrics calculateMetrics( const std::string& field )
185
+ {
186
+ return calculateMetrics( field.begin(), field.end() );
187
+ }
188
+
189
+ int m_field;
190
+ std::string m_string;
191
+ mutable std::string m_data;
192
+ mutable field_metrics m_metrics;
193
+ };
194
+ /*! @} */
195
+
196
+ inline std::ostream& operator <<
197
+ ( std::ostream& stream, const FieldBase& field )
198
+ {
199
+ stream << field.getString();
200
+ return stream;
201
+ }
202
+
203
+ /**
204
+ * MSC doesn't support partial template specialization so we have this.
205
+ * this is here to provide equality checking against native char arrays.
206
+ */
207
+ class StringField : public FieldBase
208
+ {
209
+ public:
210
+ explicit StringField( int field, const std::string& data )
211
+ : FieldBase( field, data ) {}
212
+ StringField( int field )
213
+ : FieldBase( field, "" ) {}
214
+
215
+ void setValue( const std::string& value )
216
+ { setString( value ); }
217
+ const std::string& getValue() const
218
+ { return getString(); }
219
+ operator const std::string&() const
220
+ { return getString(); }
221
+
222
+ bool operator<( const StringField& rhs ) const
223
+ { return getString() < rhs.getString(); }
224
+ bool operator>( const StringField& rhs ) const
225
+ { return getString() > rhs.getString(); }
226
+ bool operator==( const StringField& rhs ) const
227
+ { return getString() == rhs.getString(); }
228
+ bool operator!=( const StringField& rhs ) const
229
+ { return getString() != rhs.getString(); }
230
+ bool operator<=( const StringField& rhs ) const
231
+ { return getString() <= rhs.getString(); }
232
+ bool operator>=( const StringField& rhs ) const
233
+ { return getString() >= rhs.getString(); }
234
+ friend bool operator<( const StringField&, const char* );
235
+ friend bool operator<( const char*, const StringField& );
236
+ friend bool operator>( const StringField&, const char* );
237
+ friend bool operator>( const char*, const StringField& );
238
+ friend bool operator==( const StringField&, const char* );
239
+ friend bool operator==( const char*, const StringField& );
240
+ friend bool operator!=( const StringField&, const char* );
241
+ friend bool operator!=( const char*, const StringField& );
242
+ friend bool operator<=( const StringField&, const char* );
243
+ friend bool operator<=( const char*, const StringField& );
244
+ friend bool operator>=( const StringField&, const char* );
245
+ friend bool operator>=( const char*, const StringField& );
246
+
247
+ friend bool operator<( const StringField&, const std::string& );
248
+ friend bool operator<( const std::string&, const StringField& );
249
+ friend bool operator>( const StringField&, const std::string& );
250
+ friend bool operator>( const std::string&, const StringField& );
251
+ friend bool operator==( const StringField&, const std::string& );
252
+ friend bool operator==( const std::string&, const StringField& );
253
+ friend bool operator!=( const StringField&, const std::string& );
254
+ friend bool operator!=( const std::string&, const StringField& );
255
+ friend bool operator<=( const StringField&, const std::string& );
256
+ friend bool operator<=( const std::string&, const StringField& );
257
+ friend bool operator>=( const StringField&, const std::string& );
258
+ friend bool operator>=( const std::string&, const StringField& );
259
+ };
260
+
261
+ inline bool operator<( const StringField& lhs, const char* rhs )
262
+ { return lhs.getValue() < rhs; }
263
+ inline bool operator<( const char* lhs, const StringField& rhs )
264
+ { return lhs < rhs.getValue(); }
265
+ inline bool operator>( const StringField& lhs, const char* rhs )
266
+ { return lhs.getValue() > rhs; }
267
+ inline bool operator>( const char* lhs, const StringField& rhs )
268
+ { return lhs > rhs.getValue(); }
269
+ inline bool operator==( const StringField& lhs, const char* rhs )
270
+ { return lhs.getValue() == rhs; }
271
+ inline bool operator==( const char* lhs, const StringField& rhs )
272
+ { return lhs == rhs.getValue(); }
273
+ inline bool operator!=( const StringField& lhs, const char* rhs )
274
+ { return lhs.getValue() != rhs; }
275
+ inline bool operator!=( const char* lhs, const StringField& rhs )
276
+ { return lhs != rhs.getValue(); }
277
+ inline bool operator<=( const StringField& lhs, const char* rhs )
278
+ { return lhs.getValue() <= rhs; }
279
+ inline bool operator<=( const char* lhs, const StringField& rhs )
280
+ { return lhs <= rhs.getValue(); }
281
+ inline bool operator>=( const StringField& lhs, const char* rhs )
282
+ { return lhs.getValue() >= rhs; }
283
+ inline bool operator>=( const char* lhs, const StringField& rhs )
284
+ { return lhs >= rhs.getValue(); }
285
+
286
+ inline bool operator<( const StringField& lhs, const std::string& rhs )
287
+ { return lhs.getValue() < rhs; }
288
+ inline bool operator<( const std::string& lhs, const StringField& rhs )
289
+ { return lhs < rhs.getValue(); }
290
+ inline bool operator>( const StringField& lhs, const std::string& rhs )
291
+ { return lhs.getValue() > rhs; }
292
+ inline bool operator>( const std::string& lhs, const StringField& rhs )
293
+ { return lhs > rhs.getValue(); }
294
+ inline bool operator==( const StringField& lhs, const std::string& rhs )
295
+ { return lhs.getValue() == rhs; }
296
+ inline bool operator==( const std::string& lhs, const StringField& rhs )
297
+ { return lhs == rhs.getValue(); }
298
+ inline bool operator!=( const StringField& lhs, const std::string& rhs )
299
+ { return lhs.getValue() != rhs; }
300
+ inline bool operator!=( const std::string& lhs, const StringField& rhs )
301
+ { return lhs != rhs.getValue(); }
302
+ inline bool operator<=( const StringField& lhs, const std::string& rhs )
303
+ { return lhs.getValue() <= rhs; }
304
+ inline bool operator<=( const std::string& lhs, const StringField& rhs )
305
+ { return lhs <= rhs.getValue(); }
306
+ inline bool operator>=( const StringField& lhs, const std::string& rhs )
307
+ { return lhs.getValue() >= rhs; }
308
+ inline bool operator>=( const std::string& lhs, const StringField& rhs )
309
+ { return lhs >= rhs.getValue(); }
310
+
311
+ /// Field that contains a character value
312
+ class CharField : public FieldBase
313
+ {
314
+ public:
315
+ explicit CharField( int field, char data )
316
+ : FieldBase( field, CharConvertor::convert( data ) ) {}
317
+ CharField( int field )
318
+ : FieldBase( field, "" ) {}
319
+
320
+ void setValue( char value )
321
+ { setString( CharConvertor::convert( value ) ); }
322
+ char getValue() const throw ( IncorrectDataFormat )
323
+ { try
324
+ { return CharConvertor::convert( getString() ); }
325
+ catch( FieldConvertError& )
326
+ { throw IncorrectDataFormat( getField(), getString() ); } }
327
+ operator char() const
328
+ { return getValue(); }
329
+ };
330
+
331
+ /// Field that contains a double value
332
+ class DoubleField : public FieldBase
333
+ {
334
+ public:
335
+ explicit DoubleField( int field, double data, int padding = 0 )
336
+ : FieldBase( field, DoubleConvertor::convert( data, padding ) ) {}
337
+ DoubleField( int field )
338
+ : FieldBase( field, "" ) {}
339
+
340
+ void setValue( double value, int padding = 0 )
341
+ { setString( DoubleConvertor::convert( value, padding ) ); }
342
+ double getValue() const throw ( IncorrectDataFormat )
343
+ { try
344
+ { return DoubleConvertor::convert( getString() ); }
345
+ catch( FieldConvertError& )
346
+ { throw IncorrectDataFormat( getField(), getString() ); } }
347
+ operator double() const
348
+ { return getValue(); }
349
+ };
350
+
351
+ /// Field that contains an integer value
352
+ class IntField : public FieldBase
353
+ {
354
+ public:
355
+ explicit IntField( int field, int data )
356
+ : FieldBase( field, IntConvertor::convert( data ) ) {}
357
+ IntField( int field )
358
+ : FieldBase( field, "" ) {}
359
+
360
+ void setValue( int value )
361
+ { setString( IntConvertor::convert( value ) ); }
362
+ int getValue() const throw ( IncorrectDataFormat )
363
+ { try
364
+ { return IntConvertor::convert( getString() ); }
365
+ catch( FieldConvertError& )
366
+ { throw IncorrectDataFormat( getField(), getString() ); } }
367
+ operator const int() const
368
+ { return getValue(); }
369
+ };
370
+
371
+ /// Field that contains a boolean value
372
+ class BoolField : public FieldBase
373
+ {
374
+ public:
375
+ explicit BoolField( int field, bool data )
376
+ : FieldBase( field, BoolConvertor::convert( data ) ) {}
377
+ BoolField( int field )
378
+ : FieldBase( field, "" ) {}
379
+
380
+ void setValue( bool value )
381
+ { setString( BoolConvertor::convert( value ) ); }
382
+ bool getValue() const throw ( IncorrectDataFormat )
383
+ { try
384
+ { return BoolConvertor::convert( getString() ); }
385
+ catch( FieldConvertError& )
386
+ { throw IncorrectDataFormat( getField(), getString() ); } }
387
+ operator bool() const
388
+ { return getValue(); }
389
+ };
390
+
391
+ /// Field that contains a UTC time stamp value
392
+ class UtcTimeStampField : public FieldBase
393
+ {
394
+ public:
395
+ explicit UtcTimeStampField( int field, const UtcTimeStamp& data, bool showMilliseconds = false )
396
+ : FieldBase( field, UtcTimeStampConvertor::convert( data, showMilliseconds ) ) {}
397
+ UtcTimeStampField( int field, bool showMilliseconds = false )
398
+ : FieldBase( field, UtcTimeStampConvertor::convert( UtcTimeStamp(), showMilliseconds ) ) {}
399
+
400
+ void setValue( const UtcTimeStamp& value )
401
+ { setString( UtcTimeStampConvertor::convert( value ) ); }
402
+ UtcTimeStamp getValue() const throw ( IncorrectDataFormat )
403
+ { try
404
+ { return UtcTimeStampConvertor::convert( getString() ); }
405
+ catch( FieldConvertError& )
406
+ { throw IncorrectDataFormat( getField(), getString() ); } }
407
+ operator UtcTimeStamp() const
408
+ { return getValue(); }
409
+
410
+ bool operator<( const UtcTimeStampField& rhs ) const
411
+ { return getValue() < rhs.getValue(); }
412
+ bool operator==( const UtcTimeStampField& rhs ) const
413
+ { return getValue() == rhs.getValue(); }
414
+ bool operator!=( const UtcTimeStampField& rhs ) const
415
+ { return getValue() != rhs.getValue(); }
416
+ };
417
+
418
+ /// Field that contains a UTC date value
419
+ class UtcDateField : public FieldBase
420
+ {
421
+ public:
422
+ explicit UtcDateField( int field, const UtcDate& data )
423
+ : FieldBase( field, UtcDateConvertor::convert( data ) ) {}
424
+ UtcDateField( int field )
425
+ : FieldBase( field, UtcDateConvertor::convert( UtcDate() ) ) {}
426
+
427
+ void setValue( const UtcDate& value )
428
+ { setString( UtcDateConvertor::convert( value ) ); }
429
+ UtcDate getValue() const throw ( IncorrectDataFormat )
430
+ { try
431
+ { return UtcDateConvertor::convert( getString() ); }
432
+ catch( FieldConvertError& )
433
+ { throw IncorrectDataFormat( getField(), getString() ); } }
434
+ operator UtcDate() const
435
+ { return getValue(); }
436
+
437
+ bool operator<( const UtcDateField& rhs ) const
438
+ { return getValue() < rhs.getValue(); }
439
+ bool operator==( const UtcDateField& rhs ) const
440
+ { return getValue() == rhs.getValue(); }
441
+ bool operator!=( const UtcDateField& rhs ) const
442
+ { return getValue() != rhs.getValue(); }
443
+ };
444
+
445
+ /// Field that contains a UTC time value
446
+ class UtcTimeOnlyField : public FieldBase
447
+ {
448
+ public:
449
+ explicit UtcTimeOnlyField( int field, const UtcTimeOnly& data, bool showMilliseconds = false )
450
+ : FieldBase( field, UtcTimeOnlyConvertor::convert( data, showMilliseconds ) ) {}
451
+ UtcTimeOnlyField( int field, bool showMilliseconds = false )
452
+ : FieldBase( field, UtcTimeOnlyConvertor::convert( UtcTimeOnly(), showMilliseconds ) ) {}
453
+
454
+ void setValue( const UtcTimeOnly& value )
455
+ { setString( UtcTimeOnlyConvertor::convert( value ) ); }
456
+ UtcTimeOnly getValue() const throw ( IncorrectDataFormat )
457
+ { try
458
+ { return UtcTimeOnlyConvertor::convert( getString() ); }
459
+ catch( FieldConvertError& )
460
+ { throw IncorrectDataFormat( getField(), getString() ); } }
461
+ operator UtcTimeOnly() const
462
+ { return getValue(); }
463
+
464
+ bool operator<( const UtcTimeOnlyField& rhs ) const
465
+ { return getValue() < rhs.getValue(); }
466
+ bool operator==( const UtcTimeOnlyField& rhs ) const
467
+ { return getValue() == rhs.getValue(); }
468
+ bool operator!=( const UtcTimeOnlyField& rhs ) const
469
+ { return getValue() != rhs.getValue(); }
470
+ };
471
+
472
+ /// Field that contains a checksum value
473
+ class CheckSumField : public FieldBase
474
+ {
475
+ public:
476
+ explicit CheckSumField( int field, int data )
477
+ : FieldBase( field, CheckSumConvertor::convert( data ) ) {}
478
+ CheckSumField( int field )
479
+ : FieldBase( field, "" ) {}
480
+
481
+ void setValue( int value )
482
+ { setString( CheckSumConvertor::convert( value ) ); }
483
+ int getValue() const throw ( IncorrectDataFormat )
484
+ { try
485
+ { return CheckSumConvertor::convert( getString() ); }
486
+ catch( FieldConvertError& )
487
+ { throw IncorrectDataFormat( getField(), getString() ); } }
488
+ operator const int() const
489
+ { return getValue(); }
490
+ };
491
+
492
+ typedef DoubleField PriceField;
493
+ typedef DoubleField AmtField;
494
+ typedef DoubleField QtyField;
495
+ typedef StringField CurrencyField;
496
+ typedef StringField MultipleValueStringField;
497
+ typedef StringField MultipleStringValueField;
498
+ typedef StringField MultipleCharValueField;
499
+ typedef StringField ExchangeField;
500
+ typedef StringField LocalMktDateField;
501
+ typedef StringField DataField;
502
+ typedef DoubleField FloatField;
503
+ typedef DoubleField PriceOffsetField;
504
+ typedef StringField MonthField;
505
+ typedef StringField MonthYearField;
506
+ typedef StringField DayOfMonthField;
507
+ typedef UtcDateField UtcDateOnlyField;
508
+ typedef IntField LengthField;
509
+ typedef IntField NumInGroupField;
510
+ typedef IntField SeqNumField;
511
+ typedef DoubleField PercentageField;
512
+ typedef StringField CountryField;
513
+ typedef StringField TzTimeOnlyField;
514
+ typedef StringField TzTimeStampField;
515
+ }
516
+
517
+ #define DEFINE_FIELD_CLASS_NUM( NAME, TOK, TYPE, NUM ) \
518
+ class NAME : public TOK##Field { public: \
519
+ NAME() : TOK##Field(NUM) {} \
520
+ NAME(const TYPE& value) : TOK##Field(NUM, value) {} \
521
+ }
522
+
523
+ #define DEFINE_FIELD_CLASS( NAME, TOK, TYPE ) \
524
+ DEFINE_FIELD_CLASS_NUM(NAME, TOK, TYPE, FIELD::NAME)
525
+
526
+ #define DEFINE_DEPRECATED_FIELD_CLASS( NAME, TOK, TYPE ) \
527
+ DEFINE_FIELD_CLASS_NUM(NAME, TOK, TYPE, DEPRECATED_FIELD::NAME)
528
+
529
+ #define DEFINE_FIELD_TIMECLASS_NUM( NAME, TOK, TYPE, NUM ) \
530
+ class NAME : public TOK##Field { public: \
531
+ NAME() : TOK##Field(NUM, false) {} \
532
+ NAME(bool showMilliseconds) : TOK##Field(NUM, showMilliseconds) {} \
533
+ NAME(const TYPE& value) : TOK##Field(NUM, value) {} \
534
+ NAME(const TYPE& value, bool showMilliseconds) : TOK##Field(NUM, value, showMilliseconds) {} \
535
+ }
536
+
537
+ #define DEFINE_FIELD_TIMECLASS( NAME, TOK, TYPE ) \
538
+ DEFINE_FIELD_TIMECLASS_NUM(NAME, TOK, TYPE, FIELD::NAME)
539
+
540
+ #define DEFINE_DEPRECATED_FIELD_TIMECLASS( NAME, TOK, TYPE ) \
541
+ DEFINE_FIELD_TIMECLASS_NUM(NAME, TOK, TYPE, DEPRECATED_FIELD::NAME)
542
+
543
+ #define DEFINE_CHECKSUM( NAME ) \
544
+ DEFINE_FIELD_CLASS(NAME, CheckSum, FIX::INT)
545
+ #define DEFINE_STRING( NAME ) \
546
+ DEFINE_FIELD_CLASS(NAME, String, FIX::STRING)
547
+ #define DEFINE_CHAR( NAME ) \
548
+ DEFINE_FIELD_CLASS(NAME, Char, FIX::CHAR)
549
+ #define DEFINE_PRICE( NAME ) \
550
+ DEFINE_FIELD_CLASS(NAME, Price, FIX::PRICE)
551
+ #define DEFINE_INT( NAME ) \
552
+ DEFINE_FIELD_CLASS(NAME, Int, FIX::INT)
553
+ #define DEFINE_AMT( NAME ) \
554
+ DEFINE_FIELD_CLASS(NAME, Amt, FIX::AMT)
555
+ #define DEFINE_QTY( NAME ) \
556
+ DEFINE_FIELD_CLASS(NAME, Qty, FIX::QTY)
557
+ #define DEFINE_CURRENCY( NAME ) \
558
+ DEFINE_FIELD_CLASS(NAME, Currency, FIX::CURRENCY)
559
+ #define DEFINE_MULTIPLEVALUESTRING( NAME ) \
560
+ DEFINE_FIELD_CLASS(NAME, MultipleValueString, FIX::MULTIPLEVALUESTRING)
561
+ #define DEFINE_MULTIPLESTRINGVALUE( NAME ) \
562
+ DEFINE_FIELD_CLASS(NAME, MultipleStringValue, FIX::MULTIPLESTRINGVALUE)
563
+ #define DEFINE_MULTIPLECHARVALUE( NAME ) \
564
+ DEFINE_FIELD_CLASS(NAME, MultipleCharValue, FIX::MULTIPLECHARVALUE)
565
+ #define DEFINE_EXCHANGE( NAME ) \
566
+ DEFINE_FIELD_CLASS(NAME, Exchange, FIX::EXCHANGE)
567
+ #define DEFINE_UTCTIMESTAMP( NAME ) \
568
+ DEFINE_FIELD_TIMECLASS(NAME, UtcTimeStamp, FIX::UTCTIMESTAMP)
569
+ #define DEFINE_BOOLEAN( NAME ) \
570
+ DEFINE_FIELD_CLASS(NAME, Bool, FIX::BOOLEAN)
571
+ #define DEFINE_LOCALMKTDATE( NAME ) \
572
+ DEFINE_FIELD_CLASS(NAME, String, FIX::LOCALMKTDATE)
573
+ #define DEFINE_DATA( NAME ) \
574
+ DEFINE_FIELD_CLASS(NAME, Data, FIX::DATA)
575
+ #define DEFINE_FLOAT( NAME ) \
576
+ DEFINE_FIELD_CLASS(NAME, Float, FIX::FLOAT)
577
+ #define DEFINE_PRICEOFFSET( NAME ) \
578
+ DEFINE_FIELD_CLASS(NAME, PriceOffset, FIX::PRICEOFFSET)
579
+ #define DEFINE_MONTHYEAR( NAME ) \
580
+ DEFINE_FIELD_CLASS(NAME, MonthYear, FIX::MONTHYEAR)
581
+ #define DEFINE_DAYOFMONTH( NAME ) \
582
+ DEFINE_FIELD_CLASS(NAME, DayOfMonth, FIX::DAYOFMONTH)
583
+ #define DEFINE_UTCDATE( NAME ) \
584
+ DEFINE_FIELD_CLASS(NAME, UtcDate, FIX::UTCDATE)
585
+ #define DEFINE_UTCDATEONLY( NAME ) \
586
+ DEFINE_FIELD_CLASS(NAME, UtcDateOnly, FIX::UTCDATEONLY)
587
+ #define DEFINE_UTCTIMEONLY( NAME ) \
588
+ DEFINE_FIELD_CLASS(NAME, UtcTimeOnly, FIX::UTCTIMEONLY)
589
+ #define DEFINE_NUMINGROUP( NAME ) \
590
+ DEFINE_FIELD_CLASS(NAME, NumInGroup, FIX::NUMINGROUP)
591
+ #define DEFINE_SEQNUM( NAME ) \
592
+ DEFINE_FIELD_CLASS(NAME, SeqNum, FIX::SEQNUM)
593
+ #define DEFINE_LENGTH( NAME ) \
594
+ DEFINE_FIELD_CLASS(NAME, Length, FIX::LENGTH)
595
+ #define DEFINE_PERCENTAGE( NAME ) \
596
+ DEFINE_FIELD_CLASS(NAME, Percentage, FIX::PERCENTAGE)
597
+ #define DEFINE_COUNTRY( NAME ) \
598
+ DEFINE_FIELD_CLASS(NAME, Country, FIX::COUNTRY)
599
+ #define DEFINE_TZTIMEONLY( NAME ) \
600
+ DEFINE_FIELD_CLASS(NAME, String, FIX::TZTIMEONLY)
601
+ #define DEFINE_TZTIMESTAMP( NAME ) \
602
+ DEFINE_FIELD_CLASS(NAME, String, FIX::TZTIMESTAMP)
603
+ #define DEFINE_XMLDATA( NAME ) \
604
+ DEFINE_FIELD_CLASS(NAME, String, FIX::XMLDATA)
605
+ #define DEFINE_LANGUAGE( NAME ) \
606
+ DEFINE_FIELD_CLASS(NAME, String, FIX::LANGUAGE)
607
+
608
+ #define USER_DEFINE_STRING( NAME, NUM ) \
609
+ DEFINE_FIELD_CLASS_NUM(NAME, String, FIX::STRING, NUM)
610
+ #define USER_DEFINE_CHAR( NAME, NUM ) \
611
+ DEFINE_FIELD_CLASS_NUM(NAME, Char, FIX::CHAR, NUM)
612
+ #define USER_DEFINE_PRICE( NAME, NUM ) \
613
+ DEFINE_FIELD_CLASS_NUM(NAME, Price, FIX::PRICE, NUM)
614
+ #define USER_DEFINE_INT( NAME, NUM ) \
615
+ DEFINE_FIELD_CLASS_NUM(NAME, Int, FIX::INT, NUM)
616
+ #define USER_DEFINE_AMT( NAME, NUM ) \
617
+ DEFINE_FIELD_CLASS_NUM(NAME, Amt, FIX::AMT, NUM)
618
+ #define USER_DEFINE_QTY( NAME, NUM ) \
619
+ DEFINE_FIELD_CLASS_NUM(NAME, Qty, FIX::QTY, NUM)
620
+ #define USER_DEFINE_CURRENCY( NAME, NUM ) \
621
+ DEFINE_FIELD_CLASS_NUM(NAME, Currency, FIX::CURRENCY, NUM)
622
+ #define USER_DEFINE_MULTIPLEVALUESTRING( NAME, NUM ) \
623
+ DEFINE_FIELD_CLASS_NUM(NAME, MultipleValueString, FIX::MULTIPLEVALUESTRING, NUM)
624
+ #define USER_DEFINE_MULTIPLESTRINGVALUE( NAME, NUM ) \
625
+ DEFINE_FIELD_CLASS_NUM(NAME, MultipleStringValue, FIX::MULTIPLESTRINGVALUE, NUM)
626
+ #define USER_DEFINE_MULTIPLECHARVALUE( NAME, NUM ) \
627
+ DEFINE_FIELD_CLASS_NUM(NAME, MultipleCharValue, FIX::MULTIPLECHARVALUE, NUM)
628
+ #define USER_DEFINE_EXCHANGE( NAME, NUM ) \
629
+ DEFINE_FIELD_CLASS_NUM(NAME, Exchange, FIX::EXCHANGE, NUM)
630
+ #define USER_DEFINE_UTCTIMESTAMP( NAME, NUM ) \
631
+ DEFINE_FIELD_TIMECLASS_NUM(NAME, UtcTimeStamp, FIX::UTCTIMESTAMP, NUM)
632
+ #define USER_DEFINE_BOOLEAN( NAME, NUM ) \
633
+ DEFINE_FIELD_CLASS_NUM(NAME, Bool, FIX::BOOLEAN, NUM)
634
+ #define USER_DEFINE_LOCALMKTDATE( NAME, NUM ) \
635
+ DEFINE_FIELD_CLASS_NUM(NAME, String, FIX::STRING, NUM)
636
+ #define USER_DEFINE_DATA( NAME, NUM ) \
637
+ DEFINE_FIELD_CLASS_NUM(NAME, Data, FIX::DATA, NUM)
638
+ #define USER_DEFINE_FLOAT( NAME, NUM ) \
639
+ DEFINE_FIELD_CLASS_NUM(NAME, Float, FIX::FLOAT, NUM)
640
+ #define USER_DEFINE_PRICEOFFSET( NAME, NUM ) \
641
+ DEFINE_FIELD_CLASS_NUM(NAME, PriceOffset, FIX::PRICEOFFSET, NUM)
642
+ #define USER_DEFINE_MONTHYEAR( NAME, NUM ) \
643
+ DEFINE_FIELD_CLASS_NUM(NAME, MonthYear, FIX::MONTHYEAR, NUM)
644
+ #define USER_DEFINE_DAYOFMONTH( NAME, NUM ) \
645
+ DEFINE_FIELD_CLASS_NUM(NAME, DayOfMonth, FIX::DAYOFMONTH, NUM)
646
+ #define USER_DEFINE_UTCDATE( NAME, NUM ) \
647
+ DEFINE_FIELD_CLASS_NUM(NAME, UtcDate, FIX::UTCDATE, NUM)
648
+ #define USER_DEFINE_UTCDATEONLY( NAME, NUM ) \
649
+ DEFINE_FIELD_CLASS_NUM(NAME, UtcDateOnly, FIX::UTCDATEONLY, NUM)
650
+ #define USER_DEFINE_UTCTIMEONLY( NAME, NUM ) \
651
+ DEFINE_FIELD_CLASS_NUM(NAME, UtcTimeOnly, FIX::UTCTIMEONLY, NUM)
652
+ #define USER_DEFINE_NUMINGROUP( NAME, NUM ) \
653
+ DEFINE_FIELD_CLASS_NUM(NAME, NumInGroup, FIX::NUMINGROUP, NUM)
654
+ #define USER_DEFINE_SEQNUM( NAME, NUM ) \
655
+ DEFINE_FIELD_CLASS_NUM(NAME, SeqNum, FIX::SEQNUM, NUM)
656
+ #define USER_DEFINE_LENGTH( NAME, NUM ) \
657
+ DEFINE_FIELD_CLASS_NUM(NAME, Length, FIX::LENGTH, NUM)
658
+ #define USER_DEFINE_PERCENTAGE( NAME, NUM ) \
659
+ DEFINE_FIELD_CLASS_NUM(NAME, Percentage, FIX::PERCENTAGE, NUM)
660
+ #define USER_DEFINE_COUNTRY( NAME, NUM ) \
661
+ DEFINE_FIELD_CLASS_NUM(NAME, Country, FIX::COUNTRY, NUM)
662
+ #define USER_DEFINE_TZTIMEONLY( NAME, NUM ) \
663
+ DEFINE_FIELD_CLASS_NUM(NAME, String, FIX::TZTIMEONLY, NUM)
664
+ #define USER_DEFINE_TZTIMESTAMP( NAME, NUM ) \
665
+ DEFINE_FIELD_CLASS_NUM(NAME, String, FIX::TZTIMESTAMP, NUM)
666
+ #define USER_DEFINE_XMLDATA( NAME, NUM ) \
667
+ DEFINE_FIELD_CLASS_NUM(NAME, String, FIX::XMLDATA, NUM)
668
+ #define USER_DEFINE_LANGUAGE( NAME, NUM ) \
669
+ DEFINE_FIELD_CLASS_NUM(NAME, String, FIX::LANGUAGE, NUM)
670
+
671
+ #endif
672
+