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,238 @@
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 "FieldMap.h"
27
+ #include <algorithm>
28
+ #include <iterator>
29
+ #include <deque>
30
+
31
+ namespace FIX
32
+ {
33
+ FieldMap::~FieldMap()
34
+ {
35
+ clear();
36
+ }
37
+
38
+ FieldMap& FieldMap::operator=( const FieldMap& rhs )
39
+ {
40
+ clear();
41
+
42
+ m_fields = rhs.m_fields;
43
+
44
+ Groups::const_iterator i;
45
+ for ( i = rhs.m_groups.begin(); i != rhs.m_groups.end(); ++i )
46
+ {
47
+ std::vector < FieldMap* > ::const_iterator j;
48
+ for ( j = i->second.begin(); j != i->second.end(); ++j )
49
+ {
50
+ FieldMap * pGroup = new FieldMap( **j );
51
+ m_groups[ i->first ].push_back( pGroup );
52
+ }
53
+ }
54
+
55
+ return *this;
56
+ }
57
+
58
+ void FieldMap::addGroup( int field, const FieldMap& group, bool setCount )
59
+ {
60
+ FieldMap * pGroup = new FieldMap( group );
61
+
62
+ addGroupPtr( field, pGroup, setCount );
63
+ }
64
+
65
+ void FieldMap::addGroupPtr( int field, FieldMap * group, bool setCount )
66
+ {
67
+ if( group == 0 )
68
+ return;
69
+
70
+ std::vector< FieldMap* >& vec = m_groups[ field ];
71
+ vec.push_back( group );
72
+
73
+ if( setCount )
74
+ setField( IntField( field, (int)vec.size() ) );
75
+ }
76
+
77
+ void FieldMap::replaceGroup( int num, int field, const FieldMap& group )
78
+ {
79
+ Groups::const_iterator i = m_groups.find( field );
80
+ if ( i == m_groups.end() ) return;
81
+ if ( num <= 0 ) return;
82
+ if ( i->second.size() < ( unsigned ) num ) return;
83
+ *( *( i->second.begin() + ( num - 1 ) ) ) = group;
84
+ }
85
+
86
+ void FieldMap::removeGroup( int num, int field )
87
+ {
88
+ Groups::iterator i = m_groups.find( field );
89
+ if ( i == m_groups.end() ) return;
90
+ if ( num <= 0 ) return;
91
+ std::vector< FieldMap* >& vector = i->second;
92
+ if ( vector.size() < ( unsigned ) num ) return;
93
+
94
+ std::vector< FieldMap* >::iterator iter = vector.begin();
95
+ std::advance( iter, ( num - 1 ) );
96
+
97
+ delete (*iter);
98
+ vector.erase( iter );
99
+
100
+ if( vector.size() == 0 )
101
+ {
102
+ m_groups.erase( field );
103
+ removeField( field );
104
+ }
105
+ else
106
+ {
107
+ IntField groupCount( field, (int)vector.size() );
108
+ setField( groupCount, true );
109
+ }
110
+ }
111
+
112
+ void FieldMap::removeGroup( int field )
113
+ {
114
+ removeGroup( (int)groupCount(field), field );
115
+ }
116
+
117
+ void FieldMap::removeField( int field )
118
+ {
119
+ Fields::iterator i = m_fields.find( field );
120
+ if ( i != m_fields.end() )
121
+ m_fields.erase( i );
122
+ }
123
+
124
+ bool FieldMap::hasGroup( int num, int field ) const
125
+ {
126
+ return (int)groupCount(field) >= num;
127
+ }
128
+
129
+ bool FieldMap::hasGroup( int field ) const
130
+ {
131
+ Groups::const_iterator i = m_groups.find( field );
132
+ return i != m_groups.end();
133
+ }
134
+
135
+ size_t FieldMap::groupCount( int field ) const
136
+ {
137
+ Groups::const_iterator i = m_groups.find( field );
138
+ if( i == m_groups.end() )
139
+ return 0;
140
+ return i->second.size();
141
+ }
142
+
143
+ void FieldMap::clear()
144
+ {
145
+ m_fields.clear();
146
+
147
+ Groups::iterator i;
148
+ for ( i = m_groups.begin(); i != m_groups.end(); ++i )
149
+ {
150
+ std::vector < FieldMap* > ::iterator j;
151
+ for ( j = i->second.begin(); j != i->second.end(); ++j )
152
+ delete *j;
153
+ }
154
+ m_groups.clear();
155
+ }
156
+
157
+ bool FieldMap::isEmpty()
158
+ {
159
+ return m_fields.size() == 0;
160
+ }
161
+
162
+ size_t FieldMap::totalFields() const
163
+ {
164
+ size_t result = m_fields.size();
165
+
166
+ Groups::const_iterator i;
167
+ for ( i = m_groups.begin(); i != m_groups.end(); ++i )
168
+ {
169
+ std::vector < FieldMap* > ::const_iterator j;
170
+ for ( j = i->second.begin(); j != i->second.end(); ++j )
171
+ result += ( *j ) ->totalFields();
172
+ }
173
+ return result;
174
+ }
175
+
176
+ std::string& FieldMap::calculateString( std::string& result ) const
177
+ {
178
+ Fields::const_iterator i;
179
+ for ( i = m_fields.begin(); i != m_fields.end(); ++i )
180
+ {
181
+ result += i->second.getFixString();
182
+
183
+ // add groups if they exist
184
+ if( !m_groups.size() ) continue;
185
+ Groups::const_iterator j = m_groups.find( i->first );
186
+ if ( j == m_groups.end() ) continue;
187
+ std::vector < FieldMap* > ::const_iterator k;
188
+ for ( k = j->second.begin(); k != j->second.end(); ++k )
189
+ ( *k ) ->calculateString( result );
190
+ }
191
+ return result;
192
+ }
193
+
194
+ int FieldMap::calculateLength( int beginStringField,
195
+ int bodyLengthField,
196
+ int checkSumField ) const
197
+ {
198
+ int result = 0;
199
+ Fields::const_iterator i;
200
+ for ( i = m_fields.begin(); i != m_fields.end(); ++i )
201
+ {
202
+ if ( i->first != beginStringField
203
+ && i->first != bodyLengthField
204
+ && i->first != checkSumField )
205
+ { result += i->second.getLength(); }
206
+ }
207
+
208
+ Groups::const_iterator j;
209
+ for ( j = m_groups.begin(); j != m_groups.end(); ++j )
210
+ {
211
+ std::vector < FieldMap* > ::const_iterator k;
212
+ for ( k = j->second.begin(); k != j->second.end(); ++k )
213
+ result += ( *k ) ->calculateLength();
214
+ }
215
+ return result;
216
+ }
217
+
218
+ int FieldMap::calculateTotal( int checkSumField ) const
219
+ {
220
+ int result = 0;
221
+ Fields::const_iterator i;
222
+ for ( i = m_fields.begin(); i != m_fields.end(); ++i )
223
+ {
224
+ if ( i->first != checkSumField )
225
+ result += i->second.getTotal();
226
+ }
227
+
228
+ Groups::const_iterator j;
229
+ for ( j = m_groups.begin(); j != m_groups.end(); ++j )
230
+ {
231
+ std::vector < FieldMap* > ::const_iterator k;
232
+ for ( k = j->second.begin(); k != j->second.end(); ++k )
233
+ result += ( *k ) ->calculateTotal();
234
+ }
235
+ return result;
236
+ }
237
+
238
+ }
@@ -0,0 +1,244 @@
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_FIELDMAP
23
+ #define FIX_FIELDMAP
24
+
25
+ #ifdef _MSC_VER
26
+ #pragma warning( disable: 4786 )
27
+ #endif
28
+
29
+ #include "Field.h"
30
+ #include "MessageSorters.h"
31
+ #include "Exceptions.h"
32
+ #include "Utility.h"
33
+ #include <map>
34
+ #include <vector>
35
+ #include <sstream>
36
+ #include <algorithm>
37
+
38
+ namespace FIX
39
+ {
40
+ /**
41
+ * Stores and organizes a collection of Fields.
42
+ *
43
+ * This is the basis for a message, header, and trailer. This collection
44
+ * class uses a sorter to keep the fields in a particular order.
45
+ */
46
+ class FieldMap
47
+ {
48
+ public:
49
+ #if defined(_MSC_VER) && _MSC_VER < 1300
50
+ typedef std::multimap < int, FieldBase, message_order > Fields;
51
+ typedef std::map < int, std::vector < FieldMap* >, std::less<int> > Groups;
52
+ #else
53
+ typedef std::multimap < int, FieldBase, message_order,
54
+ ALLOCATOR<std::pair<const int,FieldBase> > > Fields;
55
+ typedef std::map < int, std::vector < FieldMap* >, std::less<int>,
56
+ ALLOCATOR<std::pair<const int, std::vector< FieldMap* > > > > Groups;
57
+ #endif
58
+
59
+ typedef Fields::const_iterator iterator;
60
+ typedef iterator const_iterator;
61
+ typedef Groups::const_iterator g_iterator;
62
+ typedef Groups::const_iterator g_const_iterator;
63
+
64
+ FieldMap( const message_order& order =
65
+ message_order( message_order::normal ) )
66
+ : m_fields( order ) {}
67
+
68
+ FieldMap( const int order[] )
69
+ : m_fields( message_order(order) ) {}
70
+
71
+ FieldMap( const FieldMap& copy )
72
+ { *this = copy; }
73
+
74
+ virtual ~FieldMap();
75
+
76
+ FieldMap& operator=( const FieldMap& rhs );
77
+
78
+ /// Set a field without type checking
79
+ void setField( const FieldBase& field, bool overwrite = true )
80
+ throw( RepeatedTag )
81
+ {
82
+ if(!overwrite)
83
+ m_fields.insert( Fields::value_type( field.getField(), field ) );
84
+ else
85
+ {
86
+ Fields::iterator i = m_fields.find( field.getField() );
87
+ if( i == m_fields.end() )
88
+ m_fields.insert( Fields::value_type( field.getField(), field ) );
89
+ else
90
+ i->second = field;
91
+ }
92
+ }
93
+ /// Set a field without a field class
94
+ void setField( int field, const std::string& value )
95
+ throw( RepeatedTag, NoTagValue )
96
+ {
97
+ FieldBase fieldBase( field, value );
98
+ setField( fieldBase );
99
+ }
100
+
101
+ /// Get a field if set
102
+ bool getFieldIfSet( FieldBase& field ) const
103
+ {
104
+ Fields::const_iterator iter = m_fields.find( field.getField() );
105
+ if ( iter == m_fields.end() )
106
+ return false;
107
+ field = iter->second;
108
+ return true;
109
+ }
110
+
111
+ /// Get a field without type checking
112
+ FieldBase& getField( FieldBase& field )
113
+ const throw( FieldNotFound )
114
+ {
115
+ field = getFieldRef( field.getField() );
116
+ return field;
117
+ }
118
+
119
+ /// Get a field without a field class
120
+ const std::string& getField( int field )
121
+ const throw( FieldNotFound )
122
+ {
123
+ return getFieldRef( field ).getString();
124
+ }
125
+
126
+ /// Get direct access to a field through a reference
127
+ const FieldBase& getFieldRef( int field )
128
+ const throw( FieldNotFound )
129
+ {
130
+ Fields::const_iterator iter = m_fields.find( field );
131
+ if ( iter == m_fields.end() )
132
+ throw FieldNotFound( field );
133
+ return iter->second;
134
+ }
135
+
136
+ /// Get direct access to a field through a pointer
137
+ const FieldBase* const getFieldPtr( int field )
138
+ const throw( FieldNotFound )
139
+ {
140
+ return &getFieldRef( field );
141
+ }
142
+
143
+ /// Check to see if a field is set
144
+ bool isSetField( const FieldBase& field ) const
145
+ { return isSetField( field.getField() ); }
146
+ /// Check to see if a field is set by referencing its number
147
+ bool isSetField( int field ) const
148
+ { return m_fields.find( field ) != m_fields.end(); }
149
+
150
+ /// Remove a field. If field is not present, this is a no-op.
151
+ void removeField( int field );
152
+
153
+ /// Add a group.
154
+ void addGroup( int field, const FieldMap& group, bool setCount = true );
155
+
156
+ /// Acquire ownership of Group object
157
+ void addGroupPtr( int field, FieldMap * group, bool setCount = true );
158
+
159
+ /// Replace a specific instance of a group.
160
+ void replaceGroup( int num, int field, const FieldMap& group );
161
+
162
+ /// Get a specific instance of a group.
163
+ FieldMap& getGroup( int num, int field, FieldMap& group ) const
164
+ throw( FieldNotFound )
165
+ {
166
+ return group = getGroupRef( num, field );
167
+ }
168
+
169
+ /// Get direct access to a field through a reference
170
+ FieldMap& getGroupRef( int num, int field ) const
171
+ throw( FieldNotFound )
172
+ {
173
+ Groups::const_iterator i = m_groups.find( field );
174
+ if( i == m_groups.end() ) throw FieldNotFound( field );
175
+ if( num <= 0 ) throw FieldNotFound( field );
176
+ if( i->second.size() < (unsigned)num ) throw FieldNotFound( field );
177
+ return *( *(i->second.begin() + (num-1) ) );
178
+ }
179
+
180
+ /// Get direct access to a field through a pointer
181
+ FieldMap* getGroupPtr( int num, int field ) const
182
+ throw( FieldNotFound )
183
+ {
184
+ return &getGroupRef( num, field );
185
+ }
186
+
187
+ /// Remove a specific instance of a group.
188
+ void removeGroup( int num, int field );
189
+ /// Remove all instances of a group.
190
+ void removeGroup( int field );
191
+
192
+ /// Check to see any instance of a group exists
193
+ bool hasGroup( int field ) const;
194
+ /// Check to see if a specific instance of a group exists
195
+ bool hasGroup( int num, int field ) const;
196
+ /// Count the number of instance of a group
197
+ size_t groupCount( int field ) const;
198
+
199
+ /// Clear all fields from the map
200
+ void clear();
201
+ /// Check if map contains any fields
202
+ bool isEmpty();
203
+
204
+ size_t totalFields() const;
205
+
206
+ std::string& calculateString( std::string& ) const;
207
+
208
+ int calculateLength( int beginStringField = FIELD::BeginString,
209
+ int bodyLengthField = FIELD::BodyLength,
210
+ int checkSumField = FIELD::CheckSum ) const;
211
+
212
+ int calculateTotal( int checkSumField = FIELD::CheckSum ) const;
213
+
214
+ iterator begin() const { return m_fields.begin(); }
215
+ iterator end() const { return m_fields.end(); }
216
+ g_iterator g_begin() const { return m_groups.begin(); }
217
+ g_iterator g_end() const { return m_groups.end(); }
218
+
219
+ private:
220
+ Fields m_fields;
221
+ Groups m_groups;
222
+ };
223
+ /*! @} */
224
+ }
225
+
226
+ #define FIELD_SET( MAP, FIELD ) \
227
+ bool isSet( const FIELD& field ) const \
228
+ { return (MAP).isSetField(field); } \
229
+ void set( const FIELD& field ) \
230
+ { (MAP).setField(field); } \
231
+ FIELD& get( FIELD& field ) const \
232
+ { return (FIELD&)(MAP).getField(field); } \
233
+ bool getIfSet( FIELD& field ) const \
234
+ { return (MAP).getFieldIfSet(field); }
235
+
236
+ #define FIELD_GET_PTR( MAP, FLD ) \
237
+ (const FIX::FLD*)MAP.getFieldPtr( FIX::FIELD::FLD )
238
+ #define FIELD_GET_REF( MAP, FLD ) \
239
+ (const FIX::FLD&)MAP.getFieldRef( FIX::FIELD::FLD )
240
+ #define FIELD_THROW_IF_NOT_FOUND( MAP, FLD ) \
241
+ if( !(MAP).isSetField( FIX::FIELD::FLD) ) \
242
+ throw FieldNotFound( FIX::FIELD::FLD )
243
+ #endif //FIX_FIELDMAP
244
+
@@ -0,0 +1,46 @@
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_FIELDNUMBERS_BASE_H
23
+ #define FIX_FIELDNUMBERS_BASE_H
24
+
25
+ #include <iostream>
26
+ #include "FixFieldNumbers.h"
27
+
28
+ namespace FIX
29
+ {
30
+ namespace FIELD
31
+ {
32
+ const int FIX40_LastField = PrevClosePx;
33
+ const int FIX41_LastField = PegDifference;
34
+ const int FIX42_LastField = EncodedListStatusText;
35
+ const int FIX43_LastField = SideComplianceID;
36
+ const int FIX44_LastField = LegInterestAccrualDate;
37
+ const int FIX50_LastField = ExchangeSpecialInstructions;
38
+ const int NormalMin = 1;
39
+ const int NormalMax = 4999;
40
+ const int UserMin = 5000;
41
+ const int UserMax = 9999;
42
+ const int InternalMin = 10000;
43
+ }
44
+ }
45
+
46
+ #endif //FIX_FIELDNUMBERS_BASE_H
@@ -0,0 +1,64 @@
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 "FieldTypes.h"
27
+
28
+ #ifdef HAVE_FTIME
29
+ # include <sys/timeb.h>
30
+ #endif
31
+
32
+ namespace FIX {
33
+
34
+ DateTime DateTime::nowUtc()
35
+ {
36
+ #if defined( HAVE_FTIME )
37
+ timeb tb;
38
+ ftime (&tb);
39
+ return fromUtcTimeT (tb.time, tb.millitm);
40
+ #elif defined( _POSIX_SOURCE )
41
+ struct timeval tv;
42
+ gettimeofday (&tv, 0);
43
+ return fromUtcTimeT( tv.tv_sec, tv.tv_usec / 1000 );
44
+ #else
45
+ return fromUtcTimeT( ::time (0), 0 );
46
+ #endif
47
+ }
48
+
49
+ DateTime DateTime::nowLocal()
50
+ {
51
+ #if defined( HAVE_FTIME )
52
+ timeb tb;
53
+ ftime (&tb);
54
+ return fromLocalTimeT( tb.time, tb.millitm );
55
+ #elif defined( _POSIX_SOURCE )
56
+ struct timeval tv;
57
+ gettimeofday (&tv, 0);
58
+ return fromLocalTimeT( tv.tv_sec, tv.tv_usec / 1000 );
59
+ #else
60
+ return fromLocalTimeT( ::time (0), 0 );
61
+ #endif
62
+ }
63
+
64
+ }