mirror of
https://github.com/glest/glest-source.git
synced 2025-10-01 09:56:41 +02:00
- stubbed out use of xerces as no code was using it any longer. Xerces is no longer a requirement to build, we have been using rapidxml for a long time now. For now the MACRO: WANT_XERCES will build Xerces support into th egame, but it is still not used. We will likely deprecate xerces from megaglest soon.
This commit is contained in:
@@ -6419,7 +6419,6 @@ string Game::saveGame(string name, string path) {
|
|||||||
xmlTreeSaveGame.save(replayFile);
|
xmlTreeSaveGame.save(replayFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
//XmlTree xmlTree(XML_XERCES_ENGINE);
|
|
||||||
XmlTree xmlTree;
|
XmlTree xmlTree;
|
||||||
xmlTree.init("megaglest-saved-game");
|
xmlTree.init("megaglest-saved-game");
|
||||||
XmlNode *rootNode = xmlTree.getRootNode();
|
XmlNode *rootNode = xmlTree.getRootNode();
|
||||||
|
@@ -262,8 +262,12 @@ static void cleanupProcessObjects() {
|
|||||||
std::map<string, vector<FileReader<Pixmap3D> const * >* > &list3d = FileReader<Pixmap3D>::getFileReadersMap();
|
std::map<string, vector<FileReader<Pixmap3D> const * >* > &list3d = FileReader<Pixmap3D>::getFileReadersMap();
|
||||||
deleteMapValues(list3d.begin(),list3d.end());
|
deleteMapValues(list3d.begin(),list3d.end());
|
||||||
|
|
||||||
|
#if defined(WANT_XERCES)
|
||||||
|
|
||||||
XmlIo::getInstance().cleanup();
|
XmlIo::getInstance().cleanup();
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
SystemFlags::globalCleanupHTTP();
|
SystemFlags::globalCleanupHTTP();
|
||||||
@@ -4260,10 +4264,14 @@ int glestMain(int argc, char** argv) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(WANT_XERCES)
|
||||||
|
|
||||||
if(hasCommandArgument(argc, argv,GAME_ARGS[GAME_ARG_XERCES_INFO]) == true) {
|
if(hasCommandArgument(argc, argv,GAME_ARGS[GAME_ARG_XERCES_INFO]) == true) {
|
||||||
printf("XERCES version: %s\n", XERCES_FULLVERSIONDOT);
|
printf("XERCES version: %s\n", XERCES_FULLVERSIONDOT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
if( (hasCommandArgument(argc, argv,GAME_ARGS[GAME_ARG_VERSION]) == true ||
|
if( (hasCommandArgument(argc, argv,GAME_ARGS[GAME_ARG_VERSION]) == true ||
|
||||||
hasCommandArgument(argc, argv,GAME_ARGS[GAME_ARG_SDL_INFO]) == true ||
|
hasCommandArgument(argc, argv,GAME_ARGS[GAME_ARG_SDL_INFO]) == true ||
|
||||||
hasCommandArgument(argc, argv,GAME_ARGS[GAME_ARG_LUA_INFO]) == true ||
|
hasCommandArgument(argc, argv,GAME_ARGS[GAME_ARG_LUA_INFO]) == true ||
|
||||||
|
@@ -302,10 +302,15 @@ void MenuStateLoadGame::mouseClick(int x, int y, MouseButton mouseButton){
|
|||||||
if(fileExists(filename) == true) {
|
if(fileExists(filename) == true) {
|
||||||
// Xerces is infinitely slower than rapidxml
|
// Xerces is infinitely slower than rapidxml
|
||||||
xml_engine_parser_type engine_type = XML_RAPIDXML_ENGINE;
|
xml_engine_parser_type engine_type = XML_RAPIDXML_ENGINE;
|
||||||
|
|
||||||
|
#if defined(WANT_XERCES)
|
||||||
|
|
||||||
if(Config::getInstance().getBool("ForceXMLLoadGameUsingXerces","false") == true) {
|
if(Config::getInstance().getBool("ForceXMLLoadGameUsingXerces","false") == true) {
|
||||||
engine_type = XML_XERCES_ENGINE;
|
engine_type = XML_XERCES_ENGINE;
|
||||||
}
|
}
|
||||||
// XmlTree xmlTree(XML_XERCES_ENGINE);
|
|
||||||
|
#endif
|
||||||
|
|
||||||
XmlTree xmlTree(engine_type);
|
XmlTree xmlTree(engine_type);
|
||||||
|
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("Before load of XML\n");
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("Before load of XML\n");
|
||||||
|
@@ -14,8 +14,14 @@
|
|||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <xercesc/util/XercesDefs.hpp>
|
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
|
#if defined(WANT_XERCES)
|
||||||
|
|
||||||
|
#include <xercesc/util/XercesDefs.hpp>
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "rapidxml/rapidxml.hpp"
|
#include "rapidxml/rapidxml.hpp"
|
||||||
#include "data_types.h"
|
#include "data_types.h"
|
||||||
#include "leak_dumper.h"
|
#include "leak_dumper.h"
|
||||||
@@ -23,6 +29,8 @@
|
|||||||
using namespace rapidxml;
|
using namespace rapidxml;
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
#if defined(WANT_XERCES)
|
||||||
|
|
||||||
namespace XERCES_CPP_NAMESPACE{
|
namespace XERCES_CPP_NAMESPACE{
|
||||||
class DOMImplementation;
|
class DOMImplementation;
|
||||||
class DOMDocument;
|
class DOMDocument;
|
||||||
@@ -38,10 +46,15 @@ namespace XERCES_CPP_NAMESPACE{
|
|||||||
|
|
||||||
XERCES_CPP_NAMESPACE_USE
|
XERCES_CPP_NAMESPACE_USE
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace Shared { namespace Xml {
|
namespace Shared { namespace Xml {
|
||||||
|
|
||||||
enum xml_engine_parser_type {
|
enum xml_engine_parser_type {
|
||||||
|
|
||||||
|
#if defined(WANT_XERCES)
|
||||||
XML_XERCES_ENGINE = 0,
|
XML_XERCES_ENGINE = 0,
|
||||||
|
#endif
|
||||||
XML_RAPIDXML_ENGINE = 1
|
XML_RAPIDXML_ENGINE = 1
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
@@ -52,6 +65,7 @@ class XmlTree;
|
|||||||
class XmlNode;
|
class XmlNode;
|
||||||
class XmlAttribute;
|
class XmlAttribute;
|
||||||
|
|
||||||
|
#if defined(WANT_XERCES)
|
||||||
// =====================================================
|
// =====================================================
|
||||||
// class XmlIo
|
// class XmlIo
|
||||||
//
|
//
|
||||||
@@ -93,6 +107,8 @@ public:
|
|||||||
void save(const string &path, const XmlNode *node);
|
void save(const string &path, const XmlNode *node);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
class XmlIoRapid {
|
class XmlIoRapid {
|
||||||
private:
|
private:
|
||||||
static bool initialized;
|
static bool initialized;
|
||||||
@@ -158,7 +174,14 @@ private:
|
|||||||
bool hasChildNoSuper(const string& childName) const;
|
bool hasChildNoSuper(const string& childName) const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
#if defined(WANT_XERCES)
|
||||||
|
|
||||||
XmlNode(XERCES_CPP_NAMESPACE::DOMNode *node, const std::map<string,string> &mapTagReplacementValues);
|
XmlNode(XERCES_CPP_NAMESPACE::DOMNode *node, const std::map<string,string> &mapTagReplacementValues);
|
||||||
|
XERCES_CPP_NAMESPACE::DOMElement *buildElement(XERCES_CPP_NAMESPACE::DOMDocument *document) const;
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
XmlNode(xml_node<> *node, const std::map<string,string> &mapTagReplacementValues);
|
XmlNode(xml_node<> *node, const std::map<string,string> &mapTagReplacementValues);
|
||||||
XmlNode(const string &name);
|
XmlNode(const string &name);
|
||||||
~XmlNode();
|
~XmlNode();
|
||||||
@@ -186,8 +209,6 @@ public:
|
|||||||
|
|
||||||
XmlNode *addChild(const string &name, const string text = "");
|
XmlNode *addChild(const string &name, const string text = "");
|
||||||
XmlAttribute *addAttribute(const string &name, const string &value, const std::map<string,string> &mapTagReplacementValues);
|
XmlAttribute *addAttribute(const string &name, const string &value, const std::map<string,string> &mapTagReplacementValues);
|
||||||
|
|
||||||
XERCES_CPP_NAMESPACE::DOMElement *buildElement(XERCES_CPP_NAMESPACE::DOMDocument *document) const;
|
|
||||||
xml_node<>* buildElement(xml_document<> *document) const;
|
xml_node<>* buildElement(xml_document<> *document) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -208,7 +229,13 @@ private:
|
|||||||
void operator =(XmlAttribute&);
|
void operator =(XmlAttribute&);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
#if defined(WANT_XERCES)
|
||||||
|
|
||||||
XmlAttribute(XERCES_CPP_NAMESPACE::DOMNode *attribute, const std::map<string,string> &mapTagReplacementValues);
|
XmlAttribute(XERCES_CPP_NAMESPACE::DOMNode *attribute, const std::map<string,string> &mapTagReplacementValues);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
XmlAttribute(xml_attribute<> *attribute, const std::map<string,string> &mapTagReplacementValues);
|
XmlAttribute(xml_attribute<> *attribute, const std::map<string,string> &mapTagReplacementValues);
|
||||||
XmlAttribute(const string &name, const string &value, const std::map<string,string> &mapTagReplacementValues);
|
XmlAttribute(const string &name, const string &value, const std::map<string,string> &mapTagReplacementValues);
|
||||||
|
|
||||||
|
@@ -18,9 +18,15 @@
|
|||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
#include "conversion.h"
|
#include "conversion.h"
|
||||||
|
|
||||||
|
#if defined(WANT_XERCES)
|
||||||
|
|
||||||
#include <xercesc/dom/DOM.hpp>
|
#include <xercesc/dom/DOM.hpp>
|
||||||
#include <xercesc/util/PlatformUtils.hpp>
|
#include <xercesc/util/PlatformUtils.hpp>
|
||||||
#include <xercesc/framework/LocalFileFormatTarget.hpp>
|
#include <xercesc/framework/LocalFileFormatTarget.hpp>
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include "properties.h"
|
#include "properties.h"
|
||||||
#include "platform_common.h"
|
#include "platform_common.h"
|
||||||
@@ -30,8 +36,12 @@
|
|||||||
#include "rapidxml/rapidxml_print.hpp"
|
#include "rapidxml/rapidxml_print.hpp"
|
||||||
#include "leak_dumper.h"
|
#include "leak_dumper.h"
|
||||||
|
|
||||||
|
#if defined(WANT_XERCES)
|
||||||
|
|
||||||
XERCES_CPP_NAMESPACE_USE
|
XERCES_CPP_NAMESPACE_USE
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace Shared::PlatformCommon;
|
using namespace Shared::PlatformCommon;
|
||||||
|
|
||||||
@@ -39,6 +49,15 @@ namespace Shared { namespace Xml {
|
|||||||
|
|
||||||
using namespace Util;
|
using namespace Util;
|
||||||
|
|
||||||
|
// =====================================================
|
||||||
|
// class XmlIo
|
||||||
|
// =====================================================
|
||||||
|
bool XmlIoRapid::initialized= false;
|
||||||
|
|
||||||
|
#if defined(WANT_XERCES)
|
||||||
|
|
||||||
|
bool XmlIo::initialized = false;
|
||||||
|
|
||||||
// =====================================================
|
// =====================================================
|
||||||
// class ErrorHandler
|
// class ErrorHandler
|
||||||
// =====================================================
|
// =====================================================
|
||||||
@@ -57,13 +76,6 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// =====================================================
|
|
||||||
// class XmlIo
|
|
||||||
// =====================================================
|
|
||||||
|
|
||||||
bool XmlIo::initialized = false;
|
|
||||||
bool XmlIoRapid::initialized= false;
|
|
||||||
|
|
||||||
XmlIo::XmlIo() : parser(NULL) {
|
XmlIo::XmlIo() : parser(NULL) {
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
@@ -285,6 +297,8 @@ void XmlIo::save(const string &path, const XmlNode *node){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
// =====================================================
|
// =====================================================
|
||||||
// class XmlIoRapid
|
// class XmlIoRapid
|
||||||
// =====================================================
|
// =====================================================
|
||||||
@@ -495,8 +509,10 @@ XmlTree::XmlTree(xml_engine_parser_type engine_type) {
|
|||||||
rootNode= NULL;
|
rootNode= NULL;
|
||||||
|
|
||||||
switch(engine_type) {
|
switch(engine_type) {
|
||||||
|
#if defined(WANT_XERCES)
|
||||||
case XML_XERCES_ENGINE:
|
case XML_XERCES_ENGINE:
|
||||||
break;
|
break;
|
||||||
|
#endif
|
||||||
case XML_RAPIDXML_ENGINE:
|
case XML_RAPIDXML_ENGINE:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -542,21 +558,28 @@ void XmlTree::load(const string &path, const std::map<string,string> &mapTagRepl
|
|||||||
|
|
||||||
loadPath = path;
|
loadPath = path;
|
||||||
|
|
||||||
|
#if defined(WANT_XERCES)
|
||||||
if(this->engine_type == XML_XERCES_ENGINE) {
|
if(this->engine_type == XML_XERCES_ENGINE) {
|
||||||
this->rootNode= XmlIo::getInstance().load(path, mapTagReplacementValues, noValidation,skipStackTrace);
|
this->rootNode= XmlIo::getInstance().load(path, mapTagReplacementValues, noValidation,skipStackTrace);
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
|
#endif
|
||||||
|
{
|
||||||
this->rootNode= XmlIoRapid::getInstance().load(path, mapTagReplacementValues, noValidation,skipStackTrace);
|
this->rootNode= XmlIoRapid::getInstance().load(path, mapTagReplacementValues, noValidation,skipStackTrace);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] about to load [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,path.c_str());
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] about to load [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,path.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void XmlTree::save(const string &path){
|
void XmlTree::save(const string &path) {
|
||||||
|
|
||||||
|
#if defined(WANT_XERCES)
|
||||||
if(this->engine_type == XML_XERCES_ENGINE) {
|
if(this->engine_type == XML_XERCES_ENGINE) {
|
||||||
XmlIo::getInstance().save(path, rootNode);
|
XmlIo::getInstance().save(path, rootNode);
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
|
#endif
|
||||||
|
{
|
||||||
XmlIoRapid::getInstance().save(path, rootNode);
|
XmlIoRapid::getInstance().save(path, rootNode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -587,6 +610,8 @@ XmlTree::~XmlTree() {
|
|||||||
// class XmlNode
|
// class XmlNode
|
||||||
// =====================================================
|
// =====================================================
|
||||||
|
|
||||||
|
#if defined(WANT_XERCES)
|
||||||
|
|
||||||
XmlNode::XmlNode(DOMNode *node, const std::map<string,string> &mapTagReplacementValues): superNode(NULL) {
|
XmlNode::XmlNode(DOMNode *node, const std::map<string,string> &mapTagReplacementValues): superNode(NULL) {
|
||||||
if(node == NULL || node->getNodeName() == NULL) {
|
if(node == NULL || node->getNodeName() == NULL) {
|
||||||
throw megaglest_runtime_error("XML structure seems to be corrupt!");
|
throw megaglest_runtime_error("XML structure seems to be corrupt!");
|
||||||
@@ -634,6 +659,8 @@ XmlNode::XmlNode(DOMNode *node, const std::map<string,string> &mapTagReplacement
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
XmlNode::XmlNode(xml_node<> *node, const std::map<string,string> &mapTagReplacementValues) : superNode(NULL) {
|
XmlNode::XmlNode(xml_node<> *node, const std::map<string,string> &mapTagReplacementValues) : superNode(NULL) {
|
||||||
if(node == NULL || node->name() == NULL) {
|
if(node == NULL || node->name() == NULL) {
|
||||||
throw megaglest_runtime_error("XML structure seems to be corrupt!");
|
throw megaglest_runtime_error("XML structure seems to be corrupt!");
|
||||||
@@ -852,6 +879,8 @@ XmlAttribute *XmlNode::addAttribute(const string &name, const string &value, con
|
|||||||
return attr;
|
return attr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(WANT_XERCES)
|
||||||
|
|
||||||
DOMElement *XmlNode::buildElement(XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument *document) const{
|
DOMElement *XmlNode::buildElement(XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument *document) const{
|
||||||
XMLCh str[strSize];
|
XMLCh str[strSize];
|
||||||
XMLString::transcode(name.c_str(), str, strSize-1);
|
XMLString::transcode(name.c_str(), str, strSize-1);
|
||||||
@@ -875,6 +904,8 @@ DOMElement *XmlNode::buildElement(XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument *do
|
|||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
xml_node<>* XmlNode::buildElement(xml_document<> *document) const {
|
xml_node<>* XmlNode::buildElement(xml_document<> *document) const {
|
||||||
xml_node<>* node = document->allocate_node(node_element, document->allocate_string(name.c_str()));
|
xml_node<>* node = document->allocate_node(node_element, document->allocate_string(name.c_str()));
|
||||||
|
|
||||||
@@ -913,6 +944,8 @@ string XmlNode::getTreeString() const {
|
|||||||
// class XmlAttribute
|
// class XmlAttribute
|
||||||
// =====================================================
|
// =====================================================
|
||||||
|
|
||||||
|
#if defined(WANT_XERCES)
|
||||||
|
|
||||||
XmlAttribute::XmlAttribute(DOMNode *attribute, const std::map<string,string> &mapTagReplacementValues) {
|
XmlAttribute::XmlAttribute(DOMNode *attribute, const std::map<string,string> &mapTagReplacementValues) {
|
||||||
if(attribute == NULL || attribute->getNodeName() == NULL) {
|
if(attribute == NULL || attribute->getNodeName() == NULL) {
|
||||||
throw megaglest_runtime_error("XML attribute seems to be corrupt!");
|
throw megaglest_runtime_error("XML attribute seems to be corrupt!");
|
||||||
@@ -932,6 +965,8 @@ XmlAttribute::XmlAttribute(DOMNode *attribute, const std::map<string,string> &ma
|
|||||||
name= str;
|
name= str;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
XmlAttribute::XmlAttribute(xml_attribute<> *attribute, const std::map<string,string> &mapTagReplacementValues) {
|
XmlAttribute::XmlAttribute(xml_attribute<> *attribute, const std::map<string,string> &mapTagReplacementValues) {
|
||||||
if(attribute == NULL || attribute->name() == NULL) {
|
if(attribute == NULL || attribute->name() == NULL) {
|
||||||
throw megaglest_runtime_error("XML attribute seems to be corrupt!");
|
throw megaglest_runtime_error("XML attribute seems to be corrupt!");
|
||||||
|
@@ -15,10 +15,15 @@
|
|||||||
#include "xml_parser.h"
|
#include "xml_parser.h"
|
||||||
#include "platform_util.h"
|
#include "platform_util.h"
|
||||||
|
|
||||||
|
#if defined(WANT_XERCES)
|
||||||
|
|
||||||
#include <xercesc/dom/DOM.hpp>
|
#include <xercesc/dom/DOM.hpp>
|
||||||
|
|
||||||
//#include <xercesc/util/PlatformUtils.hpp>
|
//#include <xercesc/util/PlatformUtils.hpp>
|
||||||
//#include <xercesc/framework/LocalFileFormatTarget.hpp>
|
//#include <xercesc/framework/LocalFileFormatTarget.hpp>
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
#include <io.h>
|
#include <io.h>
|
||||||
#else
|
#else
|
||||||
@@ -72,6 +77,8 @@ public:
|
|||||||
};
|
};
|
||||||
//
|
//
|
||||||
|
|
||||||
|
#if defined(WANT_XERCES)
|
||||||
|
|
||||||
//
|
//
|
||||||
// Tests for XmlIo
|
// Tests for XmlIo
|
||||||
//
|
//
|
||||||
@@ -148,6 +155,8 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
//
|
//
|
||||||
// Tests for XmlIoRapid
|
// Tests for XmlIoRapid
|
||||||
//
|
//
|
||||||
@@ -242,12 +251,26 @@ class XmlTreeTest : public CppUnit::TestFixture {
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
#if defined(WANT_XERCES)
|
||||||
|
|
||||||
void test_invalid_xml_engine_lowerbound() {
|
void test_invalid_xml_engine_lowerbound() {
|
||||||
xml_engine_parser_type testType = static_cast<xml_engine_parser_type>(XML_XERCES_ENGINE - 1);
|
xml_engine_parser_type testType = static_cast<xml_engine_parser_type>(XML_XERCES_ENGINE - 1);
|
||||||
if((int)testType == (int)(XML_XERCES_ENGINE - 1)) {
|
if((int)testType == (int)(XML_XERCES_ENGINE - 1)) {
|
||||||
XmlTree xml(testType);
|
XmlTree xml(testType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
void test_invalid_xml_engine_lowerbound() {
|
||||||
|
xml_engine_parser_type testType = static_cast<xml_engine_parser_type>(XML_RAPIDXML_ENGINE - 1);
|
||||||
|
if((int)testType == (int)(XML_RAPIDXML_ENGINE - 1)) {
|
||||||
|
XmlTree xml(testType);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
void test_invalid_xml_engine_upperbound() {
|
void test_invalid_xml_engine_upperbound() {
|
||||||
xml_engine_parser_type testType = static_cast<xml_engine_parser_type>(XML_RAPIDXML_ENGINE + 1);
|
xml_engine_parser_type testType = static_cast<xml_engine_parser_type>(XML_RAPIDXML_ENGINE + 1);
|
||||||
if((int)testType == (int)(XML_RAPIDXML_ENGINE + 1)) {
|
if((int)testType == (int)(XML_RAPIDXML_ENGINE + 1)) {
|
||||||
@@ -301,9 +324,14 @@ class XmlNodeTest : public CppUnit::TestFixture {
|
|||||||
// Register the suite of tests for this fixture
|
// Register the suite of tests for this fixture
|
||||||
CPPUNIT_TEST_SUITE( XmlNodeTest );
|
CPPUNIT_TEST_SUITE( XmlNodeTest );
|
||||||
|
|
||||||
|
#if defined(WANT_XERCES)
|
||||||
|
|
||||||
CPPUNIT_TEST_EXCEPTION( test_null_xerces_node, megaglest_runtime_error );
|
CPPUNIT_TEST_EXCEPTION( test_null_xerces_node, megaglest_runtime_error );
|
||||||
CPPUNIT_TEST_EXCEPTION( test_null_rapidxml_node, megaglest_runtime_error );
|
|
||||||
CPPUNIT_TEST( test_valid_xerces_node );
|
CPPUNIT_TEST( test_valid_xerces_node );
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
CPPUNIT_TEST_EXCEPTION( test_null_rapidxml_node, megaglest_runtime_error );
|
||||||
CPPUNIT_TEST( test_valid_named_node );
|
CPPUNIT_TEST( test_valid_named_node );
|
||||||
CPPUNIT_TEST( test_child_nodes );
|
CPPUNIT_TEST( test_child_nodes );
|
||||||
CPPUNIT_TEST( test_node_attributes );
|
CPPUNIT_TEST( test_node_attributes );
|
||||||
@@ -313,6 +341,8 @@ class XmlNodeTest : public CppUnit::TestFixture {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
#if defined(WANT_XERCES)
|
||||||
|
|
||||||
class XmlIoMock : public XmlIo {
|
class XmlIoMock : public XmlIo {
|
||||||
protected:
|
protected:
|
||||||
virtual void releaseDOMParser() { }
|
virtual void releaseDOMParser() { }
|
||||||
@@ -329,18 +359,18 @@ private:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
#if defined(WANT_XERCES)
|
||||||
|
|
||||||
void test_null_xerces_node() {
|
void test_null_xerces_node() {
|
||||||
XERCES_CPP_NAMESPACE::DOMNode *node = NULL;
|
XERCES_CPP_NAMESPACE::DOMNode *node = NULL;
|
||||||
const std::map<string,string> mapTagReplacementValues;
|
const std::map<string,string> mapTagReplacementValues;
|
||||||
XmlNode(node, mapTagReplacementValues);
|
XmlNode(node, mapTagReplacementValues);
|
||||||
}
|
}
|
||||||
void test_null_rapidxml_node() {
|
|
||||||
xml_node<> *node = NULL;
|
|
||||||
const std::map<string,string> mapTagReplacementValues;
|
|
||||||
XmlNode(node, mapTagReplacementValues);
|
|
||||||
}
|
|
||||||
void test_valid_xerces_node() {
|
void test_valid_xerces_node() {
|
||||||
const string test_filename = "xml_test_valid.xml";
|
const string test_filename = "xml_test_valid.xml";
|
||||||
createValidXMLTestFile(test_filename);
|
createValidXMLTestFile(test_filename);
|
||||||
@@ -360,6 +390,14 @@ public:
|
|||||||
CPPUNIT_ASSERT( node.hasAttribute("mytest-attribute") == true );
|
CPPUNIT_ASSERT( node.hasAttribute("mytest-attribute") == true );
|
||||||
CPPUNIT_ASSERT( node.hasChild("menu-background-model") == true );
|
CPPUNIT_ASSERT( node.hasChild("menu-background-model") == true );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void test_null_rapidxml_node() {
|
||||||
|
xml_node<> *node = NULL;
|
||||||
|
const std::map<string,string> mapTagReplacementValues;
|
||||||
|
XmlNode(node, mapTagReplacementValues);
|
||||||
|
}
|
||||||
void test_valid_named_node() {
|
void test_valid_named_node() {
|
||||||
XmlNode node("testNode");
|
XmlNode node("testNode");
|
||||||
|
|
||||||
@@ -435,6 +473,7 @@ public:
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#if defined(WANT_XERCES)
|
||||||
//
|
//
|
||||||
// Tests for XmlAttribute
|
// Tests for XmlAttribute
|
||||||
//
|
//
|
||||||
@@ -443,6 +482,7 @@ class XmlAttributeTest : public CppUnit::TestFixture {
|
|||||||
CPPUNIT_TEST_SUITE( XmlAttributeTest );
|
CPPUNIT_TEST_SUITE( XmlAttributeTest );
|
||||||
|
|
||||||
CPPUNIT_TEST_EXCEPTION( test_null_xerces_attribute, megaglest_runtime_error );
|
CPPUNIT_TEST_EXCEPTION( test_null_xerces_attribute, megaglest_runtime_error );
|
||||||
|
|
||||||
CPPUNIT_TEST( test_node_attributes );
|
CPPUNIT_TEST( test_node_attributes );
|
||||||
CPPUNIT_TEST_EXCEPTION( test_node_attributes_restricted, megaglest_runtime_error );
|
CPPUNIT_TEST_EXCEPTION( test_node_attributes_restricted, megaglest_runtime_error );
|
||||||
CPPUNIT_TEST_EXCEPTION( test_node_attributes_int_outofrange, megaglest_runtime_error );
|
CPPUNIT_TEST_EXCEPTION( test_node_attributes_int_outofrange, megaglest_runtime_error );
|
||||||
@@ -578,11 +618,19 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
// Test Suite Registrations
|
// Test Suite Registrations
|
||||||
CPPUNIT_TEST_SUITE_REGISTRATION( XmlIoTest );
|
|
||||||
CPPUNIT_TEST_SUITE_REGISTRATION( XmlIoRapidTest );
|
CPPUNIT_TEST_SUITE_REGISTRATION( XmlIoRapidTest );
|
||||||
CPPUNIT_TEST_SUITE_REGISTRATION( XmlTreeTest );
|
CPPUNIT_TEST_SUITE_REGISTRATION( XmlTreeTest );
|
||||||
CPPUNIT_TEST_SUITE_REGISTRATION( XmlNodeTest );
|
CPPUNIT_TEST_SUITE_REGISTRATION( XmlNodeTest );
|
||||||
|
|
||||||
|
#if defined(WANT_XERCES)
|
||||||
|
|
||||||
|
CPPUNIT_TEST_SUITE_REGISTRATION( XmlIoTest );
|
||||||
CPPUNIT_TEST_SUITE_REGISTRATION( XmlAttributeTest );
|
CPPUNIT_TEST_SUITE_REGISTRATION( XmlAttributeTest );
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
//
|
//
|
||||||
|
Reference in New Issue
Block a user