quickfix_ruby 1.14.3

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 (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,539 @@
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_DATADICTIONARY_H
23
+ #define FIX_DATADICTIONARY_H
24
+
25
+ #ifdef _MSC_VER
26
+ #pragma warning( disable : 4503 4355 4786 4290 )
27
+ #endif
28
+
29
+ #include "Fields.h"
30
+ #include "FieldMap.h"
31
+ #include "DOMDocument.h"
32
+ #include "Exceptions.h"
33
+ #include <set>
34
+ #include <map>
35
+ #include <string.h>
36
+
37
+ namespace FIX
38
+ {
39
+ class FieldMap;
40
+ class Message;
41
+
42
+ /**
43
+ * Represents a data dictionary for a version of %FIX.
44
+ *
45
+ * Generally loaded from an XML document. The DataDictionary is also
46
+ * responsible for validation beyond the basic structure of a message.
47
+ */
48
+
49
+ class DataDictionary
50
+ {
51
+ typedef std::set < int > MsgFields;
52
+ typedef std::map < std::string, MsgFields > MsgTypeToField;
53
+ typedef std::set < std::string > MsgTypes;
54
+ typedef std::set < int > Fields;
55
+ typedef std::map < int, bool > NonBodyFields;
56
+ typedef std::vector< int > OrderedFields;
57
+ typedef message_order OrderedFieldsArray;
58
+ typedef std::map < int, TYPE::Type > FieldTypes;
59
+ typedef std::set < std::string > Values;
60
+ typedef std::map < int, Values > FieldToValue;
61
+ typedef std::map < int, std::string > FieldToName;
62
+ typedef std::map < std::string, int > NameToField;
63
+ typedef std::map < std::pair < int, std::string > , std::string > ValueToName;
64
+ // while FieldToGroup structure seems to be overcomplicated
65
+ // in reality it yields a lot of performance because:
66
+ // 1) avoids memory copying;
67
+ // 2) first lookup is done by comparing integers and not string objects
68
+ // TODO: use hash_map with good hashing algorithm
69
+ typedef std::map < std::string, std::pair < int, DataDictionary* > > FieldPresenceMap;
70
+ typedef std::map < int, FieldPresenceMap > FieldToGroup;
71
+
72
+ public:
73
+ DataDictionary();
74
+ DataDictionary( const DataDictionary& copy );
75
+ DataDictionary( std::istream& stream ) throw( ConfigError );
76
+ DataDictionary( const std::string& url ) throw( ConfigError );
77
+ virtual ~DataDictionary();
78
+
79
+ void readFromURL( const std::string& url ) throw( ConfigError );
80
+ void readFromDocument( DOMDocumentPtr pDoc ) throw( ConfigError );
81
+ void readFromStream( std::istream& stream ) throw( ConfigError );
82
+
83
+ message_order const& getOrderedFields() const;
84
+
85
+ // storage functions
86
+ void setVersion( const std::string& beginString )
87
+ {
88
+ m_beginString = beginString;
89
+ m_hasVersion = true;
90
+ }
91
+ std::string getVersion() const
92
+ {
93
+ return m_beginString.getString();
94
+ }
95
+
96
+ void addField( int field )
97
+ {
98
+ m_fields.insert( field );
99
+ m_orderedFields.push_back( field );
100
+ }
101
+
102
+ void addFieldName( int field, const std::string& name )
103
+ {
104
+ if( m_names.insert( std::make_pair(name, field) ).second == false )
105
+ throw ConfigError( "Field named " + name + " defined multiple times" );
106
+ m_fieldNames[field] = name;
107
+ }
108
+
109
+ bool getFieldName( int field, std::string& name ) const
110
+ {
111
+ FieldToName::const_iterator i = m_fieldNames.find( field );
112
+ if(i == m_fieldNames.end()) return false;
113
+ name = i->second;
114
+ return true;
115
+ }
116
+
117
+ bool getFieldTag( const std::string& name, int& field ) const
118
+ {
119
+ NameToField::const_iterator i = m_names.find( name );
120
+ if(i == m_names.end()) return false;
121
+ field = i->second;
122
+ return true;
123
+ }
124
+
125
+ void addValueName( int field, const std::string& value, const std::string& name )
126
+ {
127
+ m_valueNames[std::make_pair(field, value)] = name;
128
+ }
129
+
130
+ bool getValueName( int field, const std::string& value, std::string& name ) const
131
+ {
132
+ ValueToName::const_iterator i = m_valueNames.find( std::make_pair(field, value) );
133
+ if(i == m_valueNames.end()) return false;
134
+ name = i->second;
135
+ return true;
136
+ }
137
+
138
+ bool isField( int field ) const
139
+ {
140
+ return m_fields.find( field ) != m_fields.end();
141
+ }
142
+
143
+ void addMsgType( const std::string& msgType )
144
+ {
145
+ m_messages.insert( msgType );
146
+ }
147
+
148
+ bool isMsgType( const std::string& msgType ) const
149
+ {
150
+ return m_messages.find( msgType ) != m_messages.end();
151
+ }
152
+
153
+ void addMsgField( const std::string& msgType, int field )
154
+ {
155
+ m_messageFields[ msgType ].insert( field );
156
+ }
157
+
158
+ bool isMsgField( const std::string& msgType, int field ) const
159
+ {
160
+ MsgTypeToField::const_iterator i = m_messageFields.find( msgType );
161
+ if ( i == m_messageFields.end() ) return false;
162
+ return i->second.find( field ) != i->second.end();
163
+ }
164
+
165
+ void addHeaderField( int field, bool required )
166
+ {
167
+ m_headerFields[ field ] = required;
168
+ }
169
+
170
+ bool isHeaderField( int field ) const
171
+ {
172
+ return m_headerFields.find( field ) != m_headerFields.end();
173
+ }
174
+
175
+ void addTrailerField( int field, bool required )
176
+ {
177
+ m_trailerFields[ field ] = required;
178
+ }
179
+
180
+ bool isTrailerField( int field ) const
181
+ {
182
+ return m_trailerFields.find( field ) != m_trailerFields.end();
183
+ }
184
+
185
+ void addFieldType( int field, FIX::TYPE::Type type )
186
+ {
187
+ m_fieldTypes[ field ] = type;
188
+
189
+ if( type == FIX::TYPE::Data )
190
+ m_dataFields.insert( field );
191
+ }
192
+
193
+ bool getFieldType( int field, FIX::TYPE::Type& type ) const
194
+ {
195
+ FieldTypes::const_iterator i = m_fieldTypes.find( field );
196
+ if ( i == m_fieldTypes.end() ) return false;
197
+ type = i->second;
198
+ return true;
199
+ }
200
+
201
+ void addRequiredField( const std::string& msgType, int field )
202
+ {
203
+ m_requiredFields[ msgType ].insert( field );
204
+ }
205
+
206
+ bool isRequiredField( const std::string& msgType, int field ) const
207
+ {
208
+ MsgTypeToField::const_iterator i = m_requiredFields.find( msgType );
209
+ if ( i == m_requiredFields.end() ) return false;
210
+ return i->second.find( field ) != i->second.end();
211
+ }
212
+
213
+ void addFieldValue( int field, const std::string& value )
214
+ {
215
+ m_fieldValues[ field ].insert( value );
216
+ }
217
+
218
+ bool hasFieldValue( int field ) const
219
+ {
220
+ FieldToValue::const_iterator i = m_fieldValues.find( field );
221
+ return i != m_fieldValues.end();
222
+ }
223
+
224
+ bool isFieldValue( int field, const std::string& value ) const
225
+ {
226
+ FieldToValue::const_iterator i = m_fieldValues.find( field );
227
+ if ( i == m_fieldValues.end() )
228
+ return false;
229
+ if( !isMultipleValueField( field ) )
230
+ return i->second.find( value ) != i->second.end();
231
+
232
+ // MultipleValue
233
+ std::string::size_type startPos = 0;
234
+ std::string::size_type endPos = 0;
235
+ do
236
+ {
237
+ endPos = value.find_first_of(' ', startPos);
238
+ std::string singleValue =
239
+ value.substr( startPos, endPos - startPos );
240
+ if( i->second.find( singleValue ) == i->second.end() )
241
+ return false;
242
+ startPos = endPos + 1;
243
+ } while( endPos != std::string::npos );
244
+ return true;
245
+ }
246
+
247
+ void addGroup( const std::string& msg, int field, int delim,
248
+ const DataDictionary& dataDictionary )
249
+ {
250
+ DataDictionary * pDD = new DataDictionary( dataDictionary );
251
+ pDD->setVersion( getVersion() );
252
+
253
+ FieldPresenceMap& presenceMap = m_groups[ field ];
254
+ presenceMap[ msg ] = std::make_pair( delim, pDD );
255
+ }
256
+
257
+ bool isGroup( const std::string& msg, int field ) const
258
+ {
259
+ FieldToGroup::const_iterator i = m_groups.find( field );
260
+ if ( i == m_groups.end() ) return false;
261
+
262
+ const FieldPresenceMap& presenceMap = i->second;
263
+
264
+ FieldPresenceMap::const_iterator iter = presenceMap.find( msg );
265
+ return ( iter != presenceMap.end() );
266
+ }
267
+
268
+ bool getGroup( const std::string& msg, int field, int& delim,
269
+ const DataDictionary*& pDataDictionary ) const
270
+ {
271
+ FieldToGroup::const_iterator i = m_groups.find( field );
272
+ if ( i == m_groups.end() ) return false;
273
+
274
+ const FieldPresenceMap& presenceMap = i->second;
275
+
276
+ FieldPresenceMap::const_iterator iter = presenceMap.find( msg );
277
+ if( iter == presenceMap.end() ) return false;
278
+
279
+ std::pair < int, DataDictionary* > pair = iter->second;
280
+ delim = pair.first;
281
+ pDataDictionary = pair.second;
282
+ return true;
283
+ }
284
+
285
+ bool isDataField( int field ) const
286
+ {
287
+ MsgFields::const_iterator iter = m_dataFields.find( field );
288
+ return iter != m_dataFields.end();
289
+ }
290
+
291
+ bool isMultipleValueField( int field ) const
292
+ {
293
+ FieldTypes::const_iterator i = m_fieldTypes.find( field );
294
+ return i != m_fieldTypes.end()
295
+ && (i->second == TYPE::MultipleValueString
296
+ || i->second == TYPE::MultipleCharValue
297
+ || i->second == TYPE::MultipleStringValue );
298
+ }
299
+
300
+ void checkFieldsOutOfOrder( bool value )
301
+ { m_checkFieldsOutOfOrder = value; }
302
+ void checkFieldsHaveValues( bool value )
303
+ { m_checkFieldsHaveValues = value; }
304
+ void checkUserDefinedFields( bool value )
305
+ { m_checkUserDefinedFields = value; }
306
+
307
+ /// Validate a message.
308
+ static void validate( const Message& message,
309
+ const DataDictionary* const pSessionDD,
310
+ const DataDictionary* const pAppID ) throw( FIX::Exception );
311
+
312
+ void validate( const Message& message ) const throw ( FIX::Exception )
313
+ { validate( message, false ); }
314
+ void validate( const Message& message, bool bodyOnly ) const throw( FIX::Exception )
315
+ { validate( message, bodyOnly ? (DataDictionary*)0 : this, this ); }
316
+
317
+ DataDictionary& operator=( const DataDictionary& rhs );
318
+
319
+ private:
320
+ /// Iterate through fields while applying checks.
321
+ void iterate( const FieldMap& map, const MsgType& msgType ) const;
322
+
323
+ /// Check if message type is defined in spec.
324
+ void checkMsgType( const MsgType& msgType ) const
325
+ {
326
+ if ( !isMsgType( msgType.getValue() ) )
327
+ throw InvalidMessageType();
328
+ }
329
+
330
+ /// If we need to check for the tag in the dictionary
331
+ bool shouldCheckTag( const FieldBase& field ) const
332
+ {
333
+ if( !m_checkUserDefinedFields && field.getField() >= FIELD::UserMin )
334
+ return false;
335
+ else
336
+ return true;
337
+ }
338
+
339
+ /// Check if field tag number is defined in spec.
340
+ void checkValidTagNumber( const FieldBase& field ) const
341
+ throw( InvalidTagNumber )
342
+ {
343
+ if( m_fields.find( field.getField() ) == m_fields.end() )
344
+ throw InvalidTagNumber( field.getField() );
345
+ }
346
+
347
+ void checkValidFormat( const FieldBase& field ) const
348
+ throw( IncorrectDataFormat )
349
+ {
350
+ try
351
+ {
352
+ TYPE::Type type = TYPE::Unknown;
353
+ getFieldType( field.getField(), type );
354
+ switch ( type )
355
+ {
356
+ case TYPE::String:
357
+ STRING_CONVERTOR::convert( field.getString() ); break;
358
+ case TYPE::Char:
359
+ CHAR_CONVERTOR::convert( field.getString() ); break;
360
+ case TYPE::Price:
361
+ PRICE_CONVERTOR::convert( field.getString() ); break;
362
+ case TYPE::Int:
363
+ INT_CONVERTOR::convert( field.getString() ); break;
364
+ case TYPE::Amt:
365
+ AMT_CONVERTOR::convert( field.getString() ); break;
366
+ case TYPE::Qty:
367
+ QTY_CONVERTOR::convert( field.getString() ); break;
368
+ case TYPE::Currency:
369
+ CURRENCY_CONVERTOR::convert( field.getString() ); break;
370
+ case TYPE::MultipleValueString:
371
+ MULTIPLEVALUESTRING_CONVERTOR::convert( field.getString() ); break;
372
+ case TYPE::MultipleStringValue:
373
+ MULTIPLESTRINGVALUE_CONVERTOR::convert( field.getString() ); break;
374
+ case TYPE::MultipleCharValue:
375
+ MULTIPLECHARVALUE_CONVERTOR::convert( field.getString() ); break;
376
+ case TYPE::Exchange:
377
+ EXCHANGE_CONVERTOR::convert( field.getString() ); break;
378
+ case TYPE::UtcTimeStamp:
379
+ UTCTIMESTAMP_CONVERTOR::convert( field.getString() ); break;
380
+ case TYPE::Boolean:
381
+ BOOLEAN_CONVERTOR::convert( field.getString() ); break;
382
+ case TYPE::LocalMktDate:
383
+ LOCALMKTDATE_CONVERTOR::convert( field.getString() ); break;
384
+ case TYPE::Data:
385
+ DATA_CONVERTOR::convert( field.getString() ); break;
386
+ case TYPE::Float:
387
+ FLOAT_CONVERTOR::convert( field.getString() ); break;
388
+ case TYPE::PriceOffset:
389
+ PRICEOFFSET_CONVERTOR::convert( field.getString() ); break;
390
+ case TYPE::MonthYear:
391
+ MONTHYEAR_CONVERTOR::convert( field.getString() ); break;
392
+ case TYPE::DayOfMonth:
393
+ DAYOFMONTH_CONVERTOR::convert( field.getString() ); break;
394
+ case TYPE::UtcDate:
395
+ UTCDATE_CONVERTOR::convert( field.getString() ); break;
396
+ case TYPE::UtcTimeOnly:
397
+ UTCTIMEONLY_CONVERTOR::convert( field.getString() ); break;
398
+ case TYPE::NumInGroup:
399
+ NUMINGROUP_CONVERTOR::convert( field.getString() ); break;
400
+ case TYPE::Percentage:
401
+ PERCENTAGE_CONVERTOR::convert( field.getString() ); break;
402
+ case TYPE::SeqNum:
403
+ SEQNUM_CONVERTOR::convert( field.getString() ); break;
404
+ case TYPE::Length:
405
+ LENGTH_CONVERTOR::convert( field.getString() ); break;
406
+ case TYPE::Country:
407
+ COUNTRY_CONVERTOR::convert( field.getString() ); break;
408
+ case TYPE::TzTimeOnly:
409
+ TZTIMEONLY_CONVERTOR::convert( field.getString() ); break;
410
+ case TYPE::TzTimeStamp:
411
+ TZTIMESTAMP_CONVERTOR::convert( field.getString() ); break;
412
+ case TYPE::XmlData:
413
+ XMLDATA_CONVERTOR::convert( field.getString() ); break;
414
+ case TYPE::Language:
415
+ LANGUAGE_CONVERTOR::convert( field.getString() ); break;
416
+ case TYPE::Unknown: break;
417
+ }
418
+ }
419
+ catch ( FieldConvertError& )
420
+ { throw IncorrectDataFormat( field.getField(), field.getString() ); }
421
+ }
422
+
423
+ void checkValue( const FieldBase& field ) const
424
+ throw( IncorrectTagValue )
425
+ {
426
+ if ( !hasFieldValue( field.getField() ) ) return ;
427
+
428
+ const std::string& value = field.getString();
429
+ if ( !isFieldValue( field.getField(), value ) )
430
+ throw IncorrectTagValue( field.getField() );
431
+ }
432
+
433
+ /// Check if a field has a value.
434
+ void checkHasValue( const FieldBase& field ) const
435
+ throw( NoTagValue )
436
+ {
437
+ if ( m_checkFieldsHaveValues && !field.getString().length() )
438
+ throw NoTagValue( field.getField() );
439
+ }
440
+
441
+ /// Check if a field is in this message type.
442
+ void checkIsInMessage
443
+ ( const FieldBase& field, const MsgType& msgType ) const
444
+ throw( TagNotDefinedForMessage )
445
+ {
446
+ if ( !isMsgField( msgType, field.getField() ) )
447
+ throw TagNotDefinedForMessage( field.getField() );
448
+ }
449
+
450
+ /// Check if group count matches number of groups in
451
+ void checkGroupCount
452
+ ( const FieldBase& field, const FieldMap& fieldMap, const MsgType& msgType ) const
453
+ throw( RepeatingGroupCountMismatch )
454
+ {
455
+ int fieldNum = field.getField();
456
+ if( isGroup(msgType, fieldNum) )
457
+ {
458
+ if( (int)fieldMap.groupCount(fieldNum)
459
+ != IntConvertor::convert(field.getString()) )
460
+ throw RepeatingGroupCountMismatch(fieldNum);
461
+ }
462
+ }
463
+
464
+ /// Check if a message has all required fields.
465
+ void checkHasRequired
466
+ ( const FieldMap& header, const FieldMap& body, const FieldMap& trailer,
467
+ const MsgType& msgType ) const
468
+ throw( RequiredTagMissing )
469
+ {
470
+ NonBodyFields::const_iterator iNBF;
471
+ for( iNBF = m_headerFields.begin(); iNBF != m_headerFields.end(); ++iNBF )
472
+ {
473
+ if( iNBF->second == true && !header.isSetField(iNBF->first) )
474
+ throw RequiredTagMissing( iNBF->first );
475
+ }
476
+
477
+ for( iNBF = m_trailerFields.begin(); iNBF != m_trailerFields.end(); ++iNBF )
478
+ {
479
+ if( iNBF->second == true && !trailer.isSetField(iNBF->first) )
480
+ throw RequiredTagMissing( iNBF->first );
481
+ }
482
+
483
+ MsgTypeToField::const_iterator iM
484
+ = m_requiredFields.find( msgType.getString() );
485
+ if ( iM == m_requiredFields.end() ) return ;
486
+
487
+ const MsgFields& fields = iM->second;
488
+ MsgFields::const_iterator iF;
489
+ for( iF = fields.begin(); iF != fields.end(); ++iF )
490
+ {
491
+ if( !body.isSetField(*iF) )
492
+ throw RequiredTagMissing( *iF );
493
+ }
494
+
495
+ FieldMap::g_iterator groups;
496
+ for( groups = body.g_begin(); groups != body.g_end(); ++groups )
497
+ {
498
+ int delim;
499
+ const DataDictionary* DD = 0;
500
+ int field = groups->first;
501
+ if( getGroup( msgType.getValue(), field, delim, DD ) )
502
+ {
503
+ std::vector<FieldMap*>::const_iterator group;
504
+ for( group = groups->second.begin(); group != groups->second.end(); ++group )
505
+ DD->checkHasRequired( **group, **group, **group, msgType );
506
+ }
507
+ }
508
+ }
509
+
510
+ int lookupXMLFieldNumber( DOMDocument*, DOMNode* ) const;
511
+ int lookupXMLFieldNumber( DOMDocument*, const std::string& name ) const;
512
+ int addXMLComponentFields( DOMDocument*, DOMNode*, const std::string& msgtype, DataDictionary&, bool );
513
+ void addXMLGroup( DOMDocument*, DOMNode*, const std::string& msgtype, DataDictionary&, bool );
514
+ TYPE::Type XMLTypeToType( const std::string& xmlType ) const;
515
+
516
+ bool m_hasVersion;
517
+ bool m_checkFieldsOutOfOrder;
518
+ bool m_checkFieldsHaveValues;
519
+ bool m_checkUserDefinedFields;
520
+ BeginString m_beginString;
521
+ MsgTypeToField m_messageFields;
522
+ MsgTypeToField m_requiredFields;
523
+ MsgTypes m_messages;
524
+ Fields m_fields;
525
+ OrderedFields m_orderedFields;
526
+ mutable OrderedFieldsArray m_orderedFieldsArray;
527
+ NonBodyFields m_headerFields;
528
+ NonBodyFields m_trailerFields;
529
+ FieldTypes m_fieldTypes;
530
+ FieldToValue m_fieldValues;
531
+ FieldToName m_fieldNames;
532
+ NameToField m_names;
533
+ ValueToName m_valueNames;
534
+ FieldToGroup m_groups;
535
+ MsgFields m_dataFields;
536
+ };
537
+ }
538
+
539
+ #endif //FIX_DATADICTIONARY_H
@@ -0,0 +1,71 @@
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 "DataDictionaryProvider.h"
27
+ #include "Fields.h"
28
+ #include "DataDictionary.h"
29
+
30
+ namespace FIX
31
+ {
32
+ DataDictionaryProvider::DataDictionaryProvider( const DataDictionaryProvider& copy )
33
+ {
34
+ *this = copy;
35
+ }
36
+
37
+ const DataDictionary& DataDictionaryProvider::getSessionDataDictionary
38
+ (const BeginString& beginString) const throw( DataDictionaryNotFound )
39
+ {
40
+ std::map<std::string, ptr::shared_ptr<DataDictionary> >::const_iterator find =
41
+ m_transportDictionaries.find(beginString);
42
+ if( find != m_transportDictionaries.end() )
43
+ return *find->second;
44
+
45
+ return emptyDataDictionary;
46
+ }
47
+
48
+ const DataDictionary& DataDictionaryProvider::getApplicationDataDictionary
49
+ (const ApplVerID& applVerID) const throw( DataDictionaryNotFound )
50
+ {
51
+ std::map<std::string, ptr::shared_ptr<DataDictionary> >::const_iterator find =
52
+ m_applicationDictionaries.find(applVerID);
53
+ if( find != m_applicationDictionaries.end() )
54
+ return *find->second;
55
+
56
+ return emptyDataDictionary;
57
+ }
58
+
59
+ void DataDictionaryProvider::addTransportDataDictionary
60
+ (const BeginString& beginString, ptr::shared_ptr<DataDictionary> pDD)
61
+ {
62
+ m_transportDictionaries[beginString.getValue()] = pDD;
63
+ }
64
+
65
+ void DataDictionaryProvider::addApplicationDataDictionary
66
+ (const ApplVerID& applVerID, ptr::shared_ptr<DataDictionary> pDD)
67
+ {
68
+ m_applicationDictionaries[applVerID.getValue()] = pDD;
69
+ }
70
+ }
71
+
@@ -0,0 +1,70 @@
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_DATADICTIONARYPROVIDER_H
23
+ #define FIX_DATADICTIONARYPROVIDER_H
24
+
25
+ #ifdef _MSC_VER
26
+ #pragma warning( disable : 4503 4355 4786 4290 )
27
+ #endif
28
+
29
+ #include "DataDictionary.h"
30
+ #include "Exceptions.h"
31
+ #include "Utility.h"
32
+
33
+ namespace FIX
34
+ {
35
+ class BeginString;
36
+ class ApplVerID;
37
+
38
+ /**
39
+ * Queries for DataDictionary based on appropriate version of %FIX.
40
+ */
41
+
42
+ class DataDictionaryProvider
43
+ {
44
+ public:
45
+ DataDictionaryProvider() {}
46
+ DataDictionaryProvider( const DataDictionaryProvider& copy );
47
+
48
+ const DataDictionary& getSessionDataDictionary(const BeginString& beginString) const
49
+ throw( DataDictionaryNotFound );
50
+
51
+ const DataDictionary& getApplicationDataDictionary(const ApplVerID& applVerID) const
52
+ throw( DataDictionaryNotFound );
53
+
54
+ void addTransportDataDictionary(const BeginString& beginString, ptr::shared_ptr<DataDictionary>);
55
+ void addApplicationDataDictionary(const ApplVerID& applVerID, ptr::shared_ptr<DataDictionary>);
56
+
57
+ void addTransportDataDictionary(const BeginString& beginString, const std::string& path)
58
+ { addTransportDataDictionary(beginString, ptr::shared_ptr<DataDictionary>( new DataDictionary(path) )); }
59
+ void addApplicationDataDictionary(const ApplVerID& applVerID, const std::string& path)
60
+ { addApplicationDataDictionary(applVerID, ptr::shared_ptr<DataDictionary>( new DataDictionary(path) )); }
61
+
62
+ private:
63
+ std::map<std::string, ptr::shared_ptr<DataDictionary> > m_transportDictionaries;
64
+ std::map<std::string, ptr::shared_ptr<DataDictionary> > m_applicationDictionaries;
65
+ DataDictionary emptyDataDictionary;
66
+ };
67
+ }
68
+
69
+ #endif //FIX_DATADICTIONARYPROVIDER_H
70
+