Xmlw::XmlDocument Class Reference

#include <XmlDocument.h>

List of all members.

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

XmlDocumentoperator= (const XmlDocument &)

Private Attributes

xmlDocPtr m_doc
bool m_ok


Detailed Description

Definition at line 32 of file XmlDocument.h.


Constructor & Destructor Documentation

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.

References m_doc, and m_ok.

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]

Definition at line 67 of file XmlDocument.cpp.

References m_doc.

00068 {
00069         if (m_doc)
00070         {
00071                 xmlFreeDoc(m_doc);
00072         }
00073 }

Xmlw::XmlDocument::XmlDocument ( const XmlDocument  )  [inline, protected]

Definition at line 44 of file XmlDocument.h.

00044 {} // copy constructor


Member Function Documentation

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 (  ) 

Definition at line 76 of file XmlDocument.cpp.

References m_doc.

00077 {
00078         return m_doc;
00079 }

XmlDocument& Xmlw::XmlDocument::operator= ( const XmlDocument  )  [inline, private]

Definition at line 47 of file XmlDocument.h.

00047 { return *this; } // assignment operator


Member Data Documentation

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]

Definition at line 50 of file XmlDocument.h.

Referenced by IsOk(), and XmlDocument().


The documentation for this class was generated from the following files:
Generated on Sun Feb 10 17:01:02 2008 for xmlw - libxml2 C++ wrapper by  doxygen 1.5.2