Cantera  2.4.0
Public Member Functions | Public Attributes | Protected Attributes | List of all members
XML_Reader Class Reference

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

#include <xml.h>

Public Member Functions

 XML_Reader (std::istream &input)
 Sole Constructor for the XML_Reader class. More...
 
void getchr (char &ch)
 Read a single character from the input stream and returns it. More...
 
int findQuotedString (const std::string &aline, std::string &rstring) const
 Searches a string for the first occurrence of a valid quoted string. More...
 
void parseTag (const 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 in between angle brackets. More...
 
std::string readTag (std::map< std::string, std::string > &attribs)
 Reads an XML tag into a string. More...
 
std::string readValue ()
 Return the value portion of an XML element. More...
 

Public Attributes

int m_line
 Line count. More...
 

Protected Attributes

std::istream & m_s
 Input stream containing the XML file. More...
 

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 27 of file xml.h.

Constructor & Destructor Documentation

◆ XML_Reader()

XML_Reader ( std::istream &  input)

Sole Constructor for the XML_Reader class.

Parameters
inputReference to the istream object containing the XML file

Definition at line 115 of file xml.cpp.

Member Function Documentation

◆ getchr()

void getchr ( char &  ch)

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

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

Parameters
chCharacter to be returned.

Definition at line 121 of file xml.cpp.

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

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

◆ findQuotedString()

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
alineThis is the input string to be searched
rstringReturn value of the string that is found. The quotes are stripped from the string.
Returns
the integer position just after the quoted string.

Definition at line 157 of file xml.cpp.

References Cantera::findUnbackslashed(), and Cantera::npos.

Referenced by XML_Reader::parseTag().

◆ parseTag()

void parseTag ( const 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 in between angle brackets.

Parameters
tagTag to be parsed - input
nameOutput string containing name of the XML
[out]attribsmap of attribute name and attribute value

Definition at line 192 of file xml.cpp.

References XML_Reader::findQuotedString(), Cantera::npos, and Cantera::trimCopy().

Referenced by XML_Reader::readTag().

◆ 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
attribsmap of attribute name and attribute value - output
Returns
Output string containing name of the XML

Definition at line 231 of file xml.cpp.

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

Referenced by XML_Node::build().

◆ readValue()

std::string readValue ( )

Return the value portion of an XML element.

This function advances the input streams pointer

Definition at line 278 of file xml.cpp.

References XML_Reader::getchr(), XML_Reader::m_s, and Cantera::trimCopy().

Referenced by XML_Node::build().

Member Data Documentation

◆ m_s

std::istream& m_s
protected

Input stream containing the XML file.

Definition at line 85 of file xml.h.

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

◆ m_line

int m_line

Line count.

Definition at line 89 of file xml.h.

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


The documentation for this class was generated from the following files: