GNUMessenger::XMLParser Class Reference

An XML Parser. More...

#include <xml.h>

Inheritance diagram for GNUMessenger::XMLParser:

Inheritance graph
Collaboration diagram for GNUMessenger::XMLParser:

Collaboration graph
List of all members.

Public Types

enum  Type { File, String }
 The type of input.

Public Member Functions

 XMLParser (const string &data="", Type type=XMLParser::String)
 Construct a new parser, may throw ParseFailure or DiskError.
 XMLParser (XMLNode &root)
 Set a XMLNode as root.
int tree_to_xml (string &line)
 Write the XML Tree to to line.
int tree_to_file (const string &filename)
 may throw DiskError
vector< XMLNodeget_tags (const string &key)
 Get all tags in the tree whose name are key.
XMLNodeget_root ()
 Return the root tag.
int lock (const string &fname)
int release (const string &fname)
int bad ()
int good ()
int getParsed () const

Static Public Member Functions

int printTag (const XMLNode &node, string &ret, int indent=0)
string escape (string str)

Protected Member Functions

virtual void recievedTag (XMLNode &n)
 This method is called whenever a new tag is recieved.
virtual void rootTagRecieved (XMLNode &n)
 This method is called when the first complete tag is recieved.
virtual void parserError (const string &errorMsg, int line)

Detailed Description

An XML Parser.

This class a string and parsers it to build a XML tree.

Usually you dont need to use this class directly, you can parse strings and convert XMLNodes to string directly with the XMLNode class.

Henrik Abelsson

Definition at line 27 of file xml.h.

Constructor & Destructor Documentation

GNUMessenger::XMLParser::XMLParser const string &  data = "",
Type  type = XMLParser::String

Construct a new parser, may throw ParseFailure or DiskError.

data Data to read, either a ready string or a filename
type Specifies w XMLParser::String - read from an in memory string, or XMLParser::File, a file.
Definition at line 71 of file xml.cpp.
00072 : Expat() 00073 { 00074 init(line, type); 00075 }

Member Function Documentation

vector< XMLNode > GNUMessenger::XMLParser::get_tags const string &  key  ) 

Get all tags in the tree whose name are key.

key What tags to return
all the tags that match key
See also:
Definition at line 112 of file xml.cpp.
00113 { 00114 vector<XMLNode> ret; 00115 return ret; 00116 }

void GNUMessenger::XMLParser::recievedTag XMLNode n  )  [protected, virtual]

This method is called whenever a new tag is recieved.

You should ovveride this.

Reimplemented from GNUMessenger::Expat.

Definition at line 192 of file xml.cpp.

References GNUMessenger::XMLNode::addChild().

00193 { 00194 root.addChild(n); 00195 }

Here is the call graph for this function:

int GNUMessenger::XMLParser::tree_to_xml string &  line  ) 

Write the XML Tree to to line.

line Otherwise store the tree in this string.
Definition at line 88 of file xml.cpp.
00089 { 00090 printTag(root,line); 00091 return 0; 00092 }

The documentation for this class was generated from the following files:
Generated on Tue Oct 5 14:41:58 2004 for GNU Messenger by doxygen 1.3.8