changes from the laptop

- some should be the same as previous commit (sorry!)
- some should be new: LINT checks, ...?
This commit is contained in:
2017-05-24 10:03:39 +02:00
parent f67f95d1ce
commit 04d8ae8c74
42 changed files with 1344 additions and 60 deletions

44
data/XMLserialize.h Normal file
View File

@@ -0,0 +1,44 @@
#ifndef XMLSERIALIZE_H
#define XMLSERIALIZE_H
#include "XMLload.h"
#include "XMLsave.h"
#include "xml.h"
class XMLserialize : public XMLload, public XMLsave {
public:
void loadXML(const std::string& file) {
XMLDoc doc;
assertOK(doc.LoadFile(file.c_str()), doc, "error while loading file");
XMLElem* root = doc.FirstChildElement("root");
readFromXML(&doc, root);
}
void saveXML(const std::string& file) {
XMLDoc doc;
XMLElem* root = doc.NewElement("root");
doc.InsertFirstChild(root);
writeToXML(&doc, root);
assertOK(doc.SaveFile(file.c_str()), doc, "error while saving file");
}
public:
static void assertOK(XMLErr res, XMLDoc& doc, const std::string& txt) {
if (res != tinyxml2::XMLError::XML_SUCCESS) {
const std::string err = doc.ErrorName();
const std::string add = doc.GetErrorStr1();
throw Exception(txt + ": " + err + " - " + add);
}
}
};
#endif // XMLSERIALIZE_H