BoB robotics
The Brains on Board robotics library
pybind11::detail::object_api< Derived > Class Template Reference

#include <pytypes.h>

Inheritance diagram for pybind11::detail::object_api< Derived >:
pybind11::detail::pyobject_tag

Public Member Functions

iterator begin () const
 
iterator end () const
 Return a sentinel which ends iteration.
 
item_accessor operator[] (handle key) const
 
item_accessor operator[] (const char *key) const
 See above (the only difference is that they key is provided as a string literal)
 
obj_attr_accessor attr (handle key) const
 
str_attr_accessor attr (const char *key) const
 See above (the only difference is that they key is provided as a string literal)
 
args_proxy operator* () const
 
template<typename T >
bool contains (T &&item) const
 Check if the given item is contained within this object, i.e. item in obj.
 
template<return_value_policy policy = return_value_policy::automatic_reference, typename... Args>
object operator() (Args &&...args) const
 
template<return_value_policy policy = return_value_policy::automatic_reference, typename... Args>
 __attribute__ ((deprecated("call(...) was deprecated in favor of operator()(...)"))) object call(Args &&... args) const
 
bool is (object_api const &other) const
 Equivalent to obj is other in Python.
 
bool is_none () const
 Equivalent to obj is None in Python.
 
bool equal (object_api const &other) const
 Equivalent to obj == other in Python.
 
bool not_equal (object_api const &other) const
 
bool operator< (object_api const &other) const
 
bool operator<= (object_api const &other) const
 
bool operator> (object_api const &other) const
 
bool operator>= (object_api const &other) const
 
object operator- () const
 
object operator~ () const
 
object operator+ (object_api const &other) const
 
object operator+= (object_api const &other) const
 
object operator- (object_api const &other) const
 
object operator-= (object_api const &other) const
 
object operator* (object_api const &other) const
 
object operator*= (object_api const &other) const
 
object operator/ (object_api const &other) const
 
object operator/= (object_api const &other) const
 
object operator| (object_api const &other) const
 
object operator|= (object_api const &other) const
 
object operator& (object_api const &other) const
 
object operator&= (object_api const &other) const
 
object operator^ (object_api const &other) const
 
object operator^= (object_api const &other) const
 
object operator<< (object_api const &other) const
 
object operator<<= (object_api const &other) const
 
object operator>> (object_api const &other) const
 
object operator>>= (object_api const &other) const
 
__attribute__((deprecated("Use py::str(obj) instead"))) pybind11 str_attr_accessor doc () const
 Get or set the object's docstring, i.e. obj.__doc__.
 
int ref_count () const
 Return the object's current reference count.
 
handle get_type () const
 

Detailed Description

template<typename Derived>
class pybind11::detail::object_api< Derived >

\rst A mixin class which adds common functions to handle, object and various accessors. The only requirement for Derived is to implement PyObject *Derived::ptr() const. \endrst

Member Function Documentation

◆ attr()

template<typename D >
obj_attr_accessor pybind11::detail::object_api< D >::attr ( handle  key) const

\rst Return an internal functor to access the object's attributes. Casting the returned detail::obj_attr_accessor instance to a handle or object subclass causes a corresponding call to getattr. Assigning a handle or object subclass causes a call to setattr. \endrst

◆ begin()

template<typename D >
iterator pybind11::detail::object_api< D >::begin

\rst Return an iterator equivalent to calling iter() in Python. The object must be a collection which supports the iteration protocol. \endrst

◆ operator()()

template<typename Derived >
template<return_value_policy policy, typename... Args>
object pybind11::detail::object_api< Derived >::operator() ( Args &&...  args) const

\rst Assuming the Python object is a function or implements the __call__ protocol, operator() invokes the underlying function, passing an arbitrary set of parameters. The result is returned as a object and may need to be converted back into a Python object using handle::cast().

When some of the arguments cannot be converted to Python objects, the function will throw a cast_error exception. When the Python function call fails, a error_already_set exception is thrown. \endrst

◆ operator*()

template<typename D >
args_proxy pybind11::detail::object_api< D >::operator*

\rst Matches * unpacking in Python, e.g. to unpack arguments out of a tuple or list for a function call. Applying another * to the result yields unpacking, e.g. to unpack a dict as function keyword arguments. See :ref:calling_python_functions. \endrst

◆ operator[]()

template<typename D >
item_accessor pybind11::detail::object_api< D >::operator[] ( handle  key) const

\rst Return an internal functor to invoke the object's sequence protocol. Casting the returned detail::item_accessor instance to a handle or object subclass causes a corresponding call to __getitem__. Assigning a handle or object subclass causes a call to __setitem__. \endrst


The documentation for this class was generated from the following files: