Scarab  v2.9.1
Project 8 C++ Utility Library
Classes | Public Types | Public Member Functions | Public Attributes | Static Public Attributes | Private Types | Static Private Member Functions | List of all members
class_< type_, options > Class Template Reference

#include <pybind11.h>

Inheritance diagram for class_< type_, options >:
Inheritance graph

Classes

struct  is_valid_class_option
 

Public Types

using type = type_
 
using type_alias = detail::exactly_one_t< is_subtype, void, options... >
 
using holder_type = detail::exactly_one_t< is_holder, std::unique_ptr< type >, options... >
 

Public Member Functions

 __attribute__ ((deprecated("Use reinterpret_borrow<""class_"">() or reinterpret_steal<""class_"">()"))) class_(handle h
 
bool typename Extra class_def (const char *name_, Func &&f, const Extra &... extra)
 
template<typename Func , typename... Extra>
class_def_static (const char *name_, Func &&f, const Extra &... extra)
 
template<detail::op_id id, detail::op_type ot, typename L , typename R , typename... Extra>
class_def (const detail::op_< id, ot, L, R > &op, const Extra &... extra)
 
template<detail::op_id id, detail::op_type ot, typename L , typename R , typename... Extra>
class_def_cast (const detail::op_< id, ot, L, R > &op, const Extra &... extra)
 
template<typename... Args, typename... Extra>
class_def (const detail::initimpl::constructor< Args... > &init, const Extra &... extra)
 
template<typename... Args, typename... Extra>
class_def (const detail::initimpl::alias_constructor< Args... > &init, const Extra &... extra)
 
template<typename... Args, typename... Extra>
class_def (detail::initimpl::factory< Args... > &&init, const Extra &... extra)
 
template<typename... Args, typename... Extra>
class_def (detail::initimpl::pickle_factory< Args... > &&pf, const Extra &...extra)
 
template<typename Func >
class_def_buffer (Func &&func)
 
template<typename Return , typename Class , typename... Args>
class_def_buffer (Return(Class::*func)(Args...))
 
template<typename Return , typename Class , typename... Args>
class_def_buffer (Return(Class::*func)(Args...) const)
 
template<typename C , typename D , typename... Extra>
class_def_readwrite (const char *name, D C::*pm, const Extra &... extra)
 
template<typename C , typename D , typename... Extra>
class_def_readonly (const char *name, const D C::*pm, const Extra &...extra)
 
template<typename D , typename... Extra>
class_def_readwrite_static (const char *name, D *pm, const Extra &...extra)
 
template<typename D , typename... Extra>
class_def_readonly_static (const char *name, const D *pm, const Extra &...extra)
 
template<typename Getter , typename... Extra>
class_def_property_readonly (const char *name, const Getter &fget, const Extra &...extra)
 Uses return_value_policy::reference_internal by default. More...
 
template<typename... Extra>
class_def_property_readonly (const char *name, const cpp_function &fget, const Extra &...extra)
 Uses cpp_function's return_value_policy by default. More...
 
template<typename Getter , typename... Extra>
class_def_property_readonly_static (const char *name, const Getter &fget, const Extra &...extra)
 Uses return_value_policy::reference by default. More...
 
template<typename... Extra>
class_def_property_readonly_static (const char *name, const cpp_function &fget, const Extra &...extra)
 Uses cpp_function's return_value_policy by default. More...
 
template<typename Getter , typename Setter , typename... Extra>
class_def_property (const char *name, const Getter &fget, const Setter &fset, const Extra &...extra)
 Uses return_value_policy::reference_internal by default. More...
 
template<typename Getter , typename... Extra>
class_def_property (const char *name, const Getter &fget, const cpp_function &fset, const Extra &...extra)
 
template<typename... Extra>
class_def_property (const char *name, const cpp_function &fget, const cpp_function &fset, const Extra &...extra)
 Uses cpp_function's return_value_policy by default. More...
 
template<typename Getter , typename... Extra>
class_def_property_static (const char *name, const Getter &fget, const cpp_function &fset, const Extra &...extra)
 Uses return_value_policy::reference by default. More...
 
template<typename... Extra>
class_def_property_static (const char *name, const cpp_function &fget, const cpp_function &fset, const Extra &...extra)
 Uses cpp_function's return_value_policy by default. More...
 
- Public Member Functions inherited from generic_type
 __attribute__ ((deprecated("Use reinterpret_borrow<""generic_type"">() or reinterpret_steal<""generic_type"">()"))) generic_type(handle h
 
- Public Member Functions inherited from object
 object ()=default
 
 __attribute__ ((deprecated("Use reinterpret_borrow<object>() or reinterpret_steal<object>()"))) object(handle h
 
 object (const object &o)
 Copy constructor; always increases the reference count. More...
 
 object (object &&other) noexcept
 Move constructor; steals the object from other and preserves its reference count. More...
 
 ~object ()
 Destructor; automatically calls handle::dec_ref() More...
 
handle release ()
 
objectoperator= (const object &other)
 
objectoperator= (object &&other) noexcept
 
template<typename T >
cast () const &
 
template<typename T >
cast () &&
 
 object (handle h, borrowed_t)
 
 object (handle h, stolen_t)
 
template<typename T >
cast () const &
 
template<typename T >
cast () &&
 
template<>
void cast () const &
 
template<>
void cast () &&
 
- Public Member Functions inherited from handle
 handle ()=default
 The default constructor creates a handle with a nullptr-valued pointer. More...
 
 handle (PyObject *ptr)
 Creates a handle from the given raw Python object pointer. More...
 
PyObject * ptr () const
 Return the underlying PyObject * pointer. More...
 
PyObject *& ptr ()
 
const handleinc_ref () const &
 
const handledec_ref () const &
 
template<typename T >
cast () const
 
 operator bool () const
 Return true when the handle wraps a valid Python object. More...
 
 __attribute__ ((deprecated("Use obj1.is(obj2) instead"))) bool operator
 
template<>
void cast () const
 
- Public Member Functions inherited from object_api< handle >
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
 
object operator* (object_api const &other) const
 
bool contains (T &&item) const
 Check if the given item is contained within this object, i.e. item in obj. More...
 
object operator() (Args &&...args) const
 
 __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- (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
 
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...
 

Public Attributes

bool is_borrowed: generic_type (is_borrowed ? generic_type (h
 
bool borrowed_t
 
bool int
 
- Public Attributes inherited from generic_type
bool is_borrowed: object (is_borrowed ? object (h
 
- Public Attributes inherited from object
bool is_borrowed: handle(h) { if (is_borrowed) inc_ref()
 

Static Public Attributes

static constexpr bool has_alias = !std::is_void<type_alias>::value
 

Private Types

template<typename T >
using is_holder = detail::is_holder_type< type_, T >
 
template<typename T >
using is_subtype = detail::is_strict_base_of< type_, T >
 
template<typename T >
using is_base = detail::is_strict_base_of< T, type_ >
 

Static Private Member Functions

template<typename T >
static void init_holder (detail::instance *inst, detail::value_and_holder &v_h, const holder_type *, const std::enable_shared_from_this< T > *)
 Initialize holder object, variant 1: object derives from enable_shared_from_this. More...
 
static void init_holder_from_existing (const detail::value_and_holder &v_h, const holder_type *holder_ptr, std::true_type)
 
static void init_holder_from_existing (const detail::value_and_holder &v_h, const holder_type *holder_ptr, std::false_type)
 
static void init_holder (detail::instance *inst, detail::value_and_holder &v_h, const holder_type *holder_ptr, const void *)
 Initialize holder object, variant 2: try to construct from existing holder object, if possible. More...
 
static void init_instance (detail::instance *inst, const void *holder_ptr)
 
static void dealloc (detail::value_and_holder &v_h)
 Deallocates an instance; via holder, if constructed; otherwise via operator delete. More...
 
static detail::function_recordget_function_record (handle h)
 

Detailed Description

template<typename type_, typename... options>
class pybind11::class_< type_, options >

Definition at line 1038 of file pybind11.h.

Member Typedef Documentation

◆ holder_type

using holder_type = detail::exactly_one_t<is_holder, std::unique_ptr<type>, options...>

Definition at line 1050 of file pybind11.h.

◆ is_base

using is_base = detail::is_strict_base_of<T, type_>
private

Definition at line 1041 of file pybind11.h.

◆ is_holder

using is_holder = detail::is_holder_type<type_, T>
private

Definition at line 1039 of file pybind11.h.

◆ is_subtype

using is_subtype = detail::is_strict_base_of<type_, T>
private

Definition at line 1040 of file pybind11.h.

◆ type

using type = type_

Definition at line 1047 of file pybind11.h.

◆ type_alias

using type_alias = detail::exactly_one_t<is_subtype, void, options...>

Definition at line 1048 of file pybind11.h.

Member Function Documentation

◆ __attribute__()

__attribute__ ( (deprecated("Use reinterpret_borrow<""class_< type_, options >"">() or reinterpret_steal<""class_< type_, options >"">()"))  )

◆ dealloc()

static void dealloc ( detail::value_and_holder v_h)
inlinestaticprivate

Deallocates an instance; via holder, if constructed; otherwise via operator delete.

Definition at line 1349 of file pybind11.h.

◆ def() [1/6]

bool typename Extra class_& def ( const char *  name_,
Func &&  f,
const Extra &...  extra 
)
inline

Definition at line 1110 of file pybind11.h.

◆ def() [2/6]

class_& def ( const detail::op_< id, ot, L, R > &  op,
const Extra &...  extra 
)
inline

Definition at line 1128 of file pybind11.h.

◆ def() [3/6]

class_& def ( const detail::initimpl::constructor< Args... > &  init,
const Extra &...  extra 
)
inline

Definition at line 1140 of file pybind11.h.

◆ def() [4/6]

class_& def ( const detail::initimpl::alias_constructor< Args... > &  init,
const Extra &...  extra 
)
inline

Definition at line 1146 of file pybind11.h.

◆ def() [5/6]

class_& def ( detail::initimpl::factory< Args... > &&  init,
const Extra &...  extra 
)
inline

Definition at line 1152 of file pybind11.h.

◆ def() [6/6]

class_& def ( detail::initimpl::pickle_factory< Args... > &&  pf,
const Extra &...  extra 
)
inline

Definition at line 1158 of file pybind11.h.

◆ def_buffer() [1/3]

class_& def_buffer ( Func &&  func)
inline

Definition at line 1163 of file pybind11.h.

◆ def_buffer() [2/3]

class_& def_buffer ( Return(Class::*)(Args...)  func)
inline

Definition at line 1176 of file pybind11.h.

◆ def_buffer() [3/3]

class_& def_buffer ( Return(Class::*)(Args...) const  func)
inline

Definition at line 1181 of file pybind11.h.

◆ def_cast()

class_& def_cast ( const detail::op_< id, ot, L, R > &  op,
const Extra &...  extra 
)
inline

Definition at line 1134 of file pybind11.h.

◆ def_property() [1/3]

class_& def_property ( const char *  name,
const Getter &  fget,
const Setter &  fset,
const Extra &...  extra 
)
inline

Uses return_value_policy::reference_internal by default.

Definition at line 1244 of file pybind11.h.

◆ def_property() [2/3]

class_& def_property ( const char *  name,
const Getter &  fget,
const cpp_function fset,
const Extra &...  extra 
)
inline

Definition at line 1248 of file pybind11.h.

◆ def_property() [3/3]

class_& def_property ( const char *  name,
const cpp_function fget,
const cpp_function fset,
const Extra &...  extra 
)
inline

Uses cpp_function's return_value_policy by default.

Definition at line 1255 of file pybind11.h.

◆ def_property_readonly() [1/2]

class_& def_property_readonly ( const char *  name,
const Getter &  fget,
const Extra &...  extra 
)
inline

Uses return_value_policy::reference_internal by default.

Definition at line 1219 of file pybind11.h.

◆ def_property_readonly() [2/2]

class_& def_property_readonly ( const char *  name,
const cpp_function fget,
const Extra &...  extra 
)
inline

Uses cpp_function's return_value_policy by default.

Definition at line 1226 of file pybind11.h.

◆ def_property_readonly_static() [1/2]

class_& def_property_readonly_static ( const char *  name,
const Getter &  fget,
const Extra &...  extra 
)
inline

Uses return_value_policy::reference by default.

Definition at line 1232 of file pybind11.h.

◆ def_property_readonly_static() [2/2]

class_& def_property_readonly_static ( const char *  name,
const cpp_function fget,
const Extra &...  extra 
)
inline

Uses cpp_function's return_value_policy by default.

Definition at line 1238 of file pybind11.h.

◆ def_property_static() [1/2]

class_& def_property_static ( const char *  name,
const Getter &  fget,
const cpp_function fset,
const Extra &...  extra 
)
inline

Uses return_value_policy::reference by default.

Definition at line 1261 of file pybind11.h.

◆ def_property_static() [2/2]

class_& def_property_static ( const char *  name,
const cpp_function fget,
const cpp_function fset,
const Extra &...  extra 
)
inline

Uses cpp_function's return_value_policy by default.

Definition at line 1267 of file pybind11.h.

◆ def_readonly()

class_& def_readonly ( const char *  name,
const D C::*  pm,
const Extra &...  extra 
)
inline

Definition at line 1195 of file pybind11.h.

◆ def_readonly_static()

class_& def_readonly_static ( const char *  name,
const D *  pm,
const Extra &...  extra 
)
inline

Definition at line 1211 of file pybind11.h.

◆ def_readwrite()

class_& def_readwrite ( const char *  name,
D C::*  pm,
const Extra &...  extra 
)
inline

Definition at line 1186 of file pybind11.h.

◆ def_readwrite_static()

class_& def_readwrite_static ( const char *  name,
D *  pm,
const Extra &...  extra 
)
inline

Definition at line 1203 of file pybind11.h.

◆ def_static()

class_& def_static ( const char *  name_,
Func &&  f,
const Extra &...  extra 
)
inline

Definition at line 1118 of file pybind11.h.

◆ get_function_record()

static detail::function_record* get_function_record ( handle  h)
inlinestaticprivate

Definition at line 1363 of file pybind11.h.

◆ init_holder() [1/2]

static void init_holder ( detail::instance inst,
detail::value_and_holder v_h,
const holder_type ,
const std::enable_shared_from_this< T > *   
)
inlinestaticprivate

Initialize holder object, variant 1: object derives from enable_shared_from_this.

Definition at line 1296 of file pybind11.h.

◆ init_holder() [2/2]

static void init_holder ( detail::instance inst,
detail::value_and_holder v_h,
const holder_type holder_ptr,
const void *   
)
inlinestaticprivate

Initialize holder object, variant 2: try to construct from existing holder object, if possible.

Definition at line 1324 of file pybind11.h.

◆ init_holder_from_existing() [1/2]

static void init_holder_from_existing ( const detail::value_and_holder v_h,
const holder_type holder_ptr,
std::true_type   
)
inlinestaticprivate

Definition at line 1313 of file pybind11.h.

◆ init_holder_from_existing() [2/2]

static void init_holder_from_existing ( const detail::value_and_holder v_h,
const holder_type holder_ptr,
std::false_type   
)
inlinestaticprivate

Definition at line 1318 of file pybind11.h.

◆ init_instance()

static void init_instance ( detail::instance inst,
const void *  holder_ptr 
)
inlinestaticprivate

Performs instance initialization including constructing a holder and registering the known instance. Should be called as soon as the type value_ptr is set for an instance. Takes an optional pointer to an existing holder to use; if not specified and the instance is .owned, a new holder will be constructed to manage the value pointer.

Definition at line 1339 of file pybind11.h.

Member Data Documentation

◆ borrowed_t

bool borrowed_t

Definition at line 1058 of file pybind11.h.

◆ has_alias

constexpr bool has_alias = !std::is_void<type_alias>::value
static

Definition at line 1049 of file pybind11.h.

◆ int

bool int
Initial value:
= 0>
static void add_base(detail::type_record &rec) {
rec.add_base(typeid(Base), [](void *src) -> void * {
return static_cast<Base *>(reinterpret_cast<type *>(src));
});
}
template <typename Base

Definition at line 1099 of file pybind11.h.

◆ is_borrowed

bool is_borrowed

Definition at line 1058 of file pybind11.h.


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