XML_Reader Class Reference

Class XML_Reader reads an XML file into an XML_Node object. More...

#include <xml.h>

List of all members.

Public Member Functions

 XML_Reader (std::istream &input)
 Sole Constructor for the XML_Reader class.
void getchr (char &ch)
 Read a single character from the input stream and return it.
std::string strip (const std::string &aline) const
 Returns string 'aline' stripped of leading and trailing white space.
std::string inquotes (const std::string &aline) const
 Looks for a substring within 'aline' enclosed in double quotes, and returns this substring (without the quotes) if found.
int findQuotedString (const std::string &aline, std::string &rstring) const
 Searches a string for the first occurrence of a valid quoted string.
void parseTag (std::string tag, std::string &name, std::map< std::string, std::string > &attribs) const
 parseTag parses XML tags, i.e., the XML elements that are inbetween angle brackets.
std::string readTag (std::map< std::string, std::string > &attribs)
 Reads an XML tag into a string.
std::string readValue ()
 Return the value portion of an XML element.

Public Attributes

int m_line
 Line count.

Protected Attributes

std::istream & m_s
 Input Stream containing the XML file.

Detailed Description

Class XML_Reader reads an XML file into an XML_Node object.

Class XML_Reader is designed for internal use.

Definition at line 38 of file xml.h.


Constructor & Destructor Documentation

XML_Reader ( std::istream &  input  ) 

Sole Constructor for the XML_Reader class.

Parameters:
input Reference to the istream object containing the XML file

Definition at line 170 of file xml.cpp.


Member Function Documentation

int findQuotedString ( const std::string &  aline,
std::string &  rstring 
) const

Searches a string for the first occurrence of a valid quoted string.

Quotes can start with either a single quote or a double quote, but must also end with the same type. Quotes may be commented out by preceding with a backslash character, '\'.

Parameters:
aline This is the input string to be searched
rstring Return value of the string that is found. The quotes are stripped from the string.
Returns:
Returns the integer position just after the quoted string.

Definition at line 255 of file xml.cpp.

Referenced by XML_Reader::parseTag().

void getchr ( char &  ch  ) 

Read a single character from the input stream and return it.

Get a single character from the input stream.

All low level reads occur through this function. The function also keeps track of the line numbers.

Parameters:
ch Character to be returned.

If the character is a new-line character, then increment the line count.

Definition at line 181 of file xml.cpp.

References XML_Reader::m_line, and XML_Reader::m_s.

Referenced by XML_Reader::readTag(), and XML_Reader::readValue().

std::string inquotes ( const std::string &  aline  )  const

Looks for a substring within 'aline' enclosed in double quotes, and returns this substring (without the quotes) if found.

If not, an empty string is returned.

Parameters:
aline This is the input string to be searched
Todo:
why is this a class method?

If not, an empty string is returned.

Todo:
why is this a class method?

Definition at line 212 of file xml.cpp.

void parseTag ( std::string  tag,
std::string &  name,
std::map< std::string, std::string > &  attribs 
) const

parseTag parses XML tags, i.e., the XML elements that are inbetween angle brackets.

Parameters:
tag Tag to be parsed - input
name Output string containing name of the XML
attribs map of attribute name and attribute value - output

Definition at line 295 of file xml.cpp.

References XML_Reader::findQuotedString(), and XML_Reader::strip().

Referenced by XML_Reader::readTag().

std::string readTag ( std::map< std::string, std::string > &  attribs  ) 

Reads an XML tag into a string.

This function advances the input streams pointer

Parameters:
attribs map of attribute name and attribute value - output
Returns:
Output string containing name of the XML

Definition at line 330 of file xml.cpp.

References XML_Reader::getchr(), XML_Reader::m_s, and XML_Reader::parseTag().

Referenced by XML_Node::build().

std::string readValue (  ) 

Return the value portion of an XML element.

This function advances the input streams pointer

Definition at line 368 of file xml.cpp.

References XML_Reader::getchr(), XML_Reader::m_s, and XML_Reader::strip().

Referenced by XML_Node::build().

std::string strip ( const std::string &  aline  )  const

Returns string 'aline' stripped of leading and trailing white space.

White space is defined by the ISO C function isspace(), and includes tabs, spaces, \n. \r, \v, and \f.

Parameters:
aline Input line to be stripped
Returns:
Returns a string stripped of leading and trailing white space.
Todo:
why is this a class method?

Definition at line 192 of file xml.cpp.

Referenced by XML_Reader::parseTag(), and XML_Reader::readValue().


Member Data Documentation

int m_line

Line count.

Definition at line 138 of file xml.h.

Referenced by XML_Node::build(), and XML_Reader::getchr().

std::istream& m_s [protected]

Input Stream containing the XML file.

Definition at line 134 of file xml.h.

Referenced by XML_Reader::getchr(), XML_Reader::readTag(), and XML_Reader::readValue().


The documentation for this class was generated from the following files:
Generated by  doxygen 1.6.3