68 void parseTag(
const std::string& tag, std::string& name,
69 std::map<std::string, std::string>& attribs)
const;
78 std::string
readTag(std::map<std::string, std::string>& attribs);
157 XML_Node& addChild(
const std::string& sname);
168 XML_Node& addChild(
const char* cstring);
199 XML_Node& addChild(
const std::string& name,
const doublereal value,
200 const std::string& fmt=
"%g");
217 void addValue(
const std::string& val);
228 void addValue(
const doublereal val,
const std::string& fmt=
"%g");
234 std::string
value()
const;
247 std::string
value(
const std::string& cname)
const;
255 std::string
operator()(
const std::string& cname)
const;
291 void addAttribute(
const std::string& attrib,
const doublereal value,
292 const std::string& fmt=
"%g");
309 std::string
operator[](
const std::string& attr)
const;
323 std::string
attrib(
const std::string& attr)
const;
338 std::map<std::string,std::string>&
attribs();
345 const std::map<std::string,std::string>&
attribsConst()
const;
376 bool hasChild(
const std::string& ch)
const;
384 bool hasAttrib(
const std::string& a)
const;
407 std::string
id()
const;
421 const std::vector<XML_Node*>&
children()
const;
428 size_t nChildren(
bool discardComments =
false)
const;
442 void _require(
const std::string& a,
const std::string& v)
const;
464 const std::string& idTarget)
const;
486 const std::string& idTarget,
const int index)
const;
508 XML_Node*
findID(
const std::string&
id,
const int depth=100)
const;
526 int depth = 100000)
const;
596 void write(std::ostream& s,
const int level = 0,
int numRecursivesAllowed = 60000)
const;
619 void build(std::istream& f);
662 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.
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...
integer int_value() const
Return the value of an XML node as a single int.
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.
std::vector< XML_Node * > m_children
Vector of pointers to child nodes.
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...
int findQuotedString(const std::string &aline, std::string &rstring) const
Searches a string for the first occurrence of a valid quoted string.
std::string readTag(std::map< std::string, std::string > &attribs)
Reads an XML tag into a string.
XML_Node * findXMLPhase(XML_Node *root, const std::string &idtarget)
Search an XML_Node tree for a named phase XML_Node.
std::string attrib(const std::string &attr) const
Function returns the value of an attribute.
void clear()
Clear the current node and everything under it.
const std::vector< XML_Node * > & children() const
Return an unchangeable reference to the vector of children of the current node.
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.
size_t m_nchildren
Number of children of this 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...
This file contains definitions for utility functions and text for modules, inputfiles, logs, textlogs, HTML_logs (see Input File Handling, Diagnostic Output, Writing messages to the screen and Writing HTML Logfiles).
std::map< std::string, std::string > m_attribs
Storage of attributes for a node.
const std::map< std::string, std::string > & attribsConst() const
Returns an unchangeable value of the attributes map for the current node.
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.
XML_Node & child(const size_t n) const
Return a changeable reference to the n'th child of the current 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.
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 addComment(const std::string &comment)
Add a child node to the current node containing a comment.
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_Reader(std::istream &input)
Sole Constructor for the XML_Reader class.
bool m_locked
Lock for this node.
XML_Node * m_root
Pointer to the root XML_Node for the current node.
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.
std::string name() const
Returns the name of the XML node.
XML_Node(const std::string &nm="--", XML_Node *const parent=0)
Constructor for XML_Node, representing a tree structure.
bool hasChild(const std::string &ch) const
Tests whether the current node has a child node with a particular name.
void write(std::ostream &s, const int level=0, int numRecursivesAllowed=60000) const
Write an XML subtree to an output stream.
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 setLineNumber(const int n)
Set the line number.
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...
void setRoot(const XML_Node &root)
Set the root XML_Node value within the current node.
std::string value() const
Return the value of an XML node as a string.
std::string m_name
XML node name of the node.
int lineNumber() const
Return the line number.
std::string readValue()
Return the value portion of an XML element.
std::string id() const
Return the id attribute, if present.
void removeChild(const XML_Node *const node)
Remove a child from this node's list of children.
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...
void writeHeader(std::ostream &s)
Write the header to the xml file to the specified ostream.
bool isComment() const
Boolean function indicating whether a comment.
std::string operator[](const std::string &attr) const
The operator[] is overloaded to provide a lookup capability on attributes for the current XML element...
doublereal fp_value() const
Return the value of an XML node as a single double.
XML_Node & root() const
Return the root of the current XML_Node tree.
XML_Node * parent() const
Returns a pointer to the parent node of the current node.
int m_linenum
The member data m_linenum.
void build(std::istream &f)
Main routine to create an tree-like representation of an XML file.
std::multimap< std::string, XML_Node * > m_childindex
Map containing an index between the node name and the pointer to the node.
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...
Definitions for the classes that are thrown when Cantera experiences an error condition (also contain...
size_t nChildren(bool discardComments=false) const
Return the number of children.
void getChildren(const std::string &name, std::vector< XML_Node * > &children) const
Get a vector of pointers to XML_Node containing all of the children of the current node which matches...
std::istream & m_s
Input stream containing the XML file.
bool hasAttrib(const std::string &a) const
Tests whether the current node has an attribute with a particular name.
void write_int(std::ostream &s, int level=0, int numRecursivesAllowed=60000) const
Write an XML subtree to an output stream.
void getchr(char &ch)
Read a single character from the input stream and returns it.
std::string operator()() const
Overloaded parenthesis operator returns the value of the Node.