Main Page | Namespace List | Class Hierarchy | Alphabetical List | Data Structures | File List | Data Fields | Globals | Related Pages

CSXMLHelper Class Reference

#include <CSXMLHelperTinyXML.h>

Inheritance diagram for CSXMLHelper:

ErrorHandler

Public Member Functions

 CSXMLHelper (const std::string &xmlFilename, const std::string &contextNode)
virtual ~CSXMLHelper ()
virtual std::string getType ()
int getError (void)
std::string getErrorMessage (void)
int getInt (const std::string &xpath)
std::string getString (const std::string &xpath)
 CSXMLHelper (const std::string &xmlFilename, const std::string &contextNode)
virtual ~CSXMLHelper ()
virtual std::string getType ()
int getError (void)
std::string getErrorMessage (void)
int getInt (const std::string &xpath)
std::string getString (const std::string &xpath)
void warning (const SAXParseException &toCatch)
void error (const SAXParseException &toCatch)
void fatalError (const SAXParseException &toCatch)
void resetErrors ()
 CSXMLHelper (const std::string &xmlFilename, const std::string &contextNode)
virtual ~CSXMLHelper ()
virtual std::string getType ()
int getError (void)
std::string getErrorMessage (void)
int getInt (const std::string &xpath)
std::string getString (const std::string &xpath)
void warning (const SAXParseException &toCatch)
void error (const SAXParseException &toCatch)
void fatalError (const SAXParseException &toCatch)
void resetErrors ()

Static Public Attributes

const char * CLASS = "CSXMLHelper"
const char * CLASS
const char * CLASS

Constructor & Destructor Documentation

CSXMLHelper::CSXMLHelper const std::string &  xmlFilename,
const std::string &  contextNode
 

Definition at line 103 of file CSXMLHelperTinyXML.cpp.

References CSXML_CONTEXT_LOADING_ERROR, CSXML_DOCUMENT_LOADING_ERROR, and CSXML_OK.

00104 {
00105     static char *functionName="CSXMLHelper";
00106     mError = CSXML_OK;
00107     mXMLdoc = 0;
00108 
00109     mXMLdoc = new TiXmlDocument(xmlFilename);
00110     mXMLdoc->setIgnoreNoEndTag(false);
00111     mXMLdoc->SetCondenseWhiteSpace(true); 
00112 
00113     if (!mXMLdoc)
00114     {
00115         mError = CSXML_CONTEXT_LOADING_ERROR;
00116         std::string errorMessageString;
00117         errorMessageString = std::string("Error - while loading context \"" + contextNode +"\"!");
00118         mErrorMessageString = mErrorMessageString + "\n"+ errorMessageString;
00119     }
00120 
00121     addEntitiesFromFile(xmlFilename, "");
00122 
00123     if (!mXMLdoc->LoadFile() )
00124     {
00125         mError = CSXML_DOCUMENT_LOADING_ERROR;
00126         std::string errorMessageString;
00127         errorMessageString = std::string("Error - while loading document \"" + xmlFilename +"\"!");
00128         mErrorMessageString = mErrorMessageString + "\n"+ errorMessageString;
00129         return;         
00130     }
00131     mXMLsource = mXMLdoc->FirstChildElement(contextNode);
00132 }

CSXMLHelper::~CSXMLHelper  )  [virtual]
 

Definition at line 134 of file CSXMLHelperTinyXML.cpp.

References LOG_ENTER, and LOG_EXIT.

00135 {
00136     static char *functionName="~CSXMLHelper";
00137     LOG_ENTER
00138     delete (mXMLdoc);
00139     mXMLdoc = 0;
00140     mXMLsource = 0;
00141     mEntityMap.clear();
00142     LOG_EXIT
00143 }

CSXMLHelper::CSXMLHelper const std::string &  xmlFilename,
const std::string &  contextNode
 

virtual CSXMLHelper::~CSXMLHelper  )  [virtual]
 

CSXMLHelper::CSXMLHelper const std::string &  xmlFilename,
const std::string &  contextNode
 

virtual CSXMLHelper::~CSXMLHelper  )  [virtual]
 


Member Function Documentation

virtual std::string CSXMLHelper::getType  )  [inline, virtual]
 

Definition at line 75 of file CSXMLHelperTinyXML.h.

References CLASS.

00075 {return (std::string) CLASS;}

int CSXMLHelper::getError void   ) 
 

Definition at line 491 of file CSXMLHelperTinyXML.cpp.

Referenced by CSBitmapLoader::create(), CSGame::loadGameData(), and CSGame::loadLevelData().

00492 {
00493     return mError;
00494 }

std::string CSXMLHelper::getErrorMessage void   ) 
 

Definition at line 496 of file CSXMLHelperTinyXML.cpp.

Referenced by CSBitmapLoader::create(), CSGame::loadGameData(), and CSGame::loadLevelData().

00497 {
00498     return mErrorMessageString;
00499 }

int CSXMLHelper::getInt const std::string &  xpath  ) 
 

Definition at line 145 of file CSXMLHelperTinyXML.cpp.

References CSXML_XPATH_ERROR, LOG_DEBUG_MESSAGE, LOG_ENTER, LOG_EXIT, and LOG_WARN_MESSAGE.

Referenced by CSBitmapLoader::create(), CSGame::loadGameData(), and CSGame::loadLevelData().

00146 {
00147     static char *functionName="getInt";
00148     LOG_ENTER
00149     int ret = 0;
00150     if (mError != 0)
00151     {
00152         LOG_WARN_MESSAGE("Error")
00153         LOG_EXIT
00154         throw "error";
00155     }
00156     try
00157     {
00158         TiXmlNode *node = getXPathResult(xpath);
00159         if (node == 0)
00160         {
00161             LOG_EXIT
00162             return 0;
00163         }
00164         if (node->Type() == TiXmlNode::FUNCTION)
00165         {
00166             ret = toInt(*node);
00167             delete node;
00168             node = 0;
00169         }
00170         else
00171         {
00172             TiXmlText *element = node->ToText();
00173             if (element == 0)
00174             {
00175                 LOG_DEBUG_MESSAGE("XPath \"" + xpath + "\" doesn't represent a text element!") 
00176             }
00177             ret = toInt(*element);
00178         }
00179     }
00180     catch(...)
00181     {
00182         mError = CSXML_XPATH_ERROR;
00183         std::string errorMessageString;
00184         errorMessageString = "tinyXMLException";
00185         mErrorMessageString = mErrorMessageString + "\n"+ errorMessageString;
00186         LOG_WARN_MESSAGE(mErrorMessageString)
00187         LOG_EXIT
00188         throw "error";
00189     }
00190     LOG_EXIT
00191     return ret;
00192 }

std::string CSXMLHelper::getString const std::string &  xpath  ) 
 

Definition at line 194 of file CSXMLHelperTinyXML.cpp.

References CSXML_XPATH_ERROR, LOG_DEBUG_MESSAGE, LOG_ENTER, LOG_EXIT, and LOG_WARN_MESSAGE.

Referenced by CSBitmapLoader::create(), CSGame::loadGameData(), and CSGame::loadLevelData().

00195 {
00196     static char *functionName="getString";
00197     LOG_ENTER
00198     std::string cstr;
00199     if (mError != 0)
00200     {
00201         LOG_WARN_MESSAGE("XML! Not properly initialized!")
00202         LOG_EXIT
00203         throw std::string("XML! Not properly initialized!");
00204     }
00205     try
00206     {
00207         TiXmlNode *node = getXPathResult(xpath);
00208         if (node == 0)
00209         {
00210             LOG_EXIT
00211             return "";
00212         }
00213         if (node->Type() == TiXmlNode::FUNCTION)
00214         {
00215             cstr = toAscii(*node);
00216             delete node;
00217             node = 0;
00218         }
00219         else
00220         {
00221             TiXmlText *element = node->ToText();
00222             if (element == 0)
00223             {
00224                 LOG_DEBUG_MESSAGE("XPath \"" + xpath + "\" doesn't represent a text element!") 
00225             }
00226             cstr = toAscii(*element);
00227         }
00228         
00229     }
00230     catch(...)
00231     {
00232         mError = CSXML_XPATH_ERROR;
00233         std::string errorMessageString;
00234         errorMessageString = "tinyXMLException";
00235         mErrorMessageString = mErrorMessageString + "\n"+ errorMessageString;
00236         LOG_WARN_MESSAGE(mErrorMessageString)
00237         LOG_EXIT
00238         throw "error";
00239     }
00240     LOG_EXIT
00241     return cstr;
00242 }

virtual std::string CSXMLHelper::getType  )  [inline, virtual]
 

Definition at line 41 of file CSXMLHelperTinyXPath.h.

References CLASS.

00041 {return (std::string) CLASS;}

int CSXMLHelper::getError void   ) 
 

std::string CSXMLHelper::getErrorMessage void   ) 
 

int CSXMLHelper::getInt const std::string &  xpath  ) 
 

std::string CSXMLHelper::getString const std::string &  xpath  ) 
 

void CSXMLHelper::warning const SAXParseException &  toCatch  ) 
 

void CSXMLHelper::error const SAXParseException &  toCatch  ) 
 

void CSXMLHelper::fatalError const SAXParseException &  toCatch  ) 
 

void CSXMLHelper::resetErrors  ) 
 

virtual std::string CSXMLHelper::getType  )  [inline, virtual]
 

Definition at line 56 of file CSXMLHelperXalan.h.

References CLASS.

00056 {return (std::string) CLASS;}

int CSXMLHelper::getError void   ) 
 

std::string CSXMLHelper::getErrorMessage void   ) 
 

int CSXMLHelper::getInt const std::string &  xpath  ) 
 

std::string CSXMLHelper::getString const std::string &  xpath  ) 
 

void CSXMLHelper::warning const SAXParseException &  toCatch  ) 
 

void CSXMLHelper::error const SAXParseException &  toCatch  ) 
 

void CSXMLHelper::fatalError const SAXParseException &  toCatch  ) 
 

void CSXMLHelper::resetErrors  ) 
 


Field Documentation

const char * CSXMLHelper::CLASS = "CSXMLHelper" [static]
 

Definition at line 11 of file CSXMLHelperTinyXML.cpp.

Referenced by getType().

const char* CSXMLHelper::CLASS [static]
 

Definition at line 40 of file CSXMLHelperTinyXPath.h.

const char* CSXMLHelper::CLASS [static]
 

Definition at line 55 of file CSXMLHelperXalan.h.


Generated on Wed Jul 14 00:45:28 2004 for CSLib by doxygen 1.3.6