这是针对pubind11::object的封装
更多...
#include <DAPyObjectWrapper.h>
|
|
using | ErrCallback = std::function< void(const char *) > |
| | 异常错误回调函数
|
| |
|
|
| DAPyObjectWrapper (const DAPyObjectWrapper &obj) |
| |
|
| DAPyObjectWrapper (DAPyObjectWrapper &&obj) |
| |
|
| DAPyObjectWrapper (const pybind11::object &obj) |
| |
|
| DAPyObjectWrapper (pybind11::object &&obj) |
| |
|
bool | isNone () const |
| |
|
DAPyObjectWrapper & | operator= (const DAPyObjectWrapper &obj) |
| |
|
DAPyObjectWrapper & | operator= (DAPyObjectWrapper &&obj) |
| |
|
DAPyObjectWrapper & | operator= (const pybind11::object &obj) |
| |
|
DAPyObjectWrapper & | operator= (pybind11::object &&obj) |
| |
|
bool | operator== (void *ptr) const |
| |
|
bool | operator== (const pybind11::object &obj) const |
| |
|
bool | operator== (const DAPyObjectWrapper &obj) const |
| |
|
bool | operator!= (void *ptr) const |
| |
|
bool | operator!= (const pybind11::object &obj) const |
| |
|
bool | operator!= (const DAPyObjectWrapper &obj) const |
| |
|
| operator bool () const |
| |
| void | dealException (const std::exception &e) const |
| | 统一的异常处理函数
|
| |
| DAPyObjectWrapper | deepCopy () const |
| | 深拷贝
|
| |
|
pybind11::object & | object () |
| |
|
const pybind11::object & | object () const |
| |
|
QVariant | toVariant () const |
| |
|
bool | isinstance (const pybind11::handle &type) const |
| |
| bool | isInt () const |
| | 是否为int
|
| |
| bool | isModule () const |
| | 是否为Module
|
| |
| bool | isFloat () const |
| | 是否为float
|
| |
| bool | isStr () const |
| | 是否为str
|
| |
|
bool | isBool () const |
| |
|
bool | isList () const |
| |
|
bool | isDict () const |
| |
|
bool | isTuple () const |
| |
|
bool | isCallable () const |
| |
|
bool | isSequence () const |
| |
|
bool | isNumeric () const |
| |
| void | setErrCallback (const ErrCallback &fun) |
| | 设置错误处理回调
|
| |
|
ErrCallback | getErrCallback () const |
| |
| pybind11::object | attr (const char *c_att) |
| | 获取属性
|
| |
|
pybind11::object | attr (const char *c_att) const |
| |
| template<typename... Args> |
| pybind11::object | call (Args &&... args) |
| | 直接调用Python可调用对象
|
| |
| QString | __name__ () const |
| | 对应__name__
|
| |
|
QString | __str__ () const |
| |
|
QString | __repr__ () const |
| |
|
QString | typeName () const |
| |
|
size_t | refCount () const |
| |
◆ __name__()
| QString DAPyObjectWrapper::__name__ |
( |
| ) |
const |
◆ attr()
| pybind11::object DAPyObjectWrapper::attr |
( |
const char * |
c_att | ) |
|
◆ call()
template<typename... Args>
| pybind11::object DA::DAPyObjectWrapper::call |
( |
Args &&... |
args | ) |
|
直接调用Python可调用对象
此函数用于调用当前包装的Python可调用对象(如函数、方法、lambda等)。 如果对象不可调用,将抛出 std::runtime_error 异常。 如果Python调用过程中发生异常,将通过pybind11抛出 pybind11::error_already_set 异常。
- 模板参数
-
- 参数
-
- 返回
- pybind11::object Python调用返回的对象
- 异常
-
| std::runtime_error | 如果对象不可调用 |
| pybind11::error_already_set | 如果Python调用过程中发生异常 |
- 注解
- 此函数不捕获任何异常,调用者需要自行处理可能的异常
pybind11::object result = func.
call();
pybind11::object result = func.
call(42,
"hello", 3.14);
try {
pybind11::object result = obj.call(x, y);
} catch (const pybind11::error_already_set& e) {
qCritical() << "Python call failed:" << e.what();
} catch (const std::runtime_error& e) {
qCritical() << "Object is not callable:" << e.what();
}
这是针对pubind11::object的封装
Definition DAPyObjectWrapper.h:15
pybind11::object call(Args &&... args)
直接调用Python可调用对象
Definition DAPyObjectWrapper.h:149
◆ dealException()
| void DAPyObjectWrapper::dealException |
( |
const std::exception & |
e | ) |
const |
◆ deepCopy()
◆ isFloat()
| bool DAPyObjectWrapper::isFloat |
( |
| ) |
const |
◆ isInt()
| bool DAPyObjectWrapper::isInt |
( |
| ) |
const |
◆ isModule()
| bool DAPyObjectWrapper::isModule |
( |
| ) |
const |
◆ isStr()
| bool DAPyObjectWrapper::isStr |
( |
| ) |
const |
◆ setErrCallback()
| void DAPyObjectWrapper::setErrCallback |
( |
const ErrCallback & |
fun | ) |
|
该类的文档由以下文件生成:
- /home/runner/work/data-workbench/data-workbench/src/DAPyBindQt/DAPyObjectWrapper.h
- /home/runner/work/data-workbench/data-workbench/src/DAPyBindQt/DAPyObjectWrapper.cpp