casacore
Public Types | Public Member Functions | Static Public Member Functions | Static Private Member Functions | List of all members
casacore::python::from_python_sequence< ContainerType, ConversionPolicy > Struct Template Reference

Conversion of Python sequence to C++ container. More...

#include <PycBasicData.h>

Public Types

typedef ContainerType::value_type container_element_type
 

Public Member Functions

 from_python_sequence ()
 

Static Public Member Functions

static void * convertible (PyObject *obj_ptr)
 Appears to return obj_ptr if it is type of Python sequence that can be convertible to C++ container. More...
 
static void construct (PyObject *obj_ptr, boost::python::converter::rvalue_from_python_stage1_data *data)
 Constructs a C++ container from a Python sequence. More...
 
static ContainerType make_container (PyObject *obj_ptr)
 Constructs a C++ container from a Python sequence. More...
 

Static Private Member Functions

static void fill_container (ContainerType &result, PyObject *obj_ptr)
 
static bool check_convertibility (PyObject *obj_ptr)
 

Detailed Description

template<typename ContainerType, typename ConversionPolicy>
struct casacore::python::from_python_sequence< ContainerType, ConversionPolicy >

Conversion of Python sequence to C++ container.

Copied from scitbx/include/scitbx/boost_python/container_conversions.h that is described in the Boost.Python FAQ.

Author
Ralf W. Grosse-Kunstleve rwgk@.nosp@m.yaho.nosp@m.o.com of Lawrence Berkeley National Laboratory

Definition at line 414 of file PycBasicData.h.

Member Typedef Documentation

◆ container_element_type

template<typename ContainerType , typename ConversionPolicy >
typedef ContainerType::value_type casacore::python::from_python_sequence< ContainerType, ConversionPolicy >::container_element_type

Definition at line 416 of file PycBasicData.h.

Constructor & Destructor Documentation

◆ from_python_sequence()

template<typename ContainerType , typename ConversionPolicy >
casacore::python::from_python_sequence< ContainerType, ConversionPolicy >::from_python_sequence ( )
inline

Member Function Documentation

◆ check_convertibility()

template<typename ContainerType , typename ConversionPolicy >
static bool casacore::python::from_python_sequence< ContainerType, ConversionPolicy >::check_convertibility ( PyObject *  obj_ptr)
inlinestaticprivate

All elements in a range and array have the same type, so need to check the first element only.

Definition at line 540 of file PycBasicData.h.

Referenced by casacore::python::from_python_sequence< ContainerType, ConversionPolicy >::convertible().

◆ construct()

template<typename ContainerType , typename ConversionPolicy >
static void casacore::python::from_python_sequence< ContainerType, ConversionPolicy >::construct ( PyObject *  obj_ptr,
boost::python::converter::rvalue_from_python_stage1_data *  data 
)
inlinestatic

Constructs a C++ container from a Python sequence.

ConversionPolicy::reserve(result, 1); ConversionPolicy::set_value(result, 0, extract<container_element_type>(py_flat.attr("__getitem__")(0)));

Definition at line 476 of file PycBasicData.h.

References casacore::python::from_python_sequence< ContainerType, ConversionPolicy >::fill_container(), casacore::python::getSeqObject(), and casacore::python::PycArrayScalarCheck().

Referenced by casacore::python::from_python_sequence< ContainerType, ConversionPolicy >::from_python_sequence().

◆ convertible()

template<typename ContainerType , typename ConversionPolicy >
static void* casacore::python::from_python_sequence< ContainerType, ConversionPolicy >::convertible ( PyObject *  obj_ptr)
inlinestatic

Appears to return obj_ptr if it is type of Python sequence that can be convertible to C++ container.

Accept single values.

An array scalar is accepted.

Get the sequence object. It can be a numarray/numpy scalar in which case it fills py_obj with a flattened array.

Check the sequence. It must be convertible to an iterator.

Definition at line 428 of file PycBasicData.h.

References casacore::python::from_python_sequence< ContainerType, ConversionPolicy >::check_convertibility(), casacore::python::getSeqObject(), and casacore::python::PycArrayScalarCheck().

Referenced by casacore::python::from_python_sequence< ContainerType, ConversionPolicy >::from_python_sequence().

◆ fill_container()

template<typename ContainerType , typename ConversionPolicy >
static void casacore::python::from_python_sequence< ContainerType, ConversionPolicy >::fill_container ( ContainerType &  result,
PyObject *  obj_ptr 
)
inlinestaticprivate

◆ make_container()

template<typename ContainerType , typename ConversionPolicy >
static ContainerType casacore::python::from_python_sequence< ContainerType, ConversionPolicy >::make_container ( PyObject *  obj_ptr)
inlinestatic

Constructs a C++ container from a Python sequence.

Definition at line 514 of file PycBasicData.h.

References casacore::python::from_python_sequence< ContainerType, ConversionPolicy >::fill_container().


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