65 void parseTag(
const std::string& tag, std::string& name,
66 std::map<std::string, std::string>& attribs)
const;
75 std::string
readTag(std::map<std::string, std::string>& attribs);
152 XML_Node& addChild(
const std::string& sname);
183 const std::string&
fmt=
"%g");
200 void addValue(
const std::string& val);
211 void addValue(
const doublereal val,
const std::string&
fmt=
"%g");
217 std::string
value()
const;
224 std::string
value(
const std::string& cname)
const;
232 std::string
operator()(
const std::string& cname)
const;
269 const std::string&
fmt=
"%g");
299 std::string
operator[](
const std::string& attr)
const;
312 std::string
attrib(
const std::string& attr)
const;
327 std::map<std::string,std::string>&
attribs();
331 const std::map<std::string,std::string>&
attribsConst()
const;
357 bool hasChild(
const std::string& ch)
const;
364 bool hasAttrib(
const std::string& a)
const;
386 std::string
id()
const;
399 const std::vector<XML_Node*>&
children()
const;
406 size_t nChildren(
bool discardComments =
false)
const;
420 void _require(
const std::string& a,
const std::string& v)
const;
441 const std::string& idTarget)
const;
461 const std::string& idTarget,
const int index)
const;
480 XML_Node*
findID(
const std::string&
id,
const int depth=100)
const;
496 int depth = 100000)
const;
560 void write(std::ostream& s,
const int level = 0,
int numRecursivesAllowed = 60000)
const;
575 void build(
const std::string& filename);
586 void build(std::istream& f,
const std::string& filename=
"[unknown]");
626 void write_int(std::ostream& s,
int level = 0,
int numRecursivesAllowed = 60000)
const;
void setName(const std::string &name_)
Sets the name of the XML node.
std::vector< XML_Node * > getChildren(const std::string &name) const
Get a vector of pointers to XML_Node containing all of the children of the current node which match t...
std::vector< XML_Node * > m_children
Vector of pointers to child nodes.
std::string readTag(std::map< std::string, std::string > &attribs)
Reads an XML tag into a string.
std::string name() const
Returns the name of the XML node.
XML_Node * findXMLPhase(XML_Node *root, const std::string &idtarget)
Search an XML_Node tree for a named phase XML_Node.
const XML_Node * findByName(const std::string &nm, int depth=100000) const
This routine carries out a recursive search for an XML node based on the name of the node...
void clear()
Clear the current node and everything under it.
void copyUnion(XML_Node *const node_dest) const
Copy all of the information in the current XML_Node tree into the destination XML_Node tree...
std::string operator()(const std::string &cname) const
The Overloaded parenthesis operator with one augment returns the value of an XML child node as a stri...
integer int_value() const
Return the value of an XML node as a single int.
void unlock()
Unset the lock for this node and all of its children.
std::map< std::string, std::string > & attribs()
Returns a changeable value of the attributes map for the current node.
Class XML_Node is a tree-based representation of the contents of an XML file.
void write(std::ostream &s, const int level=0, int numRecursivesAllowed=60000) const
Write an XML subtree to an output stream.
This file contains definitions for utility functions and text for modules, inputfiles, logs, textlogs, (see Input File Handling, Diagnostic Output, and Writing messages to the screen).
std::map< std::string, std::string > m_attribs
Storage of attributes for a node.
bool hasAttrib(const std::string &a) const
Tests whether the current node has an attribute with a particular name.
bool isComment() const
Boolean function indicating whether a comment.
XML_Node * setParent(XML_Node *const p)
Sets the pointer for the parent node of the current node.
std::string m_value
Value of the XML node.
void addValue(const std::string &val)
Modify the value for the current node.
Class XML_Reader reads an XML file into an XML_Node object.
void _require(const std::string &a, const std::string &v) const
Require that the current XML node have an attribute named by the first argument, a, and that this attribute have the the string value listed in the second argument, v.
void addComment(const std::string &comment)
Add a child node to the current node containing a comment.
const std::vector< XML_Node * > & children() const
Return an unchangeable reference to the vector of children of the current node.
XML_Reader(std::istream &input)
Sole Constructor for the XML_Reader class.
int findQuotedString(const std::string &aline, std::string &rstring) const
Searches a string for the first occurrence of a valid quoted string.
bool m_locked
Lock for this node.
XML_Node * m_root
Pointer to the root XML_Node for the current node.
std::string m_filename
Name of the file from which this XML node was read.
void lock()
Set the lock for this node and all of its children.
bool m_iscomment
True if the current node is a comment node.
XML_Node(const std::string &nm="--", XML_Node *const parent=0)
Constructor for XML_Node, representing a tree structure.
XML_Node * parent() const
Returns a pointer to the parent node of the current node.
std::string value() const
Return the value of an XML node as a string.
void build(const std::string &filename)
Populate the XML tree from an input file.
XML_Node & mergeAsChild(XML_Node &node)
Merge an existing node as a child node to the current node.
XML_Node * m_parent
Pointer to the parent XML_Node for the current node.
void addAttribute(const std::string &attrib, const std::string &value)
Add or modify an attribute of the current node.
void copy(XML_Node *const node_dest) const
Copy all of the information in the current XML_Node tree into the destination XML_Node tree...
int lineNumber() const
Return the line number.
void setLineNumber(const int n)
Set the line number.
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.
XML_Node * findNameID(const std::string &nameTarget, const std::string &idTarget) const
This routine carries out a recursive search for an XML node based on both the XML element name and th...
void setRoot(const XML_Node &root)
Set the root XML_Node value within the current node.
bool hasChild(const std::string &ch) const
Tests whether the current node has a child node with a particular name.
XML_Node & child(const size_t n) const
Return a changeable reference to the n'th child of the current node.
XML_Node & root() const
Return the root of the current XML_Node tree.
const std::map< std::string, std::string > & attribsConst() const
Returns an unchangeable value of the attributes map for the current node.
std::string m_name
XML node name of the node.
XML_Node * findNameIDIndex(const std::string &nameTarget, const std::string &idTarget, const int index) const
This routine carries out a search for an XML node based on both the XML element name and the attribut...
std::string readValue()
Return the value portion of an XML element.
void removeChild(const XML_Node *const node)
Remove a child from this node's list of children.
std::string attrib(const std::string &attr) const
Function returns the value of an attribute.
std::string operator[](const std::string &attr) const
The operator[] is overloaded to provide a lookup capability on attributes for the current XML element...
std::string id() const
Return the id attribute, if present.
void writeHeader(std::ostream &s)
Write the header to the XML file to the specified ostream.
XML_Node * findByAttr(const std::string &attr, const std::string &val, int depth=100000) const
This routine carries out a recursive search for an XML node based on an attribute of each XML node...
Namespace for the Cantera kernel.
void write_int(std::ostream &s, int level=0, int numRecursivesAllowed=60000) const
Write an XML subtree to an output stream.
doublereal fp_value() const
Return the value of an XML node as a single double.
int m_linenum
The member data m_linenum.
size_t nChildren(bool discardComments=false) const
Return the number of children.
std::multimap< std::string, XML_Node * > m_childindex
Map containing an index between the node name and the pointer to the node.
Definitions for the classes that are thrown when Cantera experiences an error condition (also contain...
XML_Node * findID(const std::string &id, const int depth=100) const
This routine carries out a recursive search for an XML node based on the XML element attribute...
std::istream & m_s
Input stream containing the XML file.
void getchr(char &ch)
Read a single character from the input stream and returns it.