MCPcopy Create free account
hub / github.com/FreeCAD/FreeCAD / Save

Method Save

src/App/PropertyPythonObject.cpp:430–459  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

428}
429
430void PropertyPythonObject::Save(Base::Writer& writer) const
431{
432 std::string repr = this->toString();
433 repr = Base::base64_encode((const unsigned char*)repr.c_str(), repr.size());
434 std::string val = /*encodeValue*/ (repr);
435 writer.Stream() << writer.ind() << "<Python value=\"" << val << R"(" encoded="yes")";
436
437 Base::PyGILStateLocker lock;
438 try {
439 if (this->object.hasAttr("__module__") && this->object.hasAttr("__class__")) {
440 Py::String mod(this->object.getAttr("__module__"));
441 Py::Object cls(this->object.getAttr("__class__"));
442 if (cls.hasAttr("__name__")) {
443 Py::String name(cls.getAttr("__name__"));
444 writer.Stream() << " module=\"" << (std::string)mod << "\""
445 << " class=\"" << (std::string)name << "\"";
446 }
447 }
448 else {
449 writer.Stream() << " json=\"yes\"";
450 }
451 }
452 catch (Py::Exception&) {
453 Base::PyException e; // extract the Python error text
454 e.reportException();
455 }
456
457 saveObject(writer);
458 writer.Stream() << "/>" << std::endl;
459}
460
461void PropertyPythonObject::Restore(Base::XMLReader& reader)
462{

Callers

nothing calls this directly

Calls 5

toStringMethod · 0.95
base64_encodeFunction · 0.85
c_strMethod · 0.45
sizeMethod · 0.45
reportExceptionMethod · 0.45

Tested by

no test coverage detected