Scarab  v2.11.1
Project 8 C++ Utility Library
Public Member Functions | Private Member Functions | List of all members
object_api< Derived > Class Template Reference

#include <pytypes.h>

Inheritance diagram for object_api< Derived >:
Inheritance graph

Public Member Functions

iterator begin () const
 
iterator end () const
 Return a sentinel which ends iteration. More...
 
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) More...
 
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) More...
 
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. More...
 
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
 Get or set the object's docstring, i.e. obj.__doc__. More...
 
bool is (object_api const &other) const
 Equivalent to obj is other in Python. More...
 
bool is_none () const
 Equivalent to obj is None in Python. More...
 
bool equal (object_api const &other) const
 Equivalent to obj == other in Python. More...
 
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
 
int ref_count () const
 Return the object's current reference count. More...
 
handle get_type () const
 Return a handle to the Python type object underlying the instance. More...
 

Private Member Functions

const Derived & derived () const
 
bool rich_compare (object_api const &other, int value) const
 

Detailed Description

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

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.

Definition at line 54 of file pytypes.h.

Member Function Documentation

◆ __attribute__()

__attribute__ ( (deprecated("call(...) was deprecated in favor of operator()(...)"))  ) const &&

Get or set the object's docstring, i.e. obj.__doc__.

◆ attr() [1/2]

obj_attr_accessor attr ( handle  key) const

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.

Definition at line 1410 of file pytypes.h.

◆ attr() [2/2]

str_attr_accessor attr ( const char *  key) const

See above (the only difference is that they key is provided as a string literal)

Definition at line 1413 of file pytypes.h.

◆ begin()

iterator begin ( ) const

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

Definition at line 1402 of file pytypes.h.

◆ contains()

bool contains ( T &&  item) const

Check if the given item is contained within this object, i.e. item in obj.

Definition at line 1419 of file pytypes.h.

◆ derived()

const Derived& derived ( ) const
inlineprivate

Definition at line 55 of file pytypes.h.

◆ end()

iterator end ( ) const

Return a sentinel which ends iteration.

Definition at line 1403 of file pytypes.h.

◆ equal()

bool equal ( object_api< Derived > const &  other) const
inline

Equivalent to obj == other in Python.

Definition at line 118 of file pytypes.h.

◆ get_type()

handle get_type ( ) const

Return a handle to the Python type object underlying the instance.

Definition at line 1430 of file pytypes.h.

◆ is()

bool is ( object_api< Derived > const &  other) const
inline

Equivalent to obj is other in Python.

Definition at line 114 of file pytypes.h.

◆ is_none()

bool is_none ( ) const
inline

Equivalent to obj is None in Python.

Definition at line 116 of file pytypes.h.

◆ not_equal()

bool not_equal ( object_api< Derived > const &  other) const
inline

Definition at line 119 of file pytypes.h.

◆ operator &()

object operator& ( object_api< Derived > const &  other) const

◆ operator &=()

object operator&= ( object_api< Derived > const &  other) const

◆ operator()()

object operator() ( Args &&...  args) const

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.

Definition at line 2109 of file cast.h.

◆ operator*() [1/2]

args_proxy operator* ( ) const

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.

Definition at line 1416 of file pytypes.h.

◆ operator*() [2/2]

object operator* ( object_api< Derived > const &  other) const

Definition at line 1464 of file pytypes.h.

◆ operator*=()

object operator*= ( object_api< Derived > const &  other) const

Definition at line 1465 of file pytypes.h.

◆ operator+()

object operator+ ( object_api< Derived > const &  other) const

Definition at line 1460 of file pytypes.h.

◆ operator+=()

object operator+= ( object_api< Derived > const &  other) const

Definition at line 1461 of file pytypes.h.

◆ operator-() [1/2]

object operator- ( ) const

Definition at line 1459 of file pytypes.h.

◆ operator-() [2/2]

object operator- ( object_api< Derived > const &  other) const

Definition at line 1462 of file pytypes.h.

◆ operator-=()

object operator-= ( object_api< Derived > const &  other) const

Definition at line 1463 of file pytypes.h.

◆ operator/()

object operator/ ( object_api< Derived > const &  other) const

Definition at line 1466 of file pytypes.h.

◆ operator/=()

object operator/= ( object_api< Derived > const &  other) const

Definition at line 1467 of file pytypes.h.

◆ operator<()

bool operator< ( object_api< Derived > const &  other) const
inline

Definition at line 120 of file pytypes.h.

◆ operator<<()

object operator<< ( object_api< Derived > const &  other) const

Definition at line 1474 of file pytypes.h.

◆ operator<<=()

object operator<<= ( object_api< Derived > const &  other) const

Definition at line 1475 of file pytypes.h.

◆ operator<=()

bool operator<= ( object_api< Derived > const &  other) const
inline

Definition at line 121 of file pytypes.h.

◆ operator>()

bool operator> ( object_api< Derived > const &  other) const
inline

Definition at line 122 of file pytypes.h.

◆ operator>=()

bool operator>= ( object_api< Derived > const &  other) const
inline

Definition at line 123 of file pytypes.h.

◆ operator>>()

object operator>> ( object_api< Derived > const &  other) const

Definition at line 1476 of file pytypes.h.

◆ operator>>=()

object operator>>= ( object_api< Derived > const &  other) const

Definition at line 1477 of file pytypes.h.

◆ operator[]() [1/2]

item_accessor operator[] ( handle  key) const

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__.

Definition at line 1404 of file pytypes.h.

◆ operator[]() [2/2]

item_accessor operator[] ( const char *  key) const

See above (the only difference is that they key is provided as a string literal)

Definition at line 1407 of file pytypes.h.

◆ operator^()

object operator^ ( object_api< Derived > const &  other) const

Definition at line 1472 of file pytypes.h.

◆ operator^=()

object operator^= ( object_api< Derived > const &  other) const

Definition at line 1473 of file pytypes.h.

◆ operator|()

object operator| ( object_api< Derived > const &  other) const

Definition at line 1468 of file pytypes.h.

◆ operator|=()

object operator|= ( object_api< Derived > const &  other) const

Definition at line 1469 of file pytypes.h.

◆ operator~()

object operator~ ( ) const

Definition at line 1458 of file pytypes.h.

◆ ref_count()

int ref_count ( ) const
inline

Return the object's current reference count.

Definition at line 153 of file pytypes.h.

◆ rich_compare()

bool rich_compare ( object_api< Derived > const &  other,
int  value 
) const
private

Definition at line 1433 of file pytypes.h.


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