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.
- 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,105 @@
|
|
|
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_DATABASECONNECTIONID_H
|
|
23
|
+
#define FIX_DATABASECONNECTIONID_H
|
|
24
|
+
|
|
25
|
+
#ifdef _MSC_VER
|
|
26
|
+
#pragma warning( disable : 4503 4355 4786 4290 )
|
|
27
|
+
#endif
|
|
28
|
+
|
|
29
|
+
#include <string>
|
|
30
|
+
#include <map>
|
|
31
|
+
|
|
32
|
+
namespace FIX
|
|
33
|
+
{
|
|
34
|
+
class DatabaseConnectionID
|
|
35
|
+
{
|
|
36
|
+
public:
|
|
37
|
+
DatabaseConnectionID
|
|
38
|
+
( const std::string& database, const std::string& user,
|
|
39
|
+
const std::string& password, const std::string& host, short port )
|
|
40
|
+
: m_database( database ), m_user( user ), m_password( password ),
|
|
41
|
+
m_host( host ), m_port( port ) {}
|
|
42
|
+
|
|
43
|
+
friend bool operator<( const DatabaseConnectionID&, const DatabaseConnectionID& );
|
|
44
|
+
friend bool operator==( const DatabaseConnectionID&, const DatabaseConnectionID& );
|
|
45
|
+
friend bool operator!=( const DatabaseConnectionID&, const DatabaseConnectionID& );
|
|
46
|
+
|
|
47
|
+
const std::string& getDatabase() const
|
|
48
|
+
{ return m_database; }
|
|
49
|
+
const std::string& getUser() const
|
|
50
|
+
{ return m_user; }
|
|
51
|
+
const std::string& getPassword() const
|
|
52
|
+
{ return m_password; }
|
|
53
|
+
const std::string& getHost() const
|
|
54
|
+
{ return m_host; }
|
|
55
|
+
short getPort() const
|
|
56
|
+
{ return m_port; }
|
|
57
|
+
|
|
58
|
+
private:
|
|
59
|
+
std::string m_database;
|
|
60
|
+
std::string m_user;
|
|
61
|
+
std::string m_password;
|
|
62
|
+
std::string m_host;
|
|
63
|
+
short m_port;
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
inline bool operator<( const DatabaseConnectionID& lhs, const DatabaseConnectionID& rhs )
|
|
67
|
+
{
|
|
68
|
+
if ( lhs.m_database < rhs.m_database )
|
|
69
|
+
return true;
|
|
70
|
+
else if ( rhs.m_database < lhs.m_database )
|
|
71
|
+
return false;
|
|
72
|
+
else if ( lhs.m_user < rhs.m_user )
|
|
73
|
+
return true;
|
|
74
|
+
else if ( rhs.m_user < lhs.m_user )
|
|
75
|
+
return false;
|
|
76
|
+
else if ( lhs.m_password < rhs.m_password )
|
|
77
|
+
return true;
|
|
78
|
+
else if ( rhs.m_password < lhs.m_password )
|
|
79
|
+
return false;
|
|
80
|
+
else if ( lhs.m_host < rhs.m_host )
|
|
81
|
+
return true;
|
|
82
|
+
else if ( rhs.m_host < lhs.m_host )
|
|
83
|
+
return false;
|
|
84
|
+
else if ( lhs.m_port < rhs.m_port )
|
|
85
|
+
return true;
|
|
86
|
+
else if ( rhs.m_port < lhs.m_port )
|
|
87
|
+
return false;
|
|
88
|
+
else
|
|
89
|
+
return false;
|
|
90
|
+
}
|
|
91
|
+
inline bool operator==( const DatabaseConnectionID& lhs, const DatabaseConnectionID& rhs )
|
|
92
|
+
{
|
|
93
|
+
return ( ( lhs.m_database == rhs.m_database ) &&
|
|
94
|
+
( lhs.m_user == rhs.m_user ) &&
|
|
95
|
+
( lhs.m_password == rhs.m_password ) &&
|
|
96
|
+
( lhs.m_host == rhs.m_host ) &&
|
|
97
|
+
( lhs.m_port == rhs.m_port ));
|
|
98
|
+
}
|
|
99
|
+
inline bool operator!=( const DatabaseConnectionID& lhs, const DatabaseConnectionID& rhs )
|
|
100
|
+
{
|
|
101
|
+
return !( lhs == rhs );
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
#endif
|
|
@@ -0,0 +1,91 @@
|
|
|
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_DATABASECONNECTIONPOOL_H
|
|
23
|
+
#define FIX_DATABASECONNECTIONPOOL_H
|
|
24
|
+
|
|
25
|
+
#ifdef _MSC_VER
|
|
26
|
+
#pragma warning( disable : 4503 4355 4786 4290 )
|
|
27
|
+
#endif
|
|
28
|
+
|
|
29
|
+
#include "DatabaseConnectionID.h"
|
|
30
|
+
#include <string>
|
|
31
|
+
#include <map>
|
|
32
|
+
|
|
33
|
+
namespace FIX
|
|
34
|
+
{
|
|
35
|
+
template< typename T > class DatabaseConnectionPool
|
|
36
|
+
{
|
|
37
|
+
public:
|
|
38
|
+
DatabaseConnectionPool( bool poolConnections )
|
|
39
|
+
: m_poolConnections( poolConnections ) {}
|
|
40
|
+
|
|
41
|
+
T* create( const DatabaseConnectionID& id )
|
|
42
|
+
{
|
|
43
|
+
if( !m_poolConnections )
|
|
44
|
+
return new T( id );
|
|
45
|
+
|
|
46
|
+
if( m_connections.find( id ) == m_connections.end() )
|
|
47
|
+
{
|
|
48
|
+
m_connections[id] = Connection
|
|
49
|
+
( new T(id), 0 );
|
|
50
|
+
}
|
|
51
|
+
m_connections[id].second++;
|
|
52
|
+
return m_connections[id].first;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
bool destroy( T* pConnection )
|
|
56
|
+
{
|
|
57
|
+
if( !m_poolConnections )
|
|
58
|
+
{
|
|
59
|
+
delete pConnection;
|
|
60
|
+
return true;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const DatabaseConnectionID& id = pConnection->connectionID();
|
|
64
|
+
if( m_connections.find( id ) == m_connections.end() )
|
|
65
|
+
return false;
|
|
66
|
+
|
|
67
|
+
Connection& connection = m_connections[id];
|
|
68
|
+
if( connection.first != pConnection )
|
|
69
|
+
return false;
|
|
70
|
+
|
|
71
|
+
connection.second--;
|
|
72
|
+
if( connection.second == 0 )
|
|
73
|
+
{
|
|
74
|
+
m_connections.erase( id );
|
|
75
|
+
delete pConnection;
|
|
76
|
+
}
|
|
77
|
+
return true;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
private:
|
|
81
|
+
typedef std::pair<T*, int>
|
|
82
|
+
Connection;
|
|
83
|
+
typedef std::map<DatabaseConnectionID, Connection>
|
|
84
|
+
Connections;
|
|
85
|
+
|
|
86
|
+
Connections m_connections;
|
|
87
|
+
bool m_poolConnections;
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
#endif
|
|
@@ -0,0 +1,162 @@
|
|
|
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 "Dictionary.h"
|
|
27
|
+
#include "FieldConvertors.h"
|
|
28
|
+
#include <algorithm>
|
|
29
|
+
|
|
30
|
+
namespace FIX
|
|
31
|
+
{
|
|
32
|
+
std::string Dictionary::getString( const std::string& key, bool capitalize ) const
|
|
33
|
+
throw( ConfigError, FieldConvertError )
|
|
34
|
+
{
|
|
35
|
+
Data::const_iterator i = m_data.find( string_toUpper(key) );
|
|
36
|
+
if ( i == m_data.end() ) throw ConfigError( key + " not defined" );
|
|
37
|
+
|
|
38
|
+
std::string result = i->second;
|
|
39
|
+
if( capitalize )
|
|
40
|
+
std::transform(result.begin(), result.end(), result.begin(), toupper);
|
|
41
|
+
|
|
42
|
+
return result;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
int Dictionary::getInt( const std::string& key ) const
|
|
46
|
+
throw( ConfigError, FieldConvertError )
|
|
47
|
+
{
|
|
48
|
+
try
|
|
49
|
+
{
|
|
50
|
+
return IntConvertor::convert( getString(key) );
|
|
51
|
+
}
|
|
52
|
+
catch ( FieldConvertError& )
|
|
53
|
+
{
|
|
54
|
+
throw ConfigError( "Illegal value " + getString(key) + " for " + key );
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
double Dictionary::getDouble( const std::string& key ) const
|
|
59
|
+
throw( ConfigError, FieldConvertError )
|
|
60
|
+
{
|
|
61
|
+
try
|
|
62
|
+
{
|
|
63
|
+
return DoubleConvertor::convert( getString(key) );
|
|
64
|
+
}
|
|
65
|
+
catch ( FieldConvertError& )
|
|
66
|
+
{
|
|
67
|
+
throw ConfigError( "Illegal value " + getString(key) + " for " + key );
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
bool Dictionary::getBool( const std::string& key ) const
|
|
72
|
+
throw( ConfigError, FieldConvertError )
|
|
73
|
+
{
|
|
74
|
+
try
|
|
75
|
+
{
|
|
76
|
+
return BoolConvertor::convert( getString(key) );
|
|
77
|
+
}
|
|
78
|
+
catch ( FieldConvertError& )
|
|
79
|
+
{
|
|
80
|
+
throw ConfigError( "Illegal value " + getString(key) + " for " + key );
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
int Dictionary::getDay( const std::string& key ) const
|
|
85
|
+
throw( ConfigError, FieldConvertError )
|
|
86
|
+
{
|
|
87
|
+
try
|
|
88
|
+
{
|
|
89
|
+
std::string value = getString(key);
|
|
90
|
+
if( value.size() < 2 ) throw FieldConvertError(0);
|
|
91
|
+
std::string abbr = value.substr(0, 2);
|
|
92
|
+
std::transform( abbr.begin(), abbr.end(), abbr.begin(), tolower );
|
|
93
|
+
if( abbr == "su" ) return 1;
|
|
94
|
+
if( abbr == "mo" ) return 2;
|
|
95
|
+
if( abbr == "tu" ) return 3;
|
|
96
|
+
if( abbr == "we" ) return 4;
|
|
97
|
+
if( abbr == "th" ) return 5;
|
|
98
|
+
if( abbr == "fr" ) return 6;
|
|
99
|
+
if( abbr == "sa" ) return 7;
|
|
100
|
+
if( value.size() < 2 ) throw FieldConvertError(0);
|
|
101
|
+
}
|
|
102
|
+
catch ( FieldConvertError& )
|
|
103
|
+
{
|
|
104
|
+
throw ConfigError( "Illegal value " + getString(key) + " for " + key );
|
|
105
|
+
}
|
|
106
|
+
return -1;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
void Dictionary::setString( const std::string& key, const std::string& value )
|
|
110
|
+
{
|
|
111
|
+
m_data[ string_strip(string_toUpper(key)) ] = string_strip(value);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
void Dictionary::setInt( const std::string& key, int value )
|
|
115
|
+
{
|
|
116
|
+
m_data[ string_strip(string_toUpper(key)) ] = IntConvertor::convert( value );
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
void Dictionary::setDouble( const std::string& key, double value )
|
|
120
|
+
{
|
|
121
|
+
m_data[ string_strip(string_toUpper(key)) ] = DoubleConvertor::convert( value );
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
void Dictionary::setBool( const std::string& key, bool value )
|
|
125
|
+
{
|
|
126
|
+
m_data[ string_strip(string_toUpper(key)) ] = BoolConvertor::convert( value );
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
void Dictionary::setDay( const std::string& key, int value )
|
|
130
|
+
{
|
|
131
|
+
switch( value )
|
|
132
|
+
{
|
|
133
|
+
case 1:
|
|
134
|
+
setString( key, "SU" ); break;
|
|
135
|
+
case 2:
|
|
136
|
+
setString( key, "MO" ); break;
|
|
137
|
+
case 3:
|
|
138
|
+
setString( key, "TU" ); break;
|
|
139
|
+
case 4:
|
|
140
|
+
setString( key, "WE" ); break;
|
|
141
|
+
case 5:
|
|
142
|
+
setString( key, "TH" ); break;
|
|
143
|
+
case 6:
|
|
144
|
+
setString( key, "FR" ); break;
|
|
145
|
+
case 7:
|
|
146
|
+
setString( key, "SA" ); break;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
bool Dictionary::has( const std::string& key ) const
|
|
151
|
+
{
|
|
152
|
+
return m_data.find( string_toUpper(key) ) != m_data.end();
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
void Dictionary::merge( const Dictionary& toMerge )
|
|
156
|
+
{
|
|
157
|
+
Data::const_iterator i = toMerge.m_data.begin();
|
|
158
|
+
for ( ; i != toMerge.m_data.end(); ++i )
|
|
159
|
+
if ( m_data.find( i->first ) == m_data.end() )
|
|
160
|
+
m_data[ i->first ] = i->second;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
@@ -0,0 +1,94 @@
|
|
|
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_DICTIONARY_H
|
|
23
|
+
#define FIX_DICTIONARY_H
|
|
24
|
+
|
|
25
|
+
#ifdef _MSC_VER
|
|
26
|
+
#pragma warning( disable : 4503 4355 4786 4290 )
|
|
27
|
+
#endif
|
|
28
|
+
|
|
29
|
+
#include <map>
|
|
30
|
+
#include <string>
|
|
31
|
+
#include "Exceptions.h"
|
|
32
|
+
|
|
33
|
+
namespace FIX
|
|
34
|
+
{
|
|
35
|
+
/// For storage and retrieval of key/value pairs.
|
|
36
|
+
class Dictionary
|
|
37
|
+
{
|
|
38
|
+
public:
|
|
39
|
+
Dictionary( const std::string& name ) : m_name( name ) {}
|
|
40
|
+
Dictionary() {}
|
|
41
|
+
virtual ~Dictionary() {}
|
|
42
|
+
|
|
43
|
+
typedef std::map < std::string, std::string > Data;
|
|
44
|
+
typedef Data::const_iterator iterator;
|
|
45
|
+
typedef iterator const_iterator;
|
|
46
|
+
|
|
47
|
+
/// Get the name of the dictionary.
|
|
48
|
+
std::string getName() const { return m_name; }
|
|
49
|
+
/// Return the number of key/value pairs.
|
|
50
|
+
size_t size() const { return m_data.size(); }
|
|
51
|
+
|
|
52
|
+
/// Get a value as a string.
|
|
53
|
+
std::string getString( const std::string&, bool capitalize = false ) const
|
|
54
|
+
throw( ConfigError, FieldConvertError );
|
|
55
|
+
/// Get a value as a int.
|
|
56
|
+
int getInt( const std::string& ) const
|
|
57
|
+
throw( ConfigError, FieldConvertError );
|
|
58
|
+
/// Get a value as a double.
|
|
59
|
+
double getDouble( const std::string& ) const
|
|
60
|
+
throw( ConfigError, FieldConvertError );
|
|
61
|
+
/// Get a value as a bool
|
|
62
|
+
bool getBool( const std::string& ) const
|
|
63
|
+
throw( ConfigError, FieldConvertError );
|
|
64
|
+
/// Get a value as a day of week
|
|
65
|
+
int getDay( const std::string& ) const
|
|
66
|
+
throw( ConfigError, FieldConvertError );
|
|
67
|
+
|
|
68
|
+
/// Set a value from a string.
|
|
69
|
+
void setString( const std::string&, const std::string& );
|
|
70
|
+
/// Set a value from a int.
|
|
71
|
+
void setInt( const std::string&, int );
|
|
72
|
+
/// Set a value from a double.
|
|
73
|
+
void setDouble( const std::string&, double );
|
|
74
|
+
/// Set a value from a bool
|
|
75
|
+
void setBool( const std::string&, bool );
|
|
76
|
+
/// Set a value from a day
|
|
77
|
+
void setDay( const std::string&, int );
|
|
78
|
+
|
|
79
|
+
/// Check if the dictionary contains a value for key.
|
|
80
|
+
bool has( const std::string& ) const;
|
|
81
|
+
/// Merge two dictionaries.
|
|
82
|
+
void merge( const Dictionary& );
|
|
83
|
+
|
|
84
|
+
iterator begin() const { return m_data.begin(); }
|
|
85
|
+
iterator end() const { return m_data.end(); }
|
|
86
|
+
|
|
87
|
+
private:
|
|
88
|
+
Data m_data;
|
|
89
|
+
std::string m_name;
|
|
90
|
+
};
|
|
91
|
+
/*! @} */
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
#endif //FIX_DICTIONARY_H
|
|
@@ -0,0 +1,95 @@
|
|
|
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_EVENT_H
|
|
23
|
+
#define FIX_EVENT_H
|
|
24
|
+
|
|
25
|
+
#include "Utility.h"
|
|
26
|
+
#include <math.h>
|
|
27
|
+
|
|
28
|
+
#ifndef _MSC_VER
|
|
29
|
+
#include <pthread.h>
|
|
30
|
+
#include <cmath>
|
|
31
|
+
#endif
|
|
32
|
+
|
|
33
|
+
namespace FIX
|
|
34
|
+
{
|
|
35
|
+
/// Portable implementation of an event/conditional mutex
|
|
36
|
+
class Event
|
|
37
|
+
{
|
|
38
|
+
public:
|
|
39
|
+
Event()
|
|
40
|
+
{
|
|
41
|
+
#ifdef _MSC_VER
|
|
42
|
+
m_event = CreateEvent( 0, false, false, 0 );
|
|
43
|
+
#else
|
|
44
|
+
pthread_mutex_init( &m_mutex, 0 );
|
|
45
|
+
pthread_cond_init( &m_event, 0 );
|
|
46
|
+
#endif
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
~Event()
|
|
50
|
+
{
|
|
51
|
+
#ifdef _MSC_VER
|
|
52
|
+
CloseHandle( m_event );
|
|
53
|
+
#else
|
|
54
|
+
pthread_cond_destroy( &m_event );
|
|
55
|
+
pthread_mutex_destroy( &m_mutex );
|
|
56
|
+
#endif
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
void signal()
|
|
60
|
+
{
|
|
61
|
+
#ifdef _MSC_VER
|
|
62
|
+
SetEvent( m_event );
|
|
63
|
+
#else
|
|
64
|
+
pthread_mutex_lock( &m_mutex );
|
|
65
|
+
pthread_cond_broadcast( &m_event );
|
|
66
|
+
pthread_mutex_unlock( &m_mutex );
|
|
67
|
+
#endif
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
void wait( double s )
|
|
71
|
+
{
|
|
72
|
+
#ifdef _MSC_VER
|
|
73
|
+
WaitForSingleObject( m_event, (long)(s * 1000) );
|
|
74
|
+
#else
|
|
75
|
+
pthread_mutex_lock( &m_mutex );
|
|
76
|
+
timespec time, remainder;
|
|
77
|
+
double intpart;
|
|
78
|
+
time.tv_nsec = (long)(modf(s, &intpart) * 1e9);
|
|
79
|
+
time.tv_sec = (int)intpart;
|
|
80
|
+
pthread_cond_timedwait( &m_event, &m_mutex, &time );
|
|
81
|
+
pthread_mutex_unlock( &m_mutex );
|
|
82
|
+
#endif
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
private:
|
|
86
|
+
#ifdef _MSC_VER
|
|
87
|
+
HANDLE m_event;
|
|
88
|
+
#else
|
|
89
|
+
pthread_cond_t m_event;
|
|
90
|
+
pthread_mutex_t m_mutex;
|
|
91
|
+
#endif
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
#endif
|