本文整理汇总了C++中app::Property::getPyObject方法的典型用法代码示例。如果您正苦于以下问题:C++ Property::getPyObject方法的具体用法?C++ Property::getPyObject怎么用?C++ Property::getPyObject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app::Property
的用法示例。
在下文中一共展示了Property::getPyObject方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getPropertyByName
PyObject* PropertyContainerPy::getPropertyByName(PyObject *args)
{
char *pstr;
if (!PyArg_ParseTuple(args, "s", &pstr)) // convert args: Python->C
return NULL; // NULL triggers exception
App::Property* prop = getPropertyContainerPtr()->getPropertyByName(pstr);
if (prop) {
return prop->getPyObject();
}
else {
PyErr_Format(PyExc_AttributeError, "Property container has no property '%s'", pstr);
return NULL;
}
}
示例2: getattr
Py::Object DocumentObjectProtectorPy::getattr(const char * attr)
{
if (!_dp) {
std::string s;
std::ostringstream s_out;
s_out << "Cannot access attribute '" << attr << "' of deleted object";
throw Py::RuntimeError(s_out.str());
}
else {
App::DocumentObject* obj = _dp->getObject();
App::Property* prop = obj->getPropertyByName(attr);
if (!prop) {
return Py::PythonExtension<DocumentObjectProtectorPy>::getattr(attr);
//std::string s;
//std::ostringstream s_out;
//s_out << "No such attribute '" << attr << "'";
//throw Py::AttributeError(s_out.str());
}
return Py::asObject(prop->getPyObject());
}
}