Mantid
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
Mantid::PythonInterface::Converters::PySequenceToVector< DestElementType > Struct Template Reference

Converts a Python sequence type to a C++ std::vector, where the element type is defined by the template type. More...

#include <PySequenceToVector.h>

Public Types

using TypedVector = std::vector< DestElementType >
 

Public Member Functions

void copyTo (TypedVector &dest)
 Fill the container with data from the array. More...
 
TypedVector operator() ()
 Converts the Python object to a C++ vector. More...
 
 PySequenceToVector (const boost::python::object &value)
 

Private Member Functions

PyObject * ptr () const
 
std::size_t srcSize () const
 
void throwIfSizeMismatched (const TypedVector &dest) const
 

Private Attributes

boost::python::object m_obj
 Python object to convert. More...
 

Detailed Description

template<typename DestElementType>
struct Mantid::PythonInterface::Converters::PySequenceToVector< DestElementType >

Converts a Python sequence type to a C++ std::vector, where the element type is defined by the template type.

Definition at line 49 of file PySequenceToVector.h.

Member Typedef Documentation

◆ TypedVector

template<typename DestElementType >
using Mantid::PythonInterface::Converters::PySequenceToVector< DestElementType >::TypedVector = std::vector<DestElementType>

Definition at line 51 of file PySequenceToVector.h.

Constructor & Destructor Documentation

◆ PySequenceToVector()

template<typename DestElementType >
Mantid::PythonInterface::Converters::PySequenceToVector< DestElementType >::PySequenceToVector ( const boost::python::object &  value)
inline

Definition at line 53 of file PySequenceToVector.h.

Member Function Documentation

◆ copyTo()

template<typename DestElementType >
void Mantid::PythonInterface::Converters::PySequenceToVector< DestElementType >::copyTo ( TypedVector dest)
inline

Fill the container with data from the array.

Parameters
destA vector<DestElementType> that receives the data

Definition at line 70 of file PySequenceToVector.h.

◆ operator()()

template<typename DestElementType >
TypedVector Mantid::PythonInterface::Converters::PySequenceToVector< DestElementType >::operator() ( )
inline

Converts the Python object to a C++ vector.

Returns
A std::vector<ElementType> containing the values from the Python sequence

Definition at line 60 of file PySequenceToVector.h.

◆ ptr()

template<typename DestElementType >
PyObject * Mantid::PythonInterface::Converters::PySequenceToVector< DestElementType >::ptr ( ) const
inlineprivate

Definition at line 80 of file PySequenceToVector.h.

◆ srcSize()

template<typename DestElementType >
std::size_t Mantid::PythonInterface::Converters::PySequenceToVector< DestElementType >::srcSize ( ) const
inlineprivate

Definition at line 82 of file PySequenceToVector.h.

◆ throwIfSizeMismatched()

template<typename DestElementType >
void Mantid::PythonInterface::Converters::PySequenceToVector< DestElementType >::throwIfSizeMismatched ( const TypedVector dest) const
inlineprivate

Definition at line 84 of file PySequenceToVector.h.

References std::to_string().

Member Data Documentation

◆ m_obj

template<typename DestElementType >
boost::python::object Mantid::PythonInterface::Converters::PySequenceToVector< DestElementType >::m_obj
private

Python object to convert.

Definition at line 92 of file PySequenceToVector.h.


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