- ALL XML loading will default to rapidxml, we now ONLY use xerces for saving the game (until i get time to implement xml save using rapidxml)

This commit is contained in:
Mark Vejvoda 2012-03-14 22:48:46 +00:00
parent 4bd6b53f9d
commit 7425dc8fdf
3 changed files with 18 additions and 9 deletions

View File

@ -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<string,string> mapExtraTagReplacementValues;

View File

@ -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);

View File

@ -105,6 +105,7 @@ XmlIo::~XmlIo() {
}
XmlNode *XmlIo::load(const string &path, std::map<string,string> 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<string,string> 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<string,string> 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<string,string> mapTagReplacement
}
void XmlTree::save(const string &path){
if(this->wantRapidXmlTree == false) {
if(this->engine_type == XML_XERCES_ENGINE) {
XmlIo::getInstance().save(path, rootNode);
}
else {