mirror of
https://github.com/glest/glest-source.git
synced 2025-08-11 02:43:57 +02:00
- 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:
@@ -3436,7 +3436,7 @@ void Game::toggleTeamColorMarker() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Game::saveGame(string name) {
|
void Game::saveGame(string name) {
|
||||||
XmlTree xmlTree;
|
XmlTree xmlTree(XML_XERCES_ENGINE);
|
||||||
xmlTree.init("megaglest-saved-game");
|
xmlTree.init("megaglest-saved-game");
|
||||||
XmlNode *rootNode = xmlTree.getRootNode();
|
XmlNode *rootNode = xmlTree.getRootNode();
|
||||||
|
|
||||||
@@ -3594,7 +3594,7 @@ void Game::saveGame(string name) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Game::loadGame(string name,Program *programPtr,bool isMasterserverMode) {
|
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");
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("Before load of XML\n");
|
||||||
std::map<string,string> mapExtraTagReplacementValues;
|
std::map<string,string> mapExtraTagReplacementValues;
|
||||||
|
@@ -29,8 +29,14 @@ namespace XERCES_CPP_NAMESPACE{
|
|||||||
class DOMElement;
|
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;
|
const int strSize= 8094;
|
||||||
|
|
||||||
class XmlIo;
|
class XmlIo;
|
||||||
@@ -86,13 +92,13 @@ class XmlTree{
|
|||||||
private:
|
private:
|
||||||
XmlNode *rootNode;
|
XmlNode *rootNode;
|
||||||
string loadPath;
|
string loadPath;
|
||||||
bool wantRapidXmlTree;
|
xml_engine_parser_type engine_type;
|
||||||
private:
|
private:
|
||||||
XmlTree(XmlTree&);
|
XmlTree(XmlTree&);
|
||||||
void operator =(XmlTree&);
|
void operator =(XmlTree&);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
XmlTree(bool wantRapidXmlTree = false);
|
XmlTree(xml_engine_parser_type engine_type = DEFAULT_XML_ENGINE);
|
||||||
~XmlTree();
|
~XmlTree();
|
||||||
|
|
||||||
void init(const string &name);
|
void init(const string &name);
|
||||||
|
@@ -105,6 +105,7 @@ XmlIo::~XmlIo() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
XmlNode *XmlIo::load(const string &path, std::map<string,string> mapTagReplacementValues,bool noValidation) {
|
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 {
|
try {
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("XERCES_FULLVERSIONDOT [%s]\nnoValidation = %d\npath [%s]\n",XERCES_FULLVERSIONDOT,noValidation,path.c_str());
|
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){
|
void XmlIo::save(const string &path, const XmlNode *node){
|
||||||
|
//printf("Saving file using Xerces engine [%s]\n",path.c_str());
|
||||||
|
|
||||||
try{
|
try{
|
||||||
XMLCh str[strSize];
|
XMLCh str[strSize];
|
||||||
XMLString::transcode(node->getName().c_str(), str, strSize-1);
|
XMLString::transcode(node->getName().c_str(), str, strSize-1);
|
||||||
@@ -362,9 +365,9 @@ void XmlIoRapid::save(const string &path, const XmlNode *node){
|
|||||||
// =====================================================
|
// =====================================================
|
||||||
// class XmlTree
|
// class XmlTree
|
||||||
// =====================================================
|
// =====================================================
|
||||||
XmlTree::XmlTree(bool wantRapidXmlTree) {
|
XmlTree::XmlTree(xml_engine_parser_type engine_type) {
|
||||||
rootNode= NULL;
|
rootNode= NULL;
|
||||||
this->wantRapidXmlTree = wantRapidXmlTree;
|
this->engine_type = engine_type;
|
||||||
}
|
}
|
||||||
|
|
||||||
void XmlTree::init(const string &name){
|
void XmlTree::init(const string &name){
|
||||||
@@ -394,7 +397,7 @@ void XmlTree::load(const string &path, std::map<string,string> mapTagReplacement
|
|||||||
safeMutex.ReleaseLock();
|
safeMutex.ReleaseLock();
|
||||||
|
|
||||||
loadPath = path;
|
loadPath = path;
|
||||||
if(this->wantRapidXmlTree == false) {
|
if(this->engine_type == XML_XERCES_ENGINE) {
|
||||||
this->rootNode= XmlIo::getInstance().load(path, mapTagReplacementValues, noValidation);
|
this->rootNode= XmlIo::getInstance().load(path, mapTagReplacementValues, noValidation);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -405,7 +408,7 @@ void XmlTree::load(const string &path, std::map<string,string> mapTagReplacement
|
|||||||
}
|
}
|
||||||
|
|
||||||
void XmlTree::save(const string &path){
|
void XmlTree::save(const string &path){
|
||||||
if(this->wantRapidXmlTree == false) {
|
if(this->engine_type == XML_XERCES_ENGINE) {
|
||||||
XmlIo::getInstance().save(path, rootNode);
|
XmlIo::getInstance().save(path, rootNode);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
Reference in New Issue
Block a user