std::string PropertyFileIncluded::getDocTransientPath(void) const { PropertyContainer *co = getContainer(); if (co->isDerivedFrom(DocumentObject::getClassTypeId())) return dynamic_cast<DocumentObject*>(co)->getDocument()->TransientDir.getValue(); return std::string(); }
std::string PropertyFileIncluded::getDocTransientPath(void) const { std::string path; PropertyContainer *co = getContainer(); if (co->isDerivedFrom(DocumentObject::getClassTypeId())) { path = static_cast<DocumentObject*>(co)->getDocument()->TransientDir.getValue(); std::replace(path.begin(), path.end(), '\\', '/'); } return path; }
void PropertyPythonObject::saveObject(Base::Writer &writer) const { Base::PyGILStateLocker lock; try { PropertyContainer* parent = this->getContainer(); if (parent->isDerivedFrom(Base::Type::fromName("App::DocumentObject"))) { if (this->object.hasAttr("__object__")) { writer.Stream() << " object=\"yes\""; } } if (parent->isDerivedFrom(Base::Type::fromName("Gui::ViewProvider"))) { if (this->object.hasAttr("__vobject__")) { writer.Stream() << " vobject=\"yes\""; } } } catch (Py::Exception& e) { e.clear(); } }
Expression * VariableExpression::eval() const { const Property * prop = getProperty(); PropertyContainer * parent = prop->getContainer(); if (!parent->isDerivedFrom(App::DocumentObject::getClassTypeId())) throw ExpressionError("Property must belong to a document object."); boost::any value = prop->getPathValue(var); if (value.type() == typeid(Quantity)) { Quantity qvalue = boost::any_cast<Quantity>(value); return new NumberExpression(owner, qvalue); } else if (value.type() == typeid(double)) { double dvalue = boost::any_cast<double>(value); return new NumberExpression(owner, dvalue); } else if (value.type() == typeid(float)) { double fvalue = boost::any_cast<float>(value); return new NumberExpression(owner, fvalue); } else if (value.type() == typeid(int)) { int ivalue = boost::any_cast<int>(value); return new NumberExpression(owner, ivalue); } else if (value.type() == typeid(std::string)) { std::string svalue = boost::any_cast<std::string>(value); return new StringExpression(owner, svalue); } else if (value.type() == typeid(char*)) { char* svalue = boost::any_cast<char*>(value); return new StringExpression(owner, svalue); } else if (value.type() == typeid(const char*)) { const char* svalue = boost::any_cast<const char*>(value); return new StringExpression(owner, svalue); } throw ExpressionError("Property is of invalid type."); }