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

xml::CXMLDocument Class Reference

#include <XMLDocument.h>


Public Member Functions

 CXMLDocument (const std::string &filename)
virtual ~CXMLDocument (void)
CXMLNodeSetevaluateXPathExpression (const std::string &expression, CXMLNameSpaceList *nsList)
bool isFileOpen (void)

Private Member Functions

bool openDocument (const std::string &filename)

Private Attributes

xmlDocPtr m_documentPtr
bool m_fileOpenSuccess


Constructor & Destructor Documentation

xml::CXMLDocument::CXMLDocument const std::string &  filename  ) 
 

Definition at line 18 of file XMLDocument.cpp.

References m_fileOpenSuccess, and openDocument().

00018                                                             {
00019                 if(!this->openDocument(filename)) {
00020                         // TODO: Error Message
00021                         this->m_fileOpenSuccess = false;
00022                 } else {
00023                         this->m_fileOpenSuccess = true;
00024                 }
00025         }

Here is the call graph for this function:

xml::CXMLDocument::~CXMLDocument void   )  [virtual]
 

Definition at line 31 of file XMLDocument.cpp.

00031                                         {
00032                 xmlFreeDoc(this->m_documentPtr);
00033         }


Member Function Documentation

CXMLNodeSet * xml::CXMLDocument::evaluateXPathExpression const std::string &  expression,
CXMLNameSpaceList nsList
 

Definition at line 39 of file XMLDocument.cpp.

References xml::CXMLNameSpaceList::getElementAt(), xml::CXMLNameSpaceList::getSize(), xml::CXMLNameSpace::m_nsHref, and xml::CXMLNameSpace::m_nsPrefix.

Referenced by pge::TextureResourceFile::parseContent(), and pge::SGFFile::parseContent().

00039                                                                                                                  {
00040                 //
00041                 // Variables
00042                 //
00043                 xmlXPathContextPtr xpathContext;
00044                 xmlXPathObjectPtr resultObject;
00045                 CXMLNodeSet *result;
00046                 int i;
00047 
00048 
00049                 // Create XPath context
00050                 xpathContext = xmlXPathNewContext(this->m_documentPtr);
00051                 if(xpathContext == NULL) {
00052                         printf("ERROR: [%s] Could not create XPath context.\n", __FILE__);
00053                         return NULL;
00054                 }
00055 
00056                 if(nsList != NULL) {
00057                         // Register namespaces
00058                         for(i = 0; i < nsList->getSize(); i++) {
00059                                 if(xmlXPathRegisterNs(xpathContext, (xmlChar*)nsList->getElementAt(i).m_nsPrefix.c_str(), (xmlChar*)nsList->getElementAt(i).m_nsHref.c_str()) != 0) {
00060                                         printf("ERROR: [%s] Could not register namespace.\n", __FILE__);
00061                                         return NULL;
00062                                 }
00063                         }
00064                 }
00065 
00066                 // Evaluate XPath expression
00067                 resultObject = xmlXPathEvalExpression((xmlChar*)expression.c_str(), xpathContext);
00068                 if(resultObject == NULL) {
00069                         printf("ERROR: [%s] Could not evaluate XPath expression.\n", __FILE__);
00070                         xmlXPathFreeContext(xpathContext);
00071                         return NULL;
00072                 }
00073 
00074                 result = new CXMLNodeSet(resultObject);
00075 
00076                 // Clean up
00077                 xmlXPathFreeContext(xpathContext);
00078                 return result;
00079         }

Here is the call graph for this function:

bool xml::CXMLDocument::isFileOpen void   ) 
 

Definition at line 85 of file XMLDocument.cpp.

References m_fileOpenSuccess.

Referenced by pge::TextureResourceFile::parseContent(), and pge::SGFFile::SGFFile().

00085                                           {
00086                 return this->m_fileOpenSuccess;
00087         }

bool xml::CXMLDocument::openDocument const std::string &  filename  )  [private]
 

Definition at line 93 of file XMLDocument.cpp.

References m_documentPtr.

Referenced by CXMLDocument().

00093                                                                  {
00094                 // Parse file
00095                 this->m_documentPtr = xmlParseFile(filename.c_str());
00096 
00097                 // Check if everything was ok
00098                 if(this->m_documentPtr == NULL) {
00099                         // TODO: Error message
00100                         return false;
00101                 } else {
00102                         return true;
00103                 }
00104         }


Field Documentation

xmlDocPtr xml::CXMLDocument::m_documentPtr [private]
 

Definition at line 53 of file XMLDocument.h.

Referenced by openDocument().

bool xml::CXMLDocument::m_fileOpenSuccess [private]
 

Definition at line 54 of file XMLDocument.h.

Referenced by CXMLDocument(), and isFileOpen().


The documentation for this class was generated from the following files:
Generated on Mon Oct 16 12:10:02 2006 for Phobosengine by doxygen 1.3.4