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
[legend]

Public Member Functions

obj_attr_accessor attr (handle key) const
 
obj_attr_accessor attr (object &&key) const
 See above (the only difference is that the key's reference is stolen) More...
 
str_attr_accessor attr (const char *key) const
 See above (the only difference is that the key is provided as a string literal) More...
 
iterator begin () 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...
 
str_attr_accessor doc () const
 Get or set the object's docstring, i.e. obj.__doc__. More...
 
iterator end () const
 Return a sentinel which ends iteration. More...
 
bool equal (object_api const &other) const
 Equivalent to obj == other in Python. More...
 
handle get_type () const
 
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 not_equal (object_api const &other) const
 
object operator & (object_api const &other) const
 
object operator &= (object_api const &other) const
 
template<return_value_policy policy = return_value_policy::automatic_reference, typename... Args>
object operator() (Args &&...args) const
 
args_proxy 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- () 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
 
bool operator< (object_api const &other) const
 
object operator<< (object_api const &other) const
 
object 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>> (object_api const &other) const
 
object operator>>= (object_api const &other) const
 
item_accessor operator[] (handle key) const
 
item_accessor operator[] (object &&key) const
 See above (the only difference is that the key's reference is stolen) More...
 
item_accessor operator[] (const char *key) const
 See above (the only difference is that the key is provided as a string literal) More...
 
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~ () const
 
template<return_value_policy policy = return_value_policy::automatic_reference, typename... Args>
 PYBIND11_DEPRECATED ("call(...) was deprecated in favor of operator()(...)") object call(Args &&...args) const
 
int ref_count () const
 Return the object's current reference count. More...
 
pybind11::str str () const
 

Private Member Functions

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

Detailed Description

template<typename Derived>
class 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 77 of file pytypes.h.

Member Function Documentation

◆ attr() [1/3]

template<typename D >
obj_attr_accessor object_api< D >::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 2304 of file pytypes.h.

◆ attr() [2/3]

template<typename D >
obj_attr_accessor object_api< D >::attr ( object &&  key) const

See above (the only difference is that the key's reference is stolen)

Definition at line 2308 of file pytypes.h.

◆ attr() [3/3]

template<typename D >
str_attr_accessor object_api< D >::attr ( const char *  key) const

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

Definition at line 2312 of file pytypes.h.

◆ begin()

template<typename D >
iterator object_api< D >::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 2284 of file pytypes.h.

◆ contains()

template<typename D >
template<typename T >
bool object_api< D >::contains ( T &&  item) const

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

Definition at line 2321 of file pytypes.h.

◆ derived()

template<typename Derived>
const Derived& object_api< Derived >::derived ( ) const
inlineprivate

Definition at line 78 of file pytypes.h.

◆ doc()

template<typename D >
str_attr_accessor object_api< D >::doc ( ) const

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

Definition at line 2331 of file pytypes.h.

◆ end()

template<typename D >
iterator object_api< D >::end ( ) const

Return a sentinel which ends iteration.

Definition at line 2288 of file pytypes.h.

◆ equal()

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

Equivalent to obj == other in Python.

Definition at line 148 of file pytypes.h.

◆ get_type()

template<typename D >
handle object_api< D >::get_type ( ) const

Definition at line 2336 of file pytypes.h.

◆ is()

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

Equivalent to obj is other in Python.

Definition at line 144 of file pytypes.h.

◆ is_none()

template<typename Derived>
bool object_api< Derived >::is_none ( ) const
inline

Equivalent to obj is None in Python.

Definition at line 146 of file pytypes.h.

◆ not_equal()

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

Definition at line 149 of file pytypes.h.

◆ operator &()

template<typename Derived>
object object_api< Derived >::operator& ( object_api< Derived > const &  other) const

◆ operator &=()

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

◆ operator()()

template<typename Derived >
template<return_value_policy policy, typename... Args>
object object_api< Derived >::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 1627 of file cast.h.

◆ operator*() [1/2]

template<typename D >
args_proxy object_api< D >::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 2316 of file pytypes.h.

◆ operator*() [2/2]

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

◆ operator*=()

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

◆ operator+()

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

◆ operator+=()

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

◆ operator-() [1/2]

template<typename Derived>
object object_api< Derived >::operator- ( ) const

◆ operator-() [2/2]

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

◆ operator-=()

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

◆ operator/()

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

◆ operator/=()

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

◆ operator<()

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

Definition at line 150 of file pytypes.h.

◆ operator<<()

template<typename Derived>
object object_api< Derived >::operator<< ( object_api< Derived > const &  other) const

◆ operator<<=()

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

◆ operator<=()

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

Definition at line 151 of file pytypes.h.

◆ operator>()

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

Definition at line 152 of file pytypes.h.

◆ operator>=()

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

Definition at line 153 of file pytypes.h.

◆ operator>>()

template<typename Derived>
object object_api< Derived >::operator>> ( object_api< Derived > const &  other) const

◆ operator>>=()

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

◆ operator[]() [1/3]

template<typename D >
item_accessor object_api< D >::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 2292 of file pytypes.h.

◆ operator[]() [2/3]

template<typename D >
item_accessor object_api< D >::operator[] ( object &&  key) const

See above (the only difference is that the key's reference is stolen)

Definition at line 2296 of file pytypes.h.

◆ operator[]() [3/3]

template<typename D >
item_accessor object_api< D >::operator[] ( const char *  key) const

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

Definition at line 2300 of file pytypes.h.

◆ operator^()

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

◆ operator^=()

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

◆ operator|()

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

◆ operator|=()

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

◆ operator~()

template<typename Derived>
object object_api< Derived >::operator~ ( ) const

◆ PYBIND11_DEPRECATED()

template<typename Derived>
template<return_value_policy policy = return_value_policy::automatic_reference, typename... Args>
object_api< Derived >::PYBIND11_DEPRECATED ( "call(...) was deprecated in favor of operator()(...)"  ) const &&

◆ ref_count()

template<typename Derived>
int object_api< Derived >::ref_count ( ) const
inline

Return the object's current reference count.

Definition at line 183 of file pytypes.h.

◆ rich_compare()

template<typename D >
bool object_api< D >::rich_compare ( object_api< Derived > const &  other,
int  value 
) const
private

Definition at line 2341 of file pytypes.h.

◆ str()

template<typename D >
pybind11::str object_api< D >::str ( ) const

Definition at line 2326 of file pytypes.h.


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


gtsam
Author(s):
autogenerated on Tue Jul 4 2023 02:41:03