Fork me on GitHub
Library for MQL5 (MetaTrader) with support for Spark
CPythonDLL Class Reference

Detailed Description

Class for PythonDLL.dll.


The documentation for this class was generated from the following file:

Public Member Functions

 CPythonDLL ()
 
bool initialize (const string python_home, const bool console=false)
 
bool isInitialized ()
 Check the active environment of Python. More...
 
void finalize ()
 It is not necessary to use this function, because it is always called when a test is completed or MetaTrader is closed. More...
 
bool eval (const string pycode, const bool override_class=false)
 Compiling and executing code. More...
 
bool isError (const bool clear=true)
 Checks for errors. More...
 
string getErrorText ()
 Checks for errors, gets text and clears the error. More...
 
int getLong (const long magic, const long value, const long &inputs[], long &outputs[], const int inputs_size=WHOLE_ARRAY, const int outputs_size=WHOLE_ARRAY)
 Calls the mql.getLong() function with the data passed. More...
 
int getULong (const long magic, const ulong value, const ulong &inputs[], ulong &outputs[], const int inputs_size=WHOLE_ARRAY, const int outputs_size=WHOLE_ARRAY)
 Calls the mql.getULong() function with the data passed. More...
 
int getDouble (const long magic, const double value, const double &inputs[], double &outputs[], const int inputs_size=WHOLE_ARRAY, const int outputs_size=WHOLE_ARRAY)
 Calls the mql.getDouble() function with the data passed. More...
 
string getString (const long magic, const string value, const uchar &inputs[], const int inputs_size=WHOLE_ARRAY)
 Calls the mql.getString() function with the data passed. More...
 
int getString (const long magic, const string value, const uchar &inputs[], string &buffer, const int inputs_size=WHOLE_ARRAY, const int stringBufferLen=WHOLE_ARRAY)
 Calls the mql.getString() function with the data passed. More...
 

Protected Attributes

string bufstr
 

Constructor & Destructor Documentation

◆ CPythonDLL()

CPythonDLL::CPythonDLL ( )

Member Function Documentation

◆ eval()

bool CPythonDLL::eval ( const string  pycode,
const bool  override_class = false 
)

Compiling and executing code.

Parameters
[in]pycode
[in]override_classwhen changing the variable mql, set to true.
Returns
error status.

◆ finalize()

void CPythonDLL::finalize ( )

It is not necessary to use this function, because it is always called when a test is completed or MetaTrader is closed.

◆ getDouble()

int CPythonDLL::getDouble ( const long  magic,
const double  value,
const double &  inputs[],
double &  outputs[],
const int  inputs_size = WHOLE_ARRAY,
const int  outputs_size = WHOLE_ARRAY 
)

Calls the mql.getDouble() function with the data passed.

The error is automatically displayed in the log.

Parameters
[in]magic
[in]value
[in]inputs
[out]outputsarray size will not change.
[in]inputs_size
[in]outputs_size
Returns
the size of the array returned from Python or -1 on a runtime error.

◆ getErrorText()

string CPythonDLL::getErrorText ( )

Checks for errors, gets text and clears the error.

◆ getLong()

int CPythonDLL::getLong ( const long  magic,
const long  value,
const long &  inputs[],
long &  outputs[],
const int  inputs_size = WHOLE_ARRAY,
const int  outputs_size = WHOLE_ARRAY 
)

Calls the mql.getLong() function with the data passed.

The error is automatically displayed in the log.

Parameters
[in]magic
[in]value
[in]inputs
[out]outputsarray size will not change.
[in]inputs_size
[in]outputs_size
Returns
the size of the array returned from Python or -1 on a runtime error.

◆ getString() [1/2]

string CPythonDLL::getString ( const long  magic,
const string  value,
const uchar &  inputs[],
const int  inputs_size = WHOLE_ARRAY 
)

Calls the mql.getString() function with the data passed.

The error is automatically displayed in the log.

Parameters
[in]magic
[in]value
[in]inputs
[in]inputs_size
Returns
the string returned from Python or "" on a runtime error.

◆ getString() [2/2]

int CPythonDLL::getString ( const long  magic,
const string  value,
const uchar &  inputs[],
string &  buffer,
const int  inputs_size = WHOLE_ARRAY,
const int  stringBufferLen = WHOLE_ARRAY 
)

Calls the mql.getString() function with the data passed.

The error is automatically displayed in the log.

Parameters
[in]magic
[in]value
[in]inputs
[out]buffer
[in]inputs_size
[in]stringBufferLenuse StringBufferLen(buffer)
Returns
the size of the array returned from Python or -1 on a runtime error.

◆ getULong()

int CPythonDLL::getULong ( const long  magic,
const ulong  value,
const ulong &  inputs[],
ulong &  outputs[],
const int  inputs_size = WHOLE_ARRAY,
const int  outputs_size = WHOLE_ARRAY 
)

Calls the mql.getULong() function with the data passed.

The error is automatically displayed in the log.

Parameters
[in]magic
[in]value
[in]inputs
[out]outputsarray size will not change.
[in]inputs_size
[in]outputs_size
Returns
the size of the array returned from Python or -1 on a runtime error.

◆ initialize()

bool CPythonDLL::initialize ( const string  python_home,
const bool  console = false 
)
  Attempt to create a Python environment.

  * If python_home is set incorrectly, the terminal will be destroyed.

  @param[in] python_home path to the environment of Python.
  @param[in] console show console window.
  @return Py_NewInterpreter() != NULL

◆ isError()

bool CPythonDLL::isError ( const bool  clear = true)

Checks for errors.

To get an error message, use getErrorText().

Parameters
[in]clearclears the error.
Returns
error status.

◆ isInitialized()

bool CPythonDLL::isInitialized ( )

Check the active environment of Python.

Returns
status.

Member Data Documentation

◆ bufstr

string CPythonDLL::bufstr
protected