本文整理汇总了C++中base::XMLReader::addFile方法的典型用法代码示例。如果您正苦于以下问题:C++ XMLReader::addFile方法的具体用法?C++ XMLReader::addFile怎么用?C++ XMLReader::addFile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类base::XMLReader
的用法示例。
在下文中一共展示了XMLReader::addFile方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Restore
void PropertyMeshKernel::Restore(Base::XMLReader &reader)
{
reader.readElement("Mesh");
std::string file (reader.getAttribute("file") );
if (file.empty()) {
// read XML
MeshCore::MeshKernel kernel;
MeshCore::MeshInput restorer(kernel);
restorer.LoadXML(reader);
// avoid to duplicate the mesh in memory
MeshCore::MeshPointArray points;
MeshCore::MeshFacetArray facets;
kernel.Adopt(points, facets);
aboutToSetValue();
_meshObject->getKernel().Adopt(points, facets);
hasSetValue();
}
else {
// initate a file read
reader.addFile(file.c_str(),this);
}
}
示例2: Restore
void PropertyFileIncluded::Restore(Base::XMLReader &reader)
{
reader.readElement("FileIncluded");
if (reader.hasAttribute("file")) {
string file (reader.getAttribute("file") );
if (!file.empty()) {
// initate a file read
reader.addFile(file.c_str(),this);
// is in the document transient path
aboutToSetValue();
_cValue = getDocTransientPath() + "/" + file;
_BaseFileName = file;
hasSetValue();
}
}
// section is XML stream
else if (reader.hasAttribute("data")) {
string file (reader.getAttribute("data") );
if (!file.empty()) {
// is in the document transient path
aboutToSetValue();
_cValue = getDocTransientPath() + "/" + file;
reader.readBinFile(_cValue.c_str());
reader.readEndElement("FileIncluded");
_BaseFileName = file;
hasSetValue();
}
}
}
示例3: Restore
void PropertyFilletEdges::Restore(Base::XMLReader &reader)
{
reader.readElement("FilletEdges");
std::string file (reader.getAttribute("file") );
if (!file.empty()) {
// initate a file read
reader.addFile(file.c_str(),this);
}
}
示例4: Restore
void PropertyGreyValueList::Restore(Base::XMLReader &reader)
{
reader.readElement("FloatList");
string file (reader.getAttribute("file") );
if (!file.empty()) {
// initate a file read
reader.addFile(file.c_str(),this);
}
}
示例5: Restore
/**
* Loads a separate XML file from the projects file with information about the view providers.
*/
void Document::Restore(Base::XMLReader &reader)
{
reader.addFile("GuiDocument.xml",this);
// hide all elements to avoid to update the 3d view when loading data files
// RestoreDocFile then restores the visibility status again
std::map<const App::DocumentObject*,ViewProviderDocumentObject*>::iterator it;
for (it = d->_ViewProviderMap.begin(); it != d->_ViewProviderMap.end(); ++it) {
it->second->startRestoring();
}
}
示例6: Restore
void PointKernel::Restore(Base::XMLReader &reader)
{
clear();
reader.readElement("Points");
std::string file (reader.getAttribute("file") );
if (!file.empty()) {
// initiate a file read
reader.addFile(file.c_str(),this);
}
if (reader.DocumentSchema > 3) {
std::string Matrix (reader.getAttribute("mtrx") );
_Mtrx.fromString(Matrix);
}
}
示例7: Restore
void PropertyPointKernel::Restore(Base::XMLReader &reader)
{
reader.readElement("Points");
std::string file (reader.getAttribute("file") );
if (!file.empty()) {
// initate a file read
reader.addFile(file.c_str(),this);
}
if(reader.DocumentSchema > 3)
{
std::string Matrix (reader.getAttribute("mtrx") );
Base::Matrix4D mtrx;
mtrx.fromString(Matrix);
aboutToSetValue();
_cPoints->setTransform(mtrx);
hasSetValue();
}
}
示例8: Restore
void PropertyPythonObject::Restore(Base::XMLReader &reader)
{
reader.readElement("Python");
if (reader.hasAttribute("file")) {
std::string file(reader.getAttribute("file"));
reader.addFile(file.c_str(),this);
}
else {
bool load_json=false;
bool load_pickle=false;
bool load_failed=false;
std::string buffer = reader.getAttribute("value");
if (reader.hasAttribute("encoded") &&
strcmp(reader.getAttribute("encoded"),"yes") == 0) {
buffer = Base::base64_decode(buffer);
}
else {
buffer = decodeValue(buffer);
}
Base::PyGILStateLocker lock;
try {
boost::regex pickle("^\\(i(\\w+)\\n(\\w+)\\n");
boost::match_results<std::string::const_iterator> what;
std::string::const_iterator start, end;
start = buffer.begin();
end = buffer.end();
if (reader.hasAttribute("module") && reader.hasAttribute("class")) {
Py::Module mod(PyImport_ImportModule(reader.getAttribute("module")),true);
PyObject* cls = mod.getAttr(reader.getAttribute("class")).ptr();
#if PY_MAJOR_VERSION >= 3
if (PyType_Check(cls)) {
#else
if (PyClass_Check(cls)) {
this->object = PyInstance_NewRaw(cls, 0);
}
else if (PyType_Check(cls)) {
#endif
this->object = PyType_GenericAlloc((PyTypeObject*)cls, 0);
}
else {
throw Py::TypeError("neither class nor type object");
}
load_json = true;
}
else if (boost::regex_search(start, end, what, pickle)) {
std::string nam = std::string(what[1].first, what[1].second);
std::string cls = std::string(what[2].first, what[2].second);
Py::Module mod(PyImport_ImportModule(nam.c_str()),true);
#if PY_MAJOR_VERSION >= 3
this->object = PyObject_CallObject(mod.getAttr(cls).ptr(), NULL);
#else
this->object = PyInstance_NewRaw(mod.getAttr(cls).ptr(), 0);
#endif
load_pickle = true;
buffer = std::string(what[2].second, end);
}
else if (reader.hasAttribute("json")) {
load_json = true;
}
}
catch (Py::Exception&) {
Base::PyException e; // extract the Python error text
e.ReportException();
this->object = Py::None();
load_failed = true;
}
aboutToSetValue();
if (load_json)
this->fromString(buffer);
else if (load_pickle)
this->loadPickle(buffer);
else if (!load_failed)
Base::Console().Warning("PropertyPythonObject::Restore: unsupported serialisation: %s\n", buffer.c_str());
restoreObject(reader);
hasSetValue();
}
}
示例9: Restore
void MergeDocuments::Restore(Base::XMLReader &r)
{
r.addFile("GuiDocument.xml", this);
}