Last active
August 29, 2015 14:15
-
-
Save wldcordeiro/cc9a56b5a8d767c85076 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bool getFieldName( int field, std::string& name ) const | |
{ | |
FieldToName::const_iterator i = m_fieldNames.find( field ); | |
if(i == m_fieldNames.end()) return false; | |
name = i->second; | |
return true; | |
} | |
bool getFieldTag( const std::string& name, int& field ) const | |
{ | |
NameToField::const_iterator i = m_names.find( name ); | |
if(i == m_names.end()) return false; | |
field = i->second; | |
return true; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def getFieldName(self, field: 'int', name: 'std::string &') -> "bool": | |
return _quickfix.DataDictionary_getFieldName(self, field, name) | |
def getFieldTag(self, name: 'std::string const &', field: 'int &') -> "bool": | |
return _quickfix.DataDictionary_getFieldTag(self, name, field) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SWIGINTERN PyObject *_wrap_DataDictionary_getFieldName(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { | |
PyObject *resultobj = 0; | |
FIX::DataDictionary *arg1 = (FIX::DataDictionary *) 0 ; | |
int arg2 ; | |
std::string *arg3 = 0 ; | |
void *argp1 = 0 ; | |
int res1 = 0 ; | |
int val2 ; | |
int ecode2 = 0 ; | |
std::string temp3 ; | |
PyObject * obj0 = 0 ; | |
PyObject * obj1 = 0 ; | |
PyObject * obj2 = 0 ; | |
bool result; | |
if (!PyArg_ParseTuple(args,(char *)"OOO:DataDictionary_getFieldName",&obj0,&obj1,&obj2)) SWIG_fail; | |
res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_FIX__DataDictionary, 0 | 0 ); | |
if (!SWIG_IsOK(res1)) { | |
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DataDictionary_getFieldName" "', argument " "1"" of type '" "FIX::DataDictionary const *""'"); | |
} | |
arg1 = reinterpret_cast< FIX::DataDictionary * >(argp1); | |
ecode2 = SWIG_AsVal_int(obj1, &val2); | |
if (!SWIG_IsOK(ecode2)) { | |
SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "DataDictionary_getFieldName" "', argument " "2"" of type '" "int""'"); | |
} | |
arg2 = static_cast< int >(val2); | |
{ | |
temp3 = std::string((char*)PyString_AsString(obj2)); | |
arg3 = &temp3; | |
} | |
{ | |
SWIG_PYTHON_THREAD_BEGIN_ALLOW; | |
result = (bool)((FIX::DataDictionary const *)arg1)->getFieldName(arg2,*arg3); | |
SWIG_PYTHON_THREAD_END_ALLOW; | |
} | |
resultobj = SWIG_From_bool(static_cast< bool >(result)); | |
{ | |
if( std::string("std::string &") == "std::string &" ) | |
{ | |
if( !PyDict_Check(resultobj) ) | |
resultobj = PyDict_New(); | |
PyDict_SetItem( resultobj, PyInt_FromLong(PyDict_Size(resultobj)), PyString_FromString(arg3->c_str()) ); | |
} | |
} | |
return resultobj; | |
fail: | |
return NULL; | |
} | |
SWIGINTERN PyObject *_wrap_DataDictionary_getFieldTag(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { | |
PyObject *resultobj = 0; | |
FIX::DataDictionary *arg1 = (FIX::DataDictionary *) 0 ; | |
std::string *arg2 = 0 ; | |
int *arg3 = 0 ; | |
void *argp1 = 0 ; | |
int res1 = 0 ; | |
int res2 = SWIG_OLDOBJ ; | |
int temp3 ; | |
PyObject * obj0 = 0 ; | |
PyObject * obj1 = 0 ; | |
PyObject * obj2 = 0 ; | |
bool result; | |
if (!PyArg_ParseTuple(args,(char *)"OOO:DataDictionary_getFieldTag",&obj0,&obj1,&obj2)) SWIG_fail; | |
res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_FIX__DataDictionary, 0 | 0 ); | |
if (!SWIG_IsOK(res1)) { | |
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DataDictionary_getFieldTag" "', argument " "1"" of type '" "FIX::DataDictionary const *""'"); | |
} | |
arg1 = reinterpret_cast< FIX::DataDictionary * >(argp1); | |
{ | |
std::string *ptr = (std::string *)0; | |
res2 = SWIG_AsPtr_std_string(obj1, &ptr); | |
if (!SWIG_IsOK(res2)) { | |
SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "DataDictionary_getFieldTag" "', argument " "2"" of type '" "std::string const &""'"); | |
} | |
if (!ptr) { | |
SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "DataDictionary_getFieldTag" "', argument " "2"" of type '" "std::string const &""'"); | |
} | |
arg2 = ptr; | |
} | |
{ | |
SWIG_AsVal_int(obj2, &temp3); | |
arg3 = &temp3; | |
} | |
{ | |
SWIG_PYTHON_THREAD_BEGIN_ALLOW; | |
result = (bool)((FIX::DataDictionary const *)arg1)->getFieldTag((std::string const &)*arg2,*arg3); | |
SWIG_PYTHON_THREAD_END_ALLOW; | |
} | |
resultobj = SWIG_From_bool(static_cast< bool >(result)); | |
{ | |
if( std::string("std::string const &") == "std::string &" ) | |
{ | |
if( !PyDict_Check(resultobj) ) | |
resultobj = PyDict_New(); | |
PyDict_SetItem( resultobj, PyInt_FromLong(PyDict_Size(resultobj)), PyString_FromString(arg2->c_str()) ); | |
} | |
} | |
{ | |
if( std::string("int &") == "int &" ) | |
{ | |
if( !PyDict_Check(resultobj) ) | |
resultobj = PyDict_New(); | |
PyDict_SetItem( resultobj, PyInt_FromLong(PyDict_Size(resultobj)), PyInt_FromLong(*arg3) ); | |
} | |
} | |
if (SWIG_IsNewObj(res2)) delete arg2; | |
return resultobj; | |
fail: | |
if (SWIG_IsNewObj(res2)) delete arg2; | |
return NULL; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This file is really called quickfix.i but I wanted Gist to give it syntax highlighting. | |
#ifdef SWIGPYTHON | |
%typemap(in) std::string& (std::string temp) { | |
temp = std::string((char*)PyString_AsString($input)); | |
$1 = &temp; | |
} | |
%typemap(argout) std::string& { | |
if( std::string("$1_type") == "std::string &" ) | |
{ | |
if( !PyDict_Check(resultobj) ) | |
resultobj = PyDict_New(); | |
PyDict_SetItem( resultobj, PyInt_FromLong(PyDict_Size(resultobj)), PyString_FromString($1->c_str()) ); | |
} | |
} | |
%typemap(in) int& (int temp) { | |
SWIG_AsVal_int($input, &temp); | |
$1 = &temp; | |
} | |
%typemap(argout) int& { | |
if( std::string("$1_type") == "int &" ) | |
{ | |
if( !PyDict_Check(resultobj) ) | |
resultobj = PyDict_New(); | |
PyDict_SetItem( resultobj, PyInt_FromLong(PyDict_Size(resultobj)), PyInt_FromLong(*$1) ); | |
} | |
} | |
#endif | |
%typemap(in) FIX::DataDictionary const *& (FIX::DataDictionary* temp) { | |
$1 = new FIX::DataDictionary*[1]; | |
*$1 = temp; | |
} | |
%typemap(free) FIX::DataDictionary const *& { | |
delete[] temp; | |
} | |
%typemap(argout) FIX::DataDictionary const *& { | |
void* argp; | |
FIX::DataDictionary* pDD = 0; | |
int res = SWIG_ConvertPtr($input, &argp, SWIGTYPE_p_FIX__DataDictionary, 0 ); | |
pDD = reinterpret_cast< FIX::DataDictionary * >(argp); | |
*pDD = *(*$1); | |
} | |
%include ../quickfix.i | |
%pythoncode %{ | |
#ifdef SWIGPYTHON | |
try: | |
import thread | |
except ImportError: | |
import _thread as thread | |
def _quickfix_start_thread(i_or_a): | |
i_or_a.block() | |
#endif | |
%} | |
%feature("shadow") FIX::Initiator::start() %{ | |
def start(self): | |
thread.start_new_thread(_quickfix_start_thread, (self,)) | |
%} | |
%feature("shadow") FIX::Acceptor::start() %{ | |
def start(self): | |
thread.start_new_thread(_quickfix_start_thread, (self,)) | |
%} | |
%feature("director:except") FIX::Application::onCreate { | |
#ifdef SWIGPYTHON | |
if( $error != NULL ) { | |
PyObject *ptype, *pvalue, *ptraceback; | |
PyErr_Fetch( &ptype, &pvalue, &ptraceback ); | |
PyErr_Restore( ptype, pvalue, ptraceback ); | |
PyErr_Print(); | |
Py_Exit(1); | |
} | |
#endif | |
} | |
%feature("director:except") FIX::Application::onLogon { | |
#ifdef SWIGPYTHON | |
if( $error != NULL ) { | |
PyObject *ptype, *pvalue, *ptraceback; | |
PyErr_Fetch( &ptype, &pvalue, &ptraceback ); | |
PyErr_Restore( ptype, pvalue, ptraceback ); | |
PyErr_Print(); | |
Py_Exit(1); | |
} | |
#endif | |
} | |
%feature("director:except") FIX::Application::onLogout { | |
#ifdef SWIGPYTHON | |
if( $error != NULL ) { | |
PyObject *ptype, *pvalue, *ptraceback; | |
PyErr_Fetch( &ptype, &pvalue, &ptraceback ); | |
PyErr_Restore( ptype, pvalue, ptraceback ); | |
PyErr_Print(); | |
Py_Exit(1); | |
} | |
#endif | |
} | |
%feature("director:except") FIX::Application::toAdmin { | |
#ifdef SWIGPYTHON | |
if( $error != NULL ) { | |
PyObject *ptype, *pvalue, *ptraceback; | |
PyErr_Fetch( &ptype, &pvalue, &ptraceback ); | |
PyErr_Restore( ptype, pvalue, ptraceback ); | |
PyErr_Print(); | |
Py_Exit(1); | |
} | |
#endif | |
} | |
%feature("director:except") FIX::Application::toApp { | |
#ifdef SWIGPYTHON | |
if( $error != NULL ) { | |
PyObject *ptype, *pvalue, *ptraceback; | |
PyErr_Fetch( &ptype, &pvalue, &ptraceback ); | |
void *result; | |
try { | |
if( SWIG_ConvertPtr(pvalue, &result, SWIGTYPE_p_FIX__DoNotSend, 0 ) != -1 ) { | |
throw *((FIX::DoNotSend*)result); | |
} else { | |
PyErr_Restore( ptype, pvalue, ptraceback ); | |
PyErr_Print(); | |
Py_Exit(1); | |
} | |
} catch( std::exception& e ) { | |
std::cout << e.what() << std::endl; | |
Py_XDECREF( ptype ); | |
Py_XDECREF( pvalue ); | |
Py_XDECREF( ptraceback ); | |
throw; | |
} catch( ... ) { | |
std::cout << "Fatal exception" << std::endl; | |
Py_XDECREF( ptype ); | |
Py_XDECREF( pvalue ); | |
Py_XDECREF( ptraceback ); | |
throw; | |
} | |
} | |
#endif | |
} | |
%feature("director:except") FIX::Application::fromAdmin { | |
#ifdef SWIGPYTHON | |
if( $error != NULL ) { | |
PyObject *ptype, *pvalue, *ptraceback; | |
PyErr_Fetch( &ptype, &pvalue, &ptraceback ); | |
void *result; | |
try { | |
if( SWIG_ConvertPtr(pvalue, &result, SWIGTYPE_p_FIX__FieldNotFound, 0 ) != -1 ) { | |
throw *((FIX::FieldNotFound*)result); | |
} else if( SWIG_ConvertPtr(pvalue, &result, SWIGTYPE_p_FIX__IncorrectDataFormat, 0 ) != -1 ) { | |
throw *((FIX::IncorrectDataFormat*)result); | |
} else if( SWIG_ConvertPtr(pvalue, &result, SWIGTYPE_p_FIX__IncorrectTagValue, 0 ) != -1 ) { | |
throw *((FIX::IncorrectTagValue*)result); | |
} else if( SWIG_ConvertPtr(pvalue, &result, SWIGTYPE_p_FIX__RejectLogon, 0 ) != -1 ) { | |
throw *((FIX::RejectLogon*)result); | |
} else { | |
PyErr_Restore( ptype, pvalue, ptraceback ); | |
PyErr_Print(); | |
Py_Exit(1); | |
} | |
} catch( std::exception& e ) { | |
std::cout << e.what() << std::endl; | |
Py_XDECREF( ptype ); | |
Py_XDECREF( pvalue ); | |
Py_XDECREF( ptraceback ); | |
throw; | |
} catch( ... ) { | |
std::cout << "Fatal exception" << std::endl; | |
Py_XDECREF( ptype ); | |
Py_XDECREF( pvalue ); | |
Py_XDECREF( ptraceback ); | |
throw; | |
} | |
} | |
#endif | |
} | |
%feature("director:except") FIX::Application::fromApp { | |
#ifdef SWIGPYTHON | |
if( $error != NULL ) { | |
PyObject *ptype, *pvalue, *ptraceback; | |
PyErr_Fetch( &ptype, &pvalue, &ptraceback ); | |
void *result; | |
try { | |
if( SWIG_ConvertPtr(pvalue, &result, SWIGTYPE_p_FIX__FieldNotFound, 0 ) != -1 ) { | |
throw *((FIX::FieldNotFound*)result); | |
} else if( SWIG_ConvertPtr(pvalue, &result, SWIGTYPE_p_FIX__IncorrectDataFormat, 0 ) != -1 ) { | |
throw *((FIX::IncorrectDataFormat*)result); | |
} else if( SWIG_ConvertPtr(pvalue, &result, SWIGTYPE_p_FIX__IncorrectTagValue, 0 ) != -1 ) { | |
throw *((FIX::IncorrectTagValue*)result); | |
} else if( SWIG_ConvertPtr(pvalue, &result, SWIGTYPE_p_FIX__UnsupportedMessageType, 0 ) != -1 ) { | |
throw *((FIX::UnsupportedMessageType*)result); | |
} else { | |
PyErr_Restore( ptype, pvalue, ptraceback ); | |
PyErr_Print(); | |
Py_Exit(1); | |
} | |
} catch( std::exception& e ) { | |
std::cout << e.what() << std::endl; | |
Py_XDECREF( ptype ); | |
Py_XDECREF( pvalue ); | |
Py_XDECREF( ptraceback ); | |
throw; | |
} catch( ... ) { | |
std::cout << "Fatal exception" << std::endl; | |
Py_XDECREF( ptype ); | |
Py_XDECREF( pvalue ); | |
Py_XDECREF( ptraceback ); | |
throw; | |
} | |
} | |
#endif | |
} | |
%include <Exceptions.h> | |
%include <Field.h> | |
%include <FieldMap.h> | |
%include <Message.h> | |
%include <Group.h> | |
%include <Fields.h> | |
%include <FixFields.h> | |
%include <Values.h> | |
%include <FixValues.h> | |
%include <SessionID.h> | |
%include <Dictionary.h> | |
%include <SessionSettings.h> | |
%include <Session.h> | |
%include <SessionID.h> | |
%include <Log.h> | |
%include <FileLog.h> | |
%include <MessageStore.h> | |
%include <FileStore.h> | |
%include <Application.h> | |
%include <Initiator.h> | |
%include <SocketInitiator.h> | |
%include <Acceptor.h> | |
%include <SocketAcceptor.h> | |
%include <DataDictionary.h> | |
%pythoncode %{ | |
#ifdef SWIGPYTHON | |
class SocketInitiator(SocketInitiatorBase): | |
application = 0 | |
storeFactory = 0 | |
setting = 0 | |
logFactory = 0 | |
def __init__(self, application, storeFactory, settings, logFactory=None): | |
if logFactory == None: | |
SocketInitiatorBase.__init__(self, application, storeFactory, settings) | |
else: | |
SocketInitiatorBase.__init__(self, application, storeFactory, settings, logFactory) | |
self.application = application | |
self.storeFactory = storeFactory | |
self.settings = settings | |
self.logFactory = logFactory | |
class SocketAcceptor(SocketAcceptorBase): | |
application = 0 | |
storeFactory = 0 | |
setting = 0 | |
logFactory = 0 | |
def __init__(self, application, storeFactory, settings, logFactory=None): | |
if logFactory == None: | |
SocketAcceptorBase.__init__(self, application, storeFactory, settings) | |
else: | |
SocketAcceptorBase.__init__(self, application, storeFactory, settings, logFactory) | |
self.application = application | |
self.storeFactory = storeFactory | |
self.settings = settings | |
self.logFactory = logFactory | |
#endif | |
%} | |
%init %{ | |
#ifndef _MSC_VER | |
struct sigaction new_action, old_action; | |
new_action.sa_handler = SIG_DFL; | |
sigemptyset( &new_action.sa_mask ); | |
new_action.sa_flags = 0; | |
sigaction( SIGINT, &new_action, &old_action ); | |
#endif | |
%} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment