mirror of
https://github.com/glest/glest-source.git
synced 2025-08-29 19:00:07 +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:
@@ -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);
|
||||
|
@@ -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 {
|
||||
|
Reference in New Issue
Block a user