Michele De Stefano's C++ Utilities
|
Adds support for random get/set access operator (i.e. square brackets) to a class that has to be exposed to the Python interpreter. The access is both in read and write mode. More...
#include <mds_utils/python/container_operators.hpp>
Public Member Functions | |
void | py_set_item (const Obj &idx, const Obj &val) |
Manages container write access through Python indices and slices. More... | |
Public Member Functions inherited from mds_utils::python::support_random_access< Derived > | |
Obj | py_get_item (const Obj &idx) |
Manages container read access through Python indices and slices. More... | |
Adds support for random get/set access operator (i.e. square brackets) to a class that has to be exposed to the Python interpreter. The access is both in read and write mode.
Using the Curiously Recurring Template Pattern (CRTP), enables the square brackets operator. Further to the requirements of the support_random_access class, the derived class must support these typedefs and methods:
value_type
: the type of the elements contained by the container.void set_el_at(size_type i,typename Derived::value_type val)
: this must set the value val
at position i
.Inheriting from this class will add the support_random_getset_access::py_get_item and support_random_getset_access::py_set_item methods to the derived class. These methods are intended to be exported as the __getitem__
and the __setitem__
Python methods respectively.
Definition at line 144 of file container_operators.hpp.
|
inline |
Manages container write access through Python indices and slices.
It is intended to be exposed/used as the __setitem__
method.
idx | A Python object which can be a numeric index or a numeric slice. |
val | The value (or sequence of values) to be set at position (or positions) idx. |
Definition at line 158 of file container_operators.hpp.