This class handles two-way translation between the data types in C++ and Python. More...
#include <utils.h>
Public Member Functions | |
bool | check (const MetaClass *c) const |
bool | check (const PythonType &c) const |
bool | getBool () const |
Date | getDate () const |
double | getDouble () const |
int | getInt () const |
long | getLong () const |
string | getString () const |
TimePeriod | getTimeperiod () const |
unsigned long | getUnsignedLong () const |
operator bool () const | |
operator PyObject * () const | |
PythonObject & | operator= (const PythonObject &o) |
PythonObject () | |
PythonObject (const PyObject *o) | |
PythonObject (Object *p) | |
PythonObject (const string &val) | |
PythonObject (const double val) | |
PythonObject (const int val) | |
PythonObject (const long val) | |
PythonObject (const unsigned long val) | |
PythonObject (const bool val) | |
PythonObject (const TimePeriod val) | |
PythonObject (const Date &val) | |
![]() | |
void | operator>> (unsigned long int &val) const |
void | operator>> (long &val) const |
void | operator>> (TimePeriod &val) const |
void | operator>> (bool &v) const |
void | operator>> (int &val) const |
void | operator>> (double &val) const |
void | operator>> (Date &val) const |
void | operator>> (string &val) const |
virtual | ~DataElement () |
This class handles two-way translation between the data types in C++ and Python.
This class is basically a wrapper around a PyObject pointer.
When creating a PythonObject from a C++ object, make sure to increment the reference count of the object.
When constructing a PythonObject from an existing Python object, the code that provided us the PyObject pointer should have incremented the reference count already.
|
inlineexplicit |
|
inline |
frepple::utils::PythonObject::PythonObject | ( | Object * | p | ) |
Constructor from a pointer to an Object.
The metadata of the Object instances allow us to create a Python object that works as a proxy for the C++ object.
Definition at line 456 of file pythonutils.cpp.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Convert a frePPLe TimePeriod into a Python number representing the number of seconds.
frepple::utils::PythonObject::PythonObject | ( | const Date & | val | ) |
Convert a frePPLe date into a Python datetime.datetime object.
Definition at line 391 of file pythonutils.cpp.
|
inline |
|
inline |
|
inlinevirtual |
Convert a Python number into a C++ bool.
Reimplemented from frepple::utils::DataElement.
|
virtual |
Convert a Python datetime.date or datetime.datetime object into a frePPLe date.
Reimplemented from frepple::utils::DataElement.
Definition at line 413 of file pythonutils.cpp.
|
inlinevirtual |
Convert a Python number or string into a C++ double.
Reimplemented from frepple::utils::DataElement.
|
inlinevirtual |
Convert a Python number or string into a C++ integer.
Reimplemented from frepple::utils::DataElement.
|
inlinevirtual |
Convert a Python number into a C++ long.
Reimplemented from frepple::utils::DataElement.
|
inlinevirtual |
Convert a Python string into a C++ string.
Reimplemented from frepple::utils::DataElement.
|
inlinevirtual |
Convert a Python number as a number of seconds into a frePPLe TimePeriod.
A TimePeriod is represented as a number of seconds in Python.
Reimplemented from frepple::utils::DataElement.
|
inlinevirtual |
Extract an unsigned long from the Python object.
Reimplemented from frepple::utils::DataElement.
|
inlinevirtual |
Check for null value.
Reimplemented from frepple::utils::DataElement.
Reimplemented in frepple::utils::PythonFunction.
|
inline |
|
inline |