XmlWriter Class Reference

#include <xml_document.h>

List of all members.

Public Member Functions

 XmlWriter ()
 ~XmlWriter ()
bool Create (const std::string &filename, const std::string &root, const std::string &version, const std::string &encoding)
bool IsOk () const
xmlpp::Element * GetRoot ()
void WriteElement (xmlpp::Element *x, const std::string &name, const std::string &value)
bool Save ()

Protected Attributes

xmlpp::Document * m_doc
xmlpp::Element * m_root
std::string m_filename
bool m_save
std::string m_encoding


Detailed Description

Definition at line 81 of file xml_document.h.


Constructor & Destructor Documentation

XmlWriter::XmlWriter (  ) 

Definition at line 234 of file xml_document.cpp.

00235 {
00236   m_doc = NULL;
00237   m_root = NULL;
00238   m_save = false;
00239 }

XmlWriter::~XmlWriter (  ) 

Definition at line 241 of file xml_document.cpp.

00242 {
00243   Save();
00244   delete m_doc;
00245 }

Here is the call graph for this function:


Member Function Documentation

bool XmlWriter::Create ( const std::string &  filename,
const std::string &  root,
const std::string &  version,
const std::string &  encoding 
)

Definition at line 261 of file xml_document.cpp.

00263 {
00264   delete m_doc;
00265   delete m_root;
00266   m_save = false;
00267   m_filename = filename;
00268   m_encoding = encoding;
00269   m_doc = new xmlpp::Document(version);
00270   m_root = m_doc->create_root_node(root);
00271   assert(m_root != NULL);
00272   return true;
00273 }

Here is the caller graph for this function:

xmlpp::Element * XmlWriter::GetRoot (  ) 

Definition at line 275 of file xml_document.cpp.

00276 {
00277   assert (m_root != NULL);
00278   return m_root;
00279 }

Here is the caller graph for this function:

bool XmlWriter::IsOk (  )  const

Definition at line 247 of file xml_document.cpp.

00248 {
00249   return (m_doc != NULL) && (m_root != NULL);
00250 }

bool XmlWriter::Save (  ) 

Definition at line 281 of file xml_document.cpp.

00282 {
00283   if (m_save) return true;
00284   m_save = true;
00285   try {
00286     m_doc->write_to_file_formatted(m_filename, m_encoding);
00287   } catch (const xmlpp::exception &err) {
00288     return false;
00289   }
00290   return true;
00291 }

Here is the caller graph for this function:

void XmlWriter::WriteElement ( xmlpp::Element *  x,
const std::string &  name,
const std::string &  value 
)

Definition at line 252 of file xml_document.cpp.

00255 {
00256   xmlpp::Element *elem = x->add_child(name);
00257   elem->add_child_text(value);
00258   m_save = false;
00259 }

Here is the caller graph for this function:


Member Data Documentation

xmlpp::Document* XmlWriter::m_doc [protected]

Definition at line 84 of file xml_document.h.

std::string XmlWriter::m_encoding [protected]

Definition at line 88 of file xml_document.h.

std::string XmlWriter::m_filename [protected]

Definition at line 86 of file xml_document.h.

xmlpp::Element* XmlWriter::m_root [protected]

Definition at line 85 of file xml_document.h.

bool XmlWriter::m_save [protected]

Definition at line 87 of file xml_document.h.


The documentation for this class was generated from the following files:
Generated on Mon Jan 1 14:34:45 2007 for Wormux by  doxygen 1.4.7