#include <XmlDocument.h>
Public Member Functions | |
XmlDocument (const std::string &filename, const std::string &verify_ns="", const std::string &verify_root="") | |
virtual | ~XmlDocument () |
bool | IsOk () |
Document parse successful. | |
operator xmlDocPtr () | |
Protected Member Functions | |
XmlDocument (const XmlDocument &) | |
Private Member Functions | |
XmlDocument & | operator= (const XmlDocument &) |
Private Attributes | |
xmlDocPtr | m_doc |
bool | m_ok |
Definition at line 32 of file XmlDocument.h.
Xmlw::XmlDocument::XmlDocument | ( | const std::string & | filename, | |
const std::string & | verify_ns = "" , |
|||
const std::string & | verify_root = "" | |||
) |
Definition at line 28 of file XmlDocument.cpp.
00029 : m_doc(NULL) 00030 , m_ok(false) 00031 { 00032 xmlNodePtr cur; 00033 xmlNsPtr ns; 00034 00035 if (!(m_doc = xmlParseFile(filename.c_str() ))) 00036 { 00037 throw XmlException("Parse of file failed: " + filename); 00038 } 00039 if (!(cur = xmlDocGetRootElement(m_doc))) 00040 { 00041 xmlFreeDoc(m_doc); 00042 m_doc = NULL; 00043 throw XmlException("Document is empty: " + filename); 00044 } 00045 if (verify_ns.size()) 00046 { 00047 if (!(ns = xmlSearchNsByHref(m_doc, cur, (const xmlChar *) verify_ns.c_str() ))) 00048 { 00049 xmlFreeDoc(m_doc); 00050 m_doc = NULL; 00051 throw XmlException("Document namespace != " + verify_ns); 00052 } 00053 } 00054 if (verify_root.size()) 00055 { 00056 if (xmlStrcmp(cur -> name, (const xmlChar *) verify_root.c_str() )) 00057 { 00058 xmlFreeDoc(m_doc); 00059 m_doc = NULL; 00060 throw XmlException("Document root != " + verify_root); 00061 } 00062 } 00063 m_ok = true; 00064 }
Xmlw::XmlDocument::~XmlDocument | ( | ) | [virtual] |
Xmlw::XmlDocument::XmlDocument | ( | const XmlDocument & | ) | [inline, protected] |
bool Xmlw::XmlDocument::IsOk | ( | ) | [inline] |
Document parse successful.
Definition at line 39 of file XmlDocument.h.
References m_ok.
00039 { return m_ok; }
Xmlw::XmlDocument::operator xmlDocPtr | ( | ) |
XmlDocument& Xmlw::XmlDocument::operator= | ( | const XmlDocument & | ) | [inline, private] |
xmlDocPtr Xmlw::XmlDocument::m_doc [private] |
Definition at line 49 of file XmlDocument.h.
Referenced by operator xmlDocPtr(), XmlDocument(), and ~XmlDocument().
bool Xmlw::XmlDocument::m_ok [private] |