Logo
~Sockets~
~Examples~
~Contact~


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 49 of file XmlDocument.h.


Constructor & Destructor Documentation

XmlDocument::XmlDocument ( const std::string &  filename,
const std::string &  verify_ns = "",
const std::string &  verify_root = "" 
)

Definition at line 43 of file XmlDocument.cpp.

References m_doc, and m_ok.

00044 : m_doc(NULL)
00045 , m_ok(false)
00046 {
00047         xmlNodePtr cur;
00048         xmlNsPtr ns;
00049 
00050         if (!(m_doc = xmlParseFile(filename.c_str() )))
00051         {
00052                 throw XmlException("Parse of file failed: " + filename);
00053         }
00054         if (!(cur = xmlDocGetRootElement(m_doc)))
00055         {
00056                 xmlFreeDoc(m_doc);
00057                 m_doc = NULL;
00058                 throw XmlException("Document is empty: " + filename);
00059         }
00060         if (verify_ns.size())
00061         {
00062                 if (!(ns = xmlSearchNsByHref(m_doc, cur, (const xmlChar *) verify_ns.c_str() )))
00063                 {
00064                         xmlFreeDoc(m_doc);
00065                         m_doc = NULL;
00066                         throw XmlException("Document namespace != " + verify_ns);
00067                 }
00068         }
00069         if (verify_root.size())
00070         {
00071                 if (xmlStrcmp(cur -> name, (const xmlChar *) verify_root.c_str() ))
00072                 {
00073                         xmlFreeDoc(m_doc);
00074                         m_doc = NULL;
00075                         throw XmlException("Document root != " + verify_root);
00076                 }
00077         }
00078         m_ok = true;
00079 }

XmlDocument::~XmlDocument (  )  [virtual]

Definition at line 82 of file XmlDocument.cpp.

References m_doc.

00083 {
00084         if (m_doc)
00085         {
00086                 xmlFreeDoc(m_doc);
00087         }
00088 }

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

Definition at line 61 of file XmlDocument.h.

00061 {} // copy constructor


Member Function Documentation

bool XmlDocument::IsOk (  )  [inline]

Document parse successful.

Definition at line 56 of file XmlDocument.h.

00056 { return m_ok; }

XmlDocument::operator xmlDocPtr (  ) 

Definition at line 91 of file XmlDocument.cpp.

References m_doc.

00092 {
00093         return m_doc;
00094 }

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

Definition at line 64 of file XmlDocument.h.

00064 { return *this; } // assignment operator


Member Data Documentation

xmlDocPtr XmlDocument::m_doc [private]

Definition at line 66 of file XmlDocument.h.

Referenced by operator xmlDocPtr(), XmlDocument(), and ~XmlDocument().

bool XmlDocument::m_ok [private]

Definition at line 67 of file XmlDocument.h.

Referenced by XmlDocument().


The documentation for this class was generated from the following files:
Page, code, and content Copyright (C) 2007 by Anders Hedström
Generated for C++ Sockets by  doxygen 1.4.4