Loading...
Searching...
No Matches
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.
static void | construct (PyObject *obj_ptr, boost::python::converter::rvalue_from_python_stage1_data *data)
| Constructs a C++ container from a Python sequence.
static ContainerType | make_container (PyObject *obj_ptr)
| Constructs a C++ container from a Python sequence.

## 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 412 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 414 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

Definition at line 416 of file PycBasicData.h.

References construct(), and convertible().

## Member Function Documentation

## check_convertibility()

template<typename ContainerType, typename ConversionPolicy>

bool casacore::python::from_python_sequence< ContainerType, ConversionPolicy >::check_convertibility | ( | PyObject * | obj_ptr | ) |

inline static private

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

Definition at line 538 of file PycBasicData.h.

Referenced by convertible().

## construct()

template<typename ContainerType, typename ConversionPolicy>

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

inline static

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 474 of file PycBasicData.h.

References fill_container(), casacore::python::getSeqObject(), casacore::python::PycArrayScalarCheck(), and casacore::storage().

Referenced by from_python_sequence().

## convertible()

template<typename ContainerType, typename ConversionPolicy>

void * casacore::python::from_python_sequence< ContainerType, ConversionPolicy >::convertible | ( | PyObject * | obj_ptr | ) |

inline static

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 426 of file PycBasicData.h.

References check_convertibility(), casacore::python::getSeqObject(), and casacore::python::PycArrayScalarCheck().

Referenced by from_python_sequence().

## fill_container()

template<typename ContainerType, typename ConversionPolicy>

void casacore::python::from_python_sequence< ContainerType, ConversionPolicy >::fill_container | ( | ContainerType & | result,
|  | PyObject * | obj_ptr )

inline static private

Definition at line 520 of file PycBasicData.h.

Referenced by construct(), and make_container().

## make_container()

template<typename ContainerType, typename ConversionPolicy>

ContainerType casacore::python::from_python_sequence< ContainerType, ConversionPolicy >::make_container | ( | PyObject * | obj_ptr | ) |

inline static

Constructs a C++ container from a Python sequence.

Definition at line 512 of file PycBasicData.h.

References fill_container().

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

- python/Converters/PycBasicData.h