A traits class providing Python conversion functions for Vector.
More...
#include <Vector.h>
|
static PyObject * | toPython (Vector< T, N > const &input) |
| Convert a Vector to a new Python object. More...
|
|
static PyTypeObject const * | getPyType () |
| Return the Python TypeObject that corresponds to the object the toPython() function returns. More...
|
|
static bool | fromPythonStage1 (PyPtr &p) |
| Check if a Python object is convertible to T and optionally begin the conversion by replacing the input with an intermediate. More...
|
|
static bool | fromPythonStage2 (PyPtr const &p, Vector< T, N > &output) |
| Complete a Python to C++ conversion begun with fromPythonStage1(). More...
|
|
static bool | matches (PyObject *arg) |
| Check if a Python object might be convertible to T. More...
|
|
static int | fromPython (PyObject *arg, Vector< T, N > *output) |
| Convert a Python object to a C++ object. More...
|
|
template<typename T, int N>
struct ndarray::PyConverter< Vector< T, N > >
A traits class providing Python conversion functions for Vector.
Definition at line 41 of file Vector.h.
template<typename T , int N>
Check if a Python object is convertible to T and optionally begin the conversion by replacing the input with an intermediate.
- Returns
- true if a conversion may be possible, and false if it is not (with a Python exception set).
- Parameters
-
p | On input, a Python object to be converted. On output, a Python object to be passed to fromPythonStage2(). |
Definition at line 73 of file Vector.h.
79 if (!PySequence_Check(p.get())) {
80 PyErr_Format(PyExc_TypeError,
"Expected a Python sequence of length %i.",N);
83 if (PySequence_Size(p.get()) != N) {
84 PyErr_Format(PyExc_ValueError,
"Incorrect sequence length for Vector<T,%i>", N);
template<typename T , int N>
Complete a Python to C++ conversion begun with fromPythonStage1().
- Returns
- true if the conversion was successful, and false otherwise (with a Python exception set).
- Parameters
-
p | A Python object processed by fromPythonStage1(). |
output | The output C++ object. |
Definition at line 97 of file Vector.h.
104 for (
int n=0; n<N; ++n) {
105 PyPtr item(PySequence_ITEM(p.get(),n),
false);
106 if (!item)
return false;
107 if (!PyConverter<T>::fromPythonStage1(item))
return false;
108 if (!PyConverter<T>::fromPythonStage2(item,tmp[n]))
return false;
boost::intrusive_ptr< PyObject > PyPtr
A reference-counting smart pointer for PyObject.
#define NDARRAY_ASSERT(ARG)
template<typename T , int N>
Return the Python TypeObject that corresponds to the object the toPython() function returns.
Definition at line 63 of file Vector.h.
63 {
return &PyTuple_Type; }
template<typename T , int N>
Convert a Vector to a new Python object.
- Returns
- A new Python object, or NULL on failure (with a Python exception set).
- Parameters
-
Definition at line 49 of file Vector.h.
52 PyObject * r = PyTuple_New(N);
53 for (
int i=0; i<N; ++i) {
54 PyTuple_SET_ITEM(r,i,PyConverter<T>::toPython(input[i]));
The documentation for this struct was generated from the following file:
- /home/lsstsw/stack/Linux64/ndarray/10.1+37/include/ndarray/swig/Vector.h