quickfix_ruby 1.14.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/ext/quickfix/Acceptor.cpp +248 -0
- data/ext/quickfix/Acceptor.h +127 -0
- data/ext/quickfix/Allocator.h +9 -0
- data/ext/quickfix/Application.h +127 -0
- data/ext/quickfix/AtomicCount.h +109 -0
- data/ext/quickfix/DOMDocument.h +74 -0
- data/ext/quickfix/DataDictionary.cpp +618 -0
- data/ext/quickfix/DataDictionary.h +539 -0
- data/ext/quickfix/DataDictionaryProvider.cpp +71 -0
- data/ext/quickfix/DataDictionaryProvider.h +70 -0
- data/ext/quickfix/DatabaseConnectionID.h +105 -0
- data/ext/quickfix/DatabaseConnectionPool.h +91 -0
- data/ext/quickfix/Dictionary.cpp +162 -0
- data/ext/quickfix/Dictionary.h +94 -0
- data/ext/quickfix/Event.h +95 -0
- data/ext/quickfix/Exceptions.h +299 -0
- data/ext/quickfix/Field.h +672 -0
- data/ext/quickfix/FieldConvertors.h +863 -0
- data/ext/quickfix/FieldMap.cpp +238 -0
- data/ext/quickfix/FieldMap.h +244 -0
- data/ext/quickfix/FieldNumbers.h +46 -0
- data/ext/quickfix/FieldTypes.cpp +64 -0
- data/ext/quickfix/FieldTypes.h +698 -0
- data/ext/quickfix/Fields.h +31 -0
- data/ext/quickfix/FileLog.cpp +200 -0
- data/ext/quickfix/FileLog.h +112 -0
- data/ext/quickfix/FileStore.cpp +332 -0
- data/ext/quickfix/FileStore.h +129 -0
- data/ext/quickfix/FixFieldNumbers.h +1537 -0
- data/ext/quickfix/FixFields.h +1538 -0
- data/ext/quickfix/FixValues.h +3281 -0
- data/ext/quickfix/FlexLexer.h +188 -0
- data/ext/quickfix/Group.cpp +64 -0
- data/ext/quickfix/Group.h +73 -0
- data/ext/quickfix/HtmlBuilder.h +186 -0
- data/ext/quickfix/HttpConnection.cpp +739 -0
- data/ext/quickfix/HttpConnection.h +78 -0
- data/ext/quickfix/HttpMessage.cpp +149 -0
- data/ext/quickfix/HttpMessage.h +133 -0
- data/ext/quickfix/HttpParser.cpp +49 -0
- data/ext/quickfix/HttpParser.h +54 -0
- data/ext/quickfix/HttpServer.cpp +169 -0
- data/ext/quickfix/HttpServer.h +78 -0
- data/ext/quickfix/Initiator.cpp +289 -0
- data/ext/quickfix/Initiator.h +149 -0
- data/ext/quickfix/Log.cpp +77 -0
- data/ext/quickfix/Log.h +179 -0
- data/ext/quickfix/Message.cpp +580 -0
- data/ext/quickfix/Message.h +370 -0
- data/ext/quickfix/MessageCracker.h +188 -0
- data/ext/quickfix/MessageSorters.cpp +105 -0
- data/ext/quickfix/MessageSorters.h +156 -0
- data/ext/quickfix/MessageStore.cpp +146 -0
- data/ext/quickfix/MessageStore.h +174 -0
- data/ext/quickfix/Mutex.h +131 -0
- data/ext/quickfix/MySQLConnection.h +194 -0
- data/ext/quickfix/MySQLLog.cpp +275 -0
- data/ext/quickfix/MySQLLog.h +145 -0
- data/ext/quickfix/MySQLStore.cpp +331 -0
- data/ext/quickfix/MySQLStore.h +142 -0
- data/ext/quickfix/NullStore.cpp +54 -0
- data/ext/quickfix/NullStore.h +99 -0
- data/ext/quickfix/OdbcConnection.h +266 -0
- data/ext/quickfix/OdbcLog.cpp +252 -0
- data/ext/quickfix/OdbcLog.h +117 -0
- data/ext/quickfix/OdbcStore.cpp +338 -0
- data/ext/quickfix/OdbcStore.h +113 -0
- data/ext/quickfix/PUGIXML_DOMDocument.cpp +112 -0
- data/ext/quickfix/PUGIXML_DOMDocument.h +81 -0
- data/ext/quickfix/Parser.cpp +103 -0
- data/ext/quickfix/Parser.h +57 -0
- data/ext/quickfix/PostgreSQLConnection.h +176 -0
- data/ext/quickfix/PostgreSQLLog.cpp +276 -0
- data/ext/quickfix/PostgreSQLLog.h +144 -0
- data/ext/quickfix/PostgreSQLStore.cpp +334 -0
- data/ext/quickfix/PostgreSQLStore.h +141 -0
- data/ext/quickfix/Queue.h +75 -0
- data/ext/quickfix/QuickfixRuby.cpp +252066 -0
- data/ext/quickfix/QuickfixRuby.h +34 -0
- data/ext/quickfix/Responder.h +43 -0
- data/ext/quickfix/Session.cpp +1487 -0
- data/ext/quickfix/Session.h +335 -0
- data/ext/quickfix/SessionFactory.cpp +274 -0
- data/ext/quickfix/SessionFactory.h +86 -0
- data/ext/quickfix/SessionID.h +170 -0
- data/ext/quickfix/SessionSettings.cpp +189 -0
- data/ext/quickfix/SessionSettings.h +171 -0
- data/ext/quickfix/SessionState.h +231 -0
- data/ext/quickfix/Settings.cpp +100 -0
- data/ext/quickfix/Settings.h +53 -0
- data/ext/quickfix/SharedArray.h +150 -0
- data/ext/quickfix/SocketAcceptor.cpp +222 -0
- data/ext/quickfix/SocketAcceptor.h +75 -0
- data/ext/quickfix/SocketConnection.cpp +238 -0
- data/ext/quickfix/SocketConnection.h +103 -0
- data/ext/quickfix/SocketConnector.cpp +116 -0
- data/ext/quickfix/SocketConnector.h +67 -0
- data/ext/quickfix/SocketInitiator.cpp +260 -0
- data/ext/quickfix/SocketInitiator.h +81 -0
- data/ext/quickfix/SocketMonitor.cpp +335 -0
- data/ext/quickfix/SocketMonitor.h +111 -0
- data/ext/quickfix/SocketServer.cpp +177 -0
- data/ext/quickfix/SocketServer.h +100 -0
- data/ext/quickfix/ThreadedSocketAcceptor.cpp +258 -0
- data/ext/quickfix/ThreadedSocketAcceptor.h +98 -0
- data/ext/quickfix/ThreadedSocketConnection.cpp +209 -0
- data/ext/quickfix/ThreadedSocketConnection.h +82 -0
- data/ext/quickfix/ThreadedSocketInitiator.cpp +268 -0
- data/ext/quickfix/ThreadedSocketInitiator.h +84 -0
- data/ext/quickfix/TimeRange.cpp +173 -0
- data/ext/quickfix/TimeRange.h +258 -0
- data/ext/quickfix/Utility.cpp +537 -0
- data/ext/quickfix/Utility.h +219 -0
- data/ext/quickfix/Values.h +62 -0
- data/ext/quickfix/config.h +0 -0
- data/ext/quickfix/config_windows.h +0 -0
- data/ext/quickfix/extconf.rb +12 -0
- data/ext/quickfix/index.h +37 -0
- data/ext/quickfix/pugiconfig.hpp +72 -0
- data/ext/quickfix/pugixml.cpp +10765 -0
- data/ext/quickfix/pugixml.hpp +1341 -0
- data/ext/quickfix/strptime.h +7 -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 +10721 -0
- data/lib/quickfix50.rb +13426 -0
- data/lib/quickfix50sp1.rb +15629 -0
- data/lib/quickfix50sp2.rb +17068 -0
- data/lib/quickfix_fields.rb +19853 -0
- data/lib/quickfix_ruby.rb +82 -0
- data/lib/quickfixt11.rb +70 -0
- data/spec/FIX40.xml +862 -0
- data/spec/FIX41.xml +1285 -0
- data/spec/FIX42.xml +2746 -0
- data/spec/FIX43.xml +4229 -0
- data/spec/FIX44.xml +6596 -0
- data/spec/FIX50.xml +8137 -0
- data/spec/FIX50SP1.xml +9496 -0
- data/spec/FIX50SP2.xml +10011 -0
- data/spec/FIXT11.xml +313 -0
- data/test/test_DataDictionaryTestCase.rb +268 -0
- data/test/test_DictionaryTestCase.rb +112 -0
- data/test/test_FieldBaseTestCase.rb +24 -0
- data/test/test_MessageTestCase.rb +368 -0
- data/test/test_SessionSettingsTestCase.rb +41 -0
- metadata +193 -0
@@ -0,0 +1,231 @@
|
|
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_SESSIONSTATE_H
|
23
|
+
#define FIX_SESSIONSTATE_H
|
24
|
+
|
25
|
+
#ifdef _MSC_VER
|
26
|
+
#pragma warning( disable : 4503 4355 4786 4290 )
|
27
|
+
#endif
|
28
|
+
|
29
|
+
#include "FieldTypes.h"
|
30
|
+
#include "MessageStore.h"
|
31
|
+
#include "Log.h"
|
32
|
+
#include "Mutex.h"
|
33
|
+
|
34
|
+
namespace FIX
|
35
|
+
{
|
36
|
+
/// Maintains all of state for the Session class.
|
37
|
+
class SessionState : public MessageStore, public Log
|
38
|
+
{
|
39
|
+
typedef std::map < int, Message > Messages;
|
40
|
+
|
41
|
+
public:
|
42
|
+
SessionState()
|
43
|
+
: m_enabled( true ), m_receivedLogon( false ),
|
44
|
+
m_sentLogout( false ), m_sentLogon( false ),
|
45
|
+
m_sentReset( false ), m_receivedReset( false ),
|
46
|
+
m_initiate( false ), m_logonTimeout( 10 ),
|
47
|
+
m_logoutTimeout( 2 ), m_testRequest( 0 ),
|
48
|
+
m_pStore( 0 ), m_pLog( 0 ) {}
|
49
|
+
|
50
|
+
bool enabled() const { return m_enabled; }
|
51
|
+
void enabled( bool value ) { m_enabled = value; }
|
52
|
+
|
53
|
+
bool receivedLogon() const { return m_receivedLogon; }
|
54
|
+
void receivedLogon( bool value ) { m_receivedLogon = value; }
|
55
|
+
|
56
|
+
bool sentLogout() const { return m_sentLogout; }
|
57
|
+
void sentLogout( bool value ) { m_sentLogout = value; }
|
58
|
+
|
59
|
+
bool sentLogon() const { return m_sentLogon; }
|
60
|
+
void sentLogon( bool value ) { m_sentLogon = value; }
|
61
|
+
|
62
|
+
bool receivedReset() const { return m_receivedReset; }
|
63
|
+
void receivedReset( bool value ) { m_receivedReset = value; }
|
64
|
+
|
65
|
+
bool sentReset() const { return m_sentReset; }
|
66
|
+
void sentReset( bool value ) { m_sentReset = value; }
|
67
|
+
|
68
|
+
bool initiate() const { return m_initiate; }
|
69
|
+
void initiate( bool value ) { m_initiate = value; }
|
70
|
+
|
71
|
+
int logonTimeout() const { return m_logonTimeout; }
|
72
|
+
void logonTimeout( int value ) { m_logonTimeout = value; }
|
73
|
+
|
74
|
+
int logoutTimeout() const { return m_logoutTimeout; }
|
75
|
+
void logoutTimeout( int value ) { m_logoutTimeout = value; }
|
76
|
+
|
77
|
+
int testRequest() const { return m_testRequest; }
|
78
|
+
void testRequest( int value ) { m_testRequest = value; }
|
79
|
+
|
80
|
+
bool resendRequested() const
|
81
|
+
{ return !(m_resendRange.first == 0 && m_resendRange.second == 0); }
|
82
|
+
|
83
|
+
typedef std::pair<int, int> ResendRange;
|
84
|
+
|
85
|
+
ResendRange resendRange () const { return m_resendRange; }
|
86
|
+
void resendRange (int begin, int end)
|
87
|
+
{ m_resendRange = std::make_pair( begin, end ); }
|
88
|
+
|
89
|
+
MessageStore* store() { return m_pStore; }
|
90
|
+
void store( MessageStore* pValue ) { m_pStore = pValue; }
|
91
|
+
Log* log() { return m_pLog ? m_pLog : &m_nullLog; }
|
92
|
+
void log( Log* pValue ) { m_pLog = pValue; }
|
93
|
+
|
94
|
+
void heartBtInt( const HeartBtInt& value )
|
95
|
+
{ m_heartBtInt = value; }
|
96
|
+
HeartBtInt& heartBtInt()
|
97
|
+
{ return m_heartBtInt; }
|
98
|
+
const HeartBtInt& heartBtInt() const
|
99
|
+
{ return m_heartBtInt; }
|
100
|
+
|
101
|
+
void lastSentTime( const UtcTimeStamp& value )
|
102
|
+
{ m_lastSentTime = value; }
|
103
|
+
UtcTimeStamp& lastSentTime()
|
104
|
+
{ return m_lastSentTime; }
|
105
|
+
const UtcTimeStamp& lastSentTime() const
|
106
|
+
{ return m_lastSentTime; }
|
107
|
+
|
108
|
+
void lastReceivedTime( const UtcTimeStamp& value )
|
109
|
+
{ m_lastReceivedTime = value; }
|
110
|
+
UtcTimeStamp& lastReceivedTime()
|
111
|
+
{ return m_lastReceivedTime; }
|
112
|
+
const UtcTimeStamp& lastReceivedTime() const
|
113
|
+
{ return m_lastReceivedTime; }
|
114
|
+
|
115
|
+
bool shouldSendLogon() const { return initiate() && !sentLogon(); }
|
116
|
+
bool alreadySentLogon() const { return initiate() && sentLogon(); }
|
117
|
+
bool logonTimedOut() const
|
118
|
+
{
|
119
|
+
UtcTimeStamp now;
|
120
|
+
return now - lastReceivedTime() >= logonTimeout();
|
121
|
+
}
|
122
|
+
bool logoutTimedOut() const
|
123
|
+
{
|
124
|
+
UtcTimeStamp now;
|
125
|
+
return sentLogout() && ( ( now - lastSentTime() ) >= logoutTimeout() );
|
126
|
+
}
|
127
|
+
bool withinHeartBeat() const
|
128
|
+
{
|
129
|
+
UtcTimeStamp now;
|
130
|
+
return ( ( now - lastSentTime() ) < heartBtInt() ) &&
|
131
|
+
( ( now - lastReceivedTime() ) < heartBtInt() );
|
132
|
+
}
|
133
|
+
bool timedOut() const
|
134
|
+
{
|
135
|
+
UtcTimeStamp now;
|
136
|
+
return ( now - lastReceivedTime() ) >= ( 2.4 * ( double ) heartBtInt() );
|
137
|
+
}
|
138
|
+
bool needHeartbeat() const
|
139
|
+
{
|
140
|
+
UtcTimeStamp now;
|
141
|
+
return ( ( now - lastSentTime() ) >= heartBtInt() ) && !testRequest();
|
142
|
+
}
|
143
|
+
bool needTestRequest() const
|
144
|
+
{
|
145
|
+
UtcTimeStamp now;
|
146
|
+
return ( now - lastReceivedTime() ) >=
|
147
|
+
( ( 1.2 * ( ( double ) testRequest() + 1 ) ) * ( double ) heartBtInt() );
|
148
|
+
}
|
149
|
+
|
150
|
+
std::string logoutReason() const
|
151
|
+
{ Locker l( m_mutex ); return m_logoutReason; }
|
152
|
+
void logoutReason( const std::string& value )
|
153
|
+
{ Locker l( m_mutex ); m_logoutReason = value; }
|
154
|
+
|
155
|
+
void queue( int msgSeqNum, const Message& message )
|
156
|
+
{ Locker l( m_mutex ); m_queue[ msgSeqNum ] = message; }
|
157
|
+
bool retrieve( int msgSeqNum, Message& message )
|
158
|
+
{
|
159
|
+
Locker l( m_mutex );
|
160
|
+
Messages::iterator i = m_queue.find( msgSeqNum );
|
161
|
+
if ( i != m_queue.end() )
|
162
|
+
{
|
163
|
+
message = i->second;
|
164
|
+
m_queue.erase( i );
|
165
|
+
return true;
|
166
|
+
}
|
167
|
+
return false;
|
168
|
+
}
|
169
|
+
void clearQueue()
|
170
|
+
{ Locker l( m_mutex ); m_queue.clear(); }
|
171
|
+
|
172
|
+
bool set( int s, const std::string& m ) throw ( IOException )
|
173
|
+
{ Locker l( m_mutex ); return m_pStore->set( s, m ); }
|
174
|
+
void get( int b, int e, std::vector < std::string > &m ) const
|
175
|
+
throw ( IOException )
|
176
|
+
{ Locker l( m_mutex ); m_pStore->get( b, e, m ); }
|
177
|
+
int getNextSenderMsgSeqNum() const throw ( IOException )
|
178
|
+
{ Locker l( m_mutex ); return m_pStore->getNextSenderMsgSeqNum(); }
|
179
|
+
int getNextTargetMsgSeqNum() const throw ( IOException )
|
180
|
+
{ Locker l( m_mutex ); return m_pStore->getNextTargetMsgSeqNum(); }
|
181
|
+
void setNextSenderMsgSeqNum( int n ) throw ( IOException )
|
182
|
+
{ Locker l( m_mutex ); m_pStore->setNextSenderMsgSeqNum( n ); }
|
183
|
+
void setNextTargetMsgSeqNum( int n ) throw ( IOException )
|
184
|
+
{ Locker l( m_mutex ); m_pStore->setNextTargetMsgSeqNum( n ); }
|
185
|
+
void incrNextSenderMsgSeqNum() throw ( IOException )
|
186
|
+
{ Locker l( m_mutex ); m_pStore->incrNextSenderMsgSeqNum(); }
|
187
|
+
void incrNextTargetMsgSeqNum() throw ( IOException )
|
188
|
+
{ Locker l( m_mutex ); m_pStore->incrNextTargetMsgSeqNum(); }
|
189
|
+
UtcTimeStamp getCreationTime() const throw ( IOException )
|
190
|
+
{ Locker l( m_mutex ); return m_pStore->getCreationTime(); }
|
191
|
+
void reset() throw ( IOException )
|
192
|
+
{ Locker l( m_mutex ); m_pStore->reset(); }
|
193
|
+
void refresh() throw ( IOException )
|
194
|
+
{ Locker l( m_mutex ); m_pStore->refresh(); }
|
195
|
+
|
196
|
+
void clear()
|
197
|
+
{ if ( !m_pLog ) return ; Locker l( m_mutex ); m_pLog->clear(); }
|
198
|
+
void backup()
|
199
|
+
{ if ( !m_pLog ) return ; Locker l( m_mutex ); m_pLog->backup(); }
|
200
|
+
void onIncoming( const std::string& string )
|
201
|
+
{ if ( !m_pLog ) return ; Locker l( m_mutex ); m_pLog->onIncoming( string ); }
|
202
|
+
void onOutgoing( const std::string& string )
|
203
|
+
{ if ( !m_pLog ) return ; Locker l( m_mutex ); m_pLog->onOutgoing( string ); }
|
204
|
+
void onEvent( const std::string& string )
|
205
|
+
{ if ( !m_pLog ) return ; Locker l( m_mutex ); m_pLog->onEvent( string ); }
|
206
|
+
|
207
|
+
private:
|
208
|
+
bool m_enabled;
|
209
|
+
bool m_receivedLogon;
|
210
|
+
bool m_sentLogout;
|
211
|
+
bool m_sentLogon;
|
212
|
+
bool m_sentReset;
|
213
|
+
bool m_receivedReset;
|
214
|
+
bool m_initiate;
|
215
|
+
int m_logonTimeout;
|
216
|
+
int m_logoutTimeout;
|
217
|
+
int m_testRequest;
|
218
|
+
ResendRange m_resendRange;
|
219
|
+
HeartBtInt m_heartBtInt;
|
220
|
+
UtcTimeStamp m_lastSentTime;
|
221
|
+
UtcTimeStamp m_lastReceivedTime;
|
222
|
+
std::string m_logoutReason;
|
223
|
+
Messages m_queue;
|
224
|
+
MessageStore* m_pStore;
|
225
|
+
Log* m_pLog;
|
226
|
+
NullLog m_nullLog;
|
227
|
+
mutable Mutex m_mutex;
|
228
|
+
};
|
229
|
+
}
|
230
|
+
|
231
|
+
#endif //FIX_SESSIONSTATE_H
|
@@ -0,0 +1,100 @@
|
|
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 "Settings.h"
|
27
|
+
|
28
|
+
namespace FIX
|
29
|
+
{
|
30
|
+
bool isComment( const std::string& line )
|
31
|
+
{
|
32
|
+
if( line.size() == 0 )
|
33
|
+
return false;
|
34
|
+
|
35
|
+
return line[0] == '#';
|
36
|
+
}
|
37
|
+
|
38
|
+
bool isSection( const std::string& line )
|
39
|
+
{
|
40
|
+
if( line.size() == 0 )
|
41
|
+
return false;
|
42
|
+
|
43
|
+
return line[0] == '[' && line[line.size()-1] == ']';
|
44
|
+
}
|
45
|
+
|
46
|
+
std::string splitSection( const std::string& line )
|
47
|
+
{
|
48
|
+
return string_strip(std::string( line, 1, line.size() - 2 ));
|
49
|
+
}
|
50
|
+
|
51
|
+
bool isKeyValue( const std::string& line )
|
52
|
+
{
|
53
|
+
return line.find( '=' ) != std::string::npos;
|
54
|
+
}
|
55
|
+
|
56
|
+
std::pair<std::string, std::string> splitKeyValue( const std::string& line )
|
57
|
+
{
|
58
|
+
size_t equals = line.find( '=' );
|
59
|
+
std::string key = std::string( line, 0, equals );
|
60
|
+
std::string value = std::string( line, equals + 1, std::string::npos );
|
61
|
+
return std::pair<std::string, std::string>( key, value );
|
62
|
+
}
|
63
|
+
|
64
|
+
std::istream& operator>>( std::istream& stream, Settings& s )
|
65
|
+
{
|
66
|
+
char buffer[1024];
|
67
|
+
std::string line;
|
68
|
+
Settings::Sections::iterator section = s.m_sections.end();;
|
69
|
+
|
70
|
+
while( stream.getline(buffer, 1024) )
|
71
|
+
{
|
72
|
+
line = string_strip( buffer );
|
73
|
+
if( isComment(line) )
|
74
|
+
{
|
75
|
+
continue;
|
76
|
+
}
|
77
|
+
else if( isSection(line) )
|
78
|
+
{
|
79
|
+
section = s.m_sections.insert( s.m_sections.end(), Dictionary(splitSection(line)) );
|
80
|
+
}
|
81
|
+
else if( isKeyValue(line) )
|
82
|
+
{
|
83
|
+
std::pair<std::string, std::string> keyValue = splitKeyValue( line );
|
84
|
+
if( section == s.m_sections.end() )
|
85
|
+
continue;
|
86
|
+
(*section).setString( keyValue.first, keyValue.second );
|
87
|
+
}
|
88
|
+
}
|
89
|
+
return stream;
|
90
|
+
}
|
91
|
+
|
92
|
+
Settings::Sections Settings::get( const std::string& name ) const
|
93
|
+
{
|
94
|
+
Sections sections;
|
95
|
+
for ( Sections::size_type i = 0; i < m_sections.size(); ++i )
|
96
|
+
if ( m_sections[ i ].getName() == name )
|
97
|
+
sections.push_back( m_sections[ i ] );
|
98
|
+
return sections;
|
99
|
+
}
|
100
|
+
}
|
@@ -0,0 +1,53 @@
|
|
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_SETTINGS_H
|
23
|
+
#define FIX_SETTINGS_H
|
24
|
+
|
25
|
+
#ifdef _MSC_VER
|
26
|
+
#pragma warning( disable : 4503 4355 4786 4290 )
|
27
|
+
#endif
|
28
|
+
|
29
|
+
#include "Dictionary.h"
|
30
|
+
#include <string>
|
31
|
+
#include <vector>
|
32
|
+
#include <map>
|
33
|
+
#include <iostream>
|
34
|
+
|
35
|
+
namespace FIX
|
36
|
+
{
|
37
|
+
/// Internal representation of QuickFIX configuration settings.
|
38
|
+
class Settings
|
39
|
+
{
|
40
|
+
public:
|
41
|
+
typedef std::vector < Dictionary > Sections;
|
42
|
+
|
43
|
+
Sections get( const std::string& name ) const;
|
44
|
+
|
45
|
+
friend std::istream& operator>>( std::istream&, Settings& );
|
46
|
+
private:
|
47
|
+
Sections m_sections;
|
48
|
+
};
|
49
|
+
|
50
|
+
std::istream& operator>>( std::istream&, Settings& );
|
51
|
+
}
|
52
|
+
|
53
|
+
#endif //FIX_SETTINGS_H
|
@@ -0,0 +1,150 @@
|
|
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 SHARED_ARRAY
|
23
|
+
#define SHARED_ARRAY
|
24
|
+
|
25
|
+
#include "AtomicCount.h"
|
26
|
+
|
27
|
+
namespace FIX
|
28
|
+
{
|
29
|
+
/// Shared array with atomic reference count
|
30
|
+
template<typename T>
|
31
|
+
class shared_array
|
32
|
+
{
|
33
|
+
public:
|
34
|
+
shared_array()
|
35
|
+
: m_size(0)
|
36
|
+
, m_buffer(0)
|
37
|
+
{}
|
38
|
+
|
39
|
+
shared_array(const shared_array& rhs)
|
40
|
+
: m_size(rhs.m_size)
|
41
|
+
, m_buffer(rhs.m_buffer)
|
42
|
+
{
|
43
|
+
rhs.attach();
|
44
|
+
}
|
45
|
+
|
46
|
+
~shared_array()
|
47
|
+
{ release(); }
|
48
|
+
|
49
|
+
shared_array& operator=(const shared_array& rhs)
|
50
|
+
{
|
51
|
+
if( &rhs == this )
|
52
|
+
return *this;
|
53
|
+
|
54
|
+
rhs.attach();
|
55
|
+
release();
|
56
|
+
|
57
|
+
m_size = rhs.m_size;
|
58
|
+
m_buffer = rhs.m_buffer;
|
59
|
+
|
60
|
+
return *this;
|
61
|
+
}
|
62
|
+
|
63
|
+
std::size_t size() const
|
64
|
+
{ return m_size; }
|
65
|
+
|
66
|
+
bool empty() const
|
67
|
+
{ return m_buffer == 0; }
|
68
|
+
|
69
|
+
operator T* () const
|
70
|
+
{ return m_buffer; }
|
71
|
+
|
72
|
+
//optimized function to allocate storage for buffer and counter object at once
|
73
|
+
static shared_array create(const std::size_t nSize)
|
74
|
+
{
|
75
|
+
if(nSize <= 0)
|
76
|
+
return shared_array();
|
77
|
+
|
78
|
+
//verify the needed buffer size to allocate counter object and nSize elements
|
79
|
+
const std::size_t sizeToAllocate = nSize + ( sizeof(atomic_count) / sizeof(T) + 1 );
|
80
|
+
|
81
|
+
//allocate and zero-fill the buffer
|
82
|
+
T* storage = new T[ sizeToAllocate ];
|
83
|
+
memset(storage, 0, sizeToAllocate * sizeof(T));
|
84
|
+
|
85
|
+
// create the counter object at the end of the storage
|
86
|
+
// with initial reference count set to 1
|
87
|
+
new (&storage[nSize]) atomic_count( 1 );
|
88
|
+
|
89
|
+
return shared_array(storage, nSize);
|
90
|
+
}
|
91
|
+
|
92
|
+
private:
|
93
|
+
|
94
|
+
shared_array( T * buff, std::size_t nSize )
|
95
|
+
: m_size(nSize)
|
96
|
+
, m_buffer(buff)
|
97
|
+
{
|
98
|
+
|
99
|
+
}
|
100
|
+
|
101
|
+
atomic_count* get_counter() const
|
102
|
+
{
|
103
|
+
return reinterpret_cast<atomic_count*>( &m_buffer[ size() ] );
|
104
|
+
}
|
105
|
+
|
106
|
+
void increment_reference_count() const
|
107
|
+
{
|
108
|
+
atomic_count* counter = get_counter();
|
109
|
+
++(*counter);
|
110
|
+
}
|
111
|
+
|
112
|
+
long decrement_reference_count()
|
113
|
+
{
|
114
|
+
atomic_count* counter = get_counter();
|
115
|
+
return --(*counter);
|
116
|
+
}
|
117
|
+
|
118
|
+
void attach() const
|
119
|
+
{
|
120
|
+
if( !empty() )
|
121
|
+
increment_reference_count();
|
122
|
+
}
|
123
|
+
|
124
|
+
void release()
|
125
|
+
{
|
126
|
+
if( empty() )
|
127
|
+
return;
|
128
|
+
|
129
|
+
//free object if reference count has decreased to zero
|
130
|
+
if( decrement_reference_count() == 0)
|
131
|
+
{
|
132
|
+
T * tmpBuff = m_buffer;
|
133
|
+
atomic_count* tmpCounter = get_counter();
|
134
|
+
|
135
|
+
m_buffer = 0;
|
136
|
+
m_size = 0;
|
137
|
+
|
138
|
+
//explicitly call destructor for the counter object
|
139
|
+
tmpCounter->~atomic_count();
|
140
|
+
|
141
|
+
delete [] tmpBuff;
|
142
|
+
}
|
143
|
+
}
|
144
|
+
|
145
|
+
std::size_t m_size;
|
146
|
+
T * m_buffer;
|
147
|
+
};
|
148
|
+
}
|
149
|
+
|
150
|
+
#endif
|