diff --git a/source/glest_game/game/game.cpp b/source/glest_game/game/game.cpp index 4995c6be..e82382d2 100644 --- a/source/glest_game/game/game.cpp +++ b/source/glest_game/game/game.cpp @@ -3436,7 +3436,7 @@ void Game::toggleTeamColorMarker() { } void Game::saveGame(string name) { - XmlTree xmlTree; + XmlTree xmlTree(XML_XERCES_ENGINE); xmlTree.init("megaglest-saved-game"); XmlNode *rootNode = xmlTree.getRootNode(); @@ -3594,7 +3594,7 @@ void Game::saveGame(string name) { } void Game::loadGame(string name,Program *programPtr,bool isMasterserverMode) { - XmlTree xmlTree(true); + XmlTree xmlTree(XML_RAPIDXML_ENGINE); if(SystemFlags::VERBOSE_MODE_ENABLED) printf("Before load of XML\n"); std::map mapExtraTagReplacementValues; diff --git a/source/shared_lib/include/xml/xml_parser.h b/source/shared_lib/include/xml/xml_parser.h index eb5f0bac..bb1f6424 100644 --- a/source/shared_lib/include/xml/xml_parser.h +++ b/source/shared_lib/include/xml/xml_parser.h @@ -29,8 +29,14 @@ namespace XERCES_CPP_NAMESPACE{ class DOMElement; } -namespace Shared{ namespace Xml{ +namespace Shared { namespace Xml { +enum xml_engine_parser_type { + XML_XERCES_ENGINE = 0, + XML_RAPIDXML_ENGINE = 1 +} ; + +static xml_engine_parser_type DEFAULT_XML_ENGINE = XML_RAPIDXML_ENGINE; const int strSize= 8094; class XmlIo; @@ -86,13 +92,13 @@ class XmlTree{ private: XmlNode *rootNode; string loadPath; - bool wantRapidXmlTree; + xml_engine_parser_type engine_type; private: XmlTree(XmlTree&); void operator =(XmlTree&); public: - XmlTree(bool wantRapidXmlTree = false); + XmlTree(xml_engine_parser_type engine_type = DEFAULT_XML_ENGINE); ~XmlTree(); void init(const string &name); diff --git a/source/shared_lib/sources/xml/xml_parser.cpp b/source/shared_lib/sources/xml/xml_parser.cpp index f98830d5..c3adb91b 100644 --- a/source/shared_lib/sources/xml/xml_parser.cpp +++ b/source/shared_lib/sources/xml/xml_parser.cpp @@ -105,6 +105,7 @@ XmlIo::~XmlIo() { } XmlNode *XmlIo::load(const string &path, std::map mapTagReplacementValues,bool noValidation) { + //printf("Load file using Xerces engine [%s]\n",path.c_str()); try { if(SystemFlags::VERBOSE_MODE_ENABLED) printf("XERCES_FULLVERSIONDOT [%s]\nnoValidation = %d\npath [%s]\n",XERCES_FULLVERSIONDOT,noValidation,path.c_str()); @@ -174,6 +175,8 @@ XmlNode *XmlIo::load(const string &path, std::map mapTagReplaceme } void XmlIo::save(const string &path, const XmlNode *node){ + //printf("Saving file using Xerces engine [%s]\n",path.c_str()); + try{ XMLCh str[strSize]; XMLString::transcode(node->getName().c_str(), str, strSize-1); @@ -362,9 +365,9 @@ void XmlIoRapid::save(const string &path, const XmlNode *node){ // ===================================================== // class XmlTree // ===================================================== -XmlTree::XmlTree(bool wantRapidXmlTree) { +XmlTree::XmlTree(xml_engine_parser_type engine_type) { rootNode= NULL; - this->wantRapidXmlTree = wantRapidXmlTree; + this->engine_type = engine_type; } void XmlTree::init(const string &name){ @@ -394,7 +397,7 @@ void XmlTree::load(const string &path, std::map mapTagReplacement safeMutex.ReleaseLock(); loadPath = path; - if(this->wantRapidXmlTree == false) { + if(this->engine_type == XML_XERCES_ENGINE) { this->rootNode= XmlIo::getInstance().load(path, mapTagReplacementValues, noValidation); } else { @@ -405,7 +408,7 @@ void XmlTree::load(const string &path, std::map mapTagReplacement } void XmlTree::save(const string &path){ - if(this->wantRapidXmlTree == false) { + if(this->engine_type == XML_XERCES_ENGINE) { XmlIo::getInstance().save(path, rootNode); } else {