Cantera 2.6.0

xml.h
Go to the documentation of this file.
1/**
2 * @file xml.h
3 * Classes providing support for XML data files. These classes
4 * implement only those aspects of XML required to read, write, and
5 * manipulate CTML data files.
6 */
7
8// This file is part of Cantera. See License.txt in the top-level directory or
9// at https://cantera.org/license.txt for license and copyright information.
10
11#ifndef CT_XML_H
12#define CT_XML_H
13
14#include "ct_defs.h"
15
16//! @{
17#define XML_INDENT 4
18//! @}
19
20 namespace Cantera
21{
22//! Class XML_Reader reads an XML file into an XML_Node object.
23/*!
24 * Class XML_Reader is designed for internal use.
25 *
26 * @deprecated The XML input format is deprecated and will be removed in
27 * Cantera 3.0.
28 */
29 class XML_Reader
30{
31 public:
32 //! Sole Constructor for the XML_Reader class
33 /*!
34 * @param input Reference to the istream object containing the XML file
35 */
36 XML_Reader(std::istream& input);
37
38 //! Read a single character from the input stream and returns it
39 /*!
40 * All low level reads occur through this function. The function also keeps
41 * track of the line numbers.
42 *
43 * @param ch Character to be returned.
44 */
45 void getchr(char& ch);
46
47 //! Searches a string for the first occurrence of a valid quoted string.
48 /*!
49 * Quotes can start with either a single quote or a double quote, but must
50 * also end with the same type. Quotes may be commented out by preceding
51 * with a backslash character, '\\'.
52 *
53 * @param aline This is the input string to be searched
54 * @param rstring Return value of the string that is found.
55 * The quotes are stripped from the string.
56 * @returns the integer position just after the quoted string.
57 */
58 int findQuotedString(const std::string& aline, std::string& rstring) const;
59
60 //! parseTag parses XML tags, i.e., the XML elements that are in between
61 //! angle brackets.
62 /*!
63 * @param tag Tag to be parsed - input
64 * @param name Output string containing name of the XML
65 * @param[out] attribs map of attribute name and attribute value
66 */
67 void parseTag(const std::string& tag, std::string& name,
68 std::map<std::string, std::string>& attribs) const;
69
70 //! Reads an XML tag into a string
71 /*!
72 * This function advances the input streams pointer
73 *
74 * @param attribs map of attribute name and attribute value - output
75 * @return Output string containing name of the XML
76 */
77 std::string readTag(std::map<std::string, std::string>& attribs);
78
79 //! Return the value portion of an XML element
80 /*!
81 * This function advances the input streams pointer
82 */
83 std::string readValue();
84
85 protected:
86 //! Input stream containing the XML file
87 std::istream& m_s;
88
89 public:
90 //! Line count
91 int m_line;
92};
93
94//! Class XML_Node is a tree-based representation of the contents of an XML file
95/*!
96 * There are routines for adding to the tree, querying and searching the tree,
97 * and for writing the tree out to an output file.
98 *
99 * @deprecated The XML input format is deprecated and will be removed in
100 * Cantera 3.0.
101 */
102 class XML_Node
103{
104 public:
105 //! Constructor for XML_Node, representing a tree structure
106 /*!
107 * @param nm Name of the node.
108 * @param parent Pointer to the parent for this node in the tree.
109 * A value of 0 indicates this is the top of the tree.
110 */
111 explicit XML_Node(const std::string& nm="--", XML_Node* const parent=0);
112
113 XML_Node(const XML_Node& right);
114 XML_Node& operator=(const XML_Node& right);
115 virtual ~XML_Node();
116
117 //! Clear the current node and everything under it
118 /*!
119 * The value, attributes and children are all zeroed. The name and the
120 * parent information is kept.
121 */
122 void clear();
123
124 //! Merge an existing node as a child node to the current node
125 /*!
126 * This will merge an XML_Node as a child to the current node. Note, this
127 * actually adds the node. Therefore, the current node is changed. There is
128 * no copy made of the child node. The child node should not be deleted in
129 * the future
130 *
131 * @param node Reference to a child XML_Node object
132 * @returns a reference to the added child node
133 */
134 XML_Node& mergeAsChild(XML_Node& node);
135
136 // Add a child node to the current node by making a copy of an existing node
137 // tree
138 /*
139 * This will add an XML_Node as a child to the current node. Note, this
140 * actually adds the node. Therefore, node is changed. A copy is made of the
141 * underlying tree
142 *
143 * @param node Reference to a child XML_Node object
144 * @returns a reference to the added node
145 */
146 XML_Node& addChild(const XML_Node& node);
147
148 //! Add a child node to the current node with a specified name
149 /*!
150 * This will add an XML_Node as a child to the current node.
151 * The node will be blank except for the specified name.
152 *
153 * @param sname Name of the new child
154 * @returns a reference to the added node
155 */
156 XML_Node& addChild(const std::string& sname);
157
158 //! Add a child node to the current XML node, and at the same time add a
159 //! value to the child
160 /*!
161 * Resulting XML string:
162 *
163 * <name> value </name>
164 *
165 * @param name Name of the child XML_Node object
166 * @param value Value of the XML_Node - string
167 * @returns a reference to the created child XML_Node object
168 */
169 XML_Node& addChild(const std::string& name, const std::string& value);
170
171 //! Add a child node to the current XML node, and at the same time add a
172 //! formatted value to the child
173 /*!
174 * This version supplies a formatting string (printf format) to the output
175 * of the value.
176 *
177 * Resulting XML string:
178 *
179 * <name> value </name>
180 *
181 * @param name Name of the child XML_Node object
182 * @param value Value of the XML_Node - double.
183 * @param fmt Format of the output for value
184 * @returns a reference to the created child XML_Node object
185 */
186 XML_Node& addChild(const std::string& name, const doublereal value,
187 const std::string& fmt="%g");
188
189 //! Remove a child from this node's list of children
190 /*!
191 * This function removes an XML_Node from the children of this node.
192 *
193 * @param node Pointer to the node to be removed. Note, this node
194 * isn't modified in any way.
195 */
196 void removeChild(const XML_Node* const node);
197
198 //! Add a child node to the current node containing a comment
199 /*!
200 * Child node will have the name, comment.
201 *
202 * @param comment Content of the comment
203 */
204 void addComment(const std::string& comment);
205
206 //! Modify the value for the current node
207 /*!
208 * This functions fills in the m_value field of the current node
209 *
210 * @param val string Value that the node will be assigned
211 */
212 void addValue(const std::string& val);
213
214 //! Modify the value for the current node
215 /*!
216 * This functions fills in the m_value field of the current node
217 * with a formatted double value
218 *
219 * @param val double Value that the node will be assigned
220 * @param fmt Format of the printf string conversion of the double.
221 * Default is "%g". Must be less than 63 chars
222 */
223 void addValue(const doublereal val, const std::string& fmt="%g");
224
225 //! Return the value of an XML node as a string
226 /*!
227 * This is a simple accessor routine
228 */
229 std::string value() const;
230
231 //! Return the value of an XML child node as a string
232 /*!
233 * @param cname Name of the child node to the current node, for which you
234 * want the value
235 */
236 std::string value(const std::string& cname) const;
237
238 //! The Overloaded parenthesis operator with one augment
239 //! returns the value of an XML child node as a string
240 /*!
241 * @param cname Name of the child node to the current node, for which you
242 * want the value
243 */
244 std::string operator()(const std::string& cname) const;
245
246 //! Return the value of an XML node as a single double
247 /*!
248 * This accesses the value string, and then tries to interpret it as a
249 * single double value.
250 */
251 doublereal fp_value() const;
252
253 //! Return the value of an XML node as a single int
254 /*!
255 * This accesses the value string, and then tries to interpret it as a
256 * single int value.
257 */
258 integer int_value() const;
259
260 //! Add or modify an attribute of the current node
261 /*!
262 * This functions fills in the m_value field of the current node
263 * with a string value
264 *
265 * @param attrib String name for the attribute to be assigned
266 * @param value String value that the attribute will have
267 */
268 void addAttribute(const std::string& attrib, const std::string& value);
269
270 //! Add or modify an attribute to the double, value
271 /*!
272 * This functions fills in the attribute field, named attrib,
273 * with the double value, value. A formatting string is used.
274 *
275 * @param attrib String name for the attribute to be assigned
276 * @param value double Value that the node will be assigned
277 * @param fmt Format of the printf string conversion of the double.
278 * Default is "%g".
279 */
280 void addAttribute(const std::string& attrib, const doublereal value,
281 const std::string& fmt="%g");
282
283 //! Add an integer attribute
284 /*!
285 * @param attrib String name for the attribute to be assigned
286 * @param value int Value that the node will be assigned
287 */
288 void addAttribute(const std::string& attrib, int value);
289
290 //! Add an unsigned integer attribute
291 /*!
292 * @param attrib String name for the attribute to be assigned
293 * @param value int Value that the node will be assigned
294 */
295 void addAttribute(const std::string& attrib, size_t value);
296
297 //! The operator[] is overloaded to provide a lookup capability
298 //! on attributes for the current XML element.
299 /*!
300 * For example
301 * xmlNode["id"]
302 * will return the value of the attribute "id" for the current
303 * XML element. It will return the blank std::string if there isn't
304 * an attribute with that name.
305 *
306 * @param attr attribute string to look up
307 * @returns a string representing the value of the attribute within the XML
308 * node. If there is no attribute with the given name, it returns
309 * the null string.
310 */
311 std::string operator[](const std::string& attr) const;
312
313 //! Function returns the value of an attribute
314 /*!
315 * This function searches the attributes vector for the attribute named
316 * 'attr'. If a match is found, the attribute value is returned as a
317 * string. If no match is found, the empty string is returned.
318 *
319 * @param attr String containing the attribute to be searched for.
320 * @return If a match is found, the attribute value is returned as a
321 * string. If no match is found, the empty string is returned.
322 */
323 std::string attrib(const std::string& attr) const;
324
325 private:
326 //! Returns a changeable value of the attributes map for the current node
327 /*!
328 * Note this is a simple accessor routine. And, it is a private function.
329 * It's used in some internal copy and assignment routines
330 */
331 std::map<std::string,std::string>& attribs();
332
333 public:
334 //! Returns an unchangeable value of the attributes map for the current node
335 const std::map<std::string,std::string>& attribsConst() const;
336
337 //! Set the line number
338 /*!
339 * @param n the member data m_linenum is set to n
340 */
341 void setLineNumber(const int n);
342
343 //! Return the line number
344 int lineNumber() const;
345
346 //! Returns a pointer to the parent node of the current node
347 XML_Node* parent() const;
348
349 //! Sets the pointer for the parent node of the current node
350 /*!
351 * @param p Pointer to the parent node
352 * @returns the pointer p
353 */
354 XML_Node* setParent(XML_Node* const p);
355
356 //! Tests whether the current node has a child node with a particular name
357 /*!
358 * @param ch Name of the child node to test
359 * @returns true if the child node exists, false otherwise.
360 */
361 bool hasChild(const std::string& ch) const;
362
363 //! Tests whether the current node has an attribute with a particular name
364 /*!
365 * @param a Name of the attribute to test
366 * @returns true if the attribute exists, false otherwise.
367 */
368 bool hasAttrib(const std::string& a) const;
369
370 //! Returns the name of the XML node
371 std::string name() const {
372 return m_name;
373 }
374
375 //! Sets the name of the XML node
376 /*!
377 * @param name_ The name of the XML node
378 */
379 void setName(const std::string& name_) {
380 m_name = name_;
381 }
382
383 //! Return the id attribute, if present
384 /*!
385 * Returns the id attribute if present. If not it return the empty string
386 */
387 std::string id() const;
388
389 //! Return a changeable reference to the n'th child of the current node
390 /*!
391 * @param n Number of the child to return
392 */
393 XML_Node& child(const size_t n) const;
394
395 //! Return an unchangeable reference to the vector of children of the current node
396 /*!
397 * Each of the individual XML_Node child pointers, however, is pointing to a
398 * changeable XML node object.
399 */
400 const std::vector<XML_Node*>& children() const;
401
402 //! Return the number of children
403 /*!
404 * @param discardComments If true comments are discarded when adding up the
405 * number of children. Defaults to false.
406 */
407 size_t nChildren(bool discardComments = false) const;
408
409 //! Boolean function indicating whether a comment
410 bool isComment() const;
411
412 //! Require that the current XML node has an attribute named by the first
413 //! argument, a, and that this attribute has the string value listed in
414 //! the second argument, v.
415 /*!
416 * @param a attribute name
417 * @param v required value of the attribute
418 *
419 * If the condition is not true, an exception is thrown
420 */
421 void _require(const std::string& a, const std::string& v) const;
422
423 //! This routine carries out a recursive search for an XML node based
424 //! on both the XML element name and the attribute ID.
425 /*!
426 * If exact matches are found for both fields, the pointer
427 * to the matching XML Node is returned.
428 *
429 * The ID attribute may be defaulted by setting it to "". In this case the
430 * pointer to the first XML element matching the name only is returned.
431 *
432 * @param nameTarget Name of the XML Node that is being searched for
433 * @param idTarget "id" attribute of the XML Node that the routine
434 * looks for
435 * @returns the pointer to the XML node that fits the criteria
436 *
437 * @internal
438 * This algorithm does a lateral search of first generation children
439 * first before diving deeper into each tree branch.
440 */
441 XML_Node* findNameID(const std::string& nameTarget,
442 const std::string& idTarget) const;
443
444 //! This routine carries out a search for an XML node based on the XML
445 //! element name, the attribute ID and an integer index.
446 /*!
447 * If exact matches are found for all fields, the pointer
448 * to the matching XML Node is returned. The search is only carried out on
449 * the current element and the child elements of the current element.
450 *
451 * The "id" attribute may be defaulted by setting it to "". In this case the
452 * pointer to the first XML element matching the name and the Index is returned.
453 *
454 * @param nameTarget Name of the XML Node that is being searched for
455 * @param idTarget "id" attribute of the XML Node that the routine
456 * looks for
457 * @param index Integer describing the index. The index is an
458 * attribute of the form index = "3"
459 * @returns the pointer to the XML node that fits the criteria
460 */
461 XML_Node* findNameIDIndex(const std::string& nameTarget,
462 const std::string& idTarget, const int index) const;
463
464 //! This routine carries out a recursive search for an XML node based
465 //! on the XML element attribute "id"
466 /*!
467 * If exact match is found, the pointer to the matching XML Node is
468 * returned. If not, 0 is returned.
469 *
470 * @param id "id" attribute of the XML Node that the routine looks for
471 * @param depth Depth of the search.
472 * @returns the pointer to the XML node that fits the criteria
473 *
474 * @internal
475 * This algorithm does a lateral search of first generation children
476 * first before diving deeper into each tree branch.
477 */
478 XML_Node* findID(const std::string& id, const int depth=100) const;
479
480 //! This routine carries out a recursive search for an XML node based
481 //! on an attribute of each XML node
482 /*!
483 * If exact match is found with respect to the attribute name and value of
484 * the attribute, the pointer to the matching XML Node is returned. If
485 * not, 0 is returned.
486 *
487 * @param attr Attribute of the XML Node that the routine looks for
488 * @param val Value of the attribute
489 * @param depth Depth of the search. A value of 1 means that only the
490 * immediate children are searched.
491 * @returns the pointer to the XML node that fits the criteria
492 */
493 XML_Node* findByAttr(const std::string& attr, const std::string& val,
494 int depth = 100000) const;
495
496 //! This routine carries out a recursive search for an XML node based
497 //! on the name of the node.
498 /*!
499 * If exact match is found with respect to XML_Node name, the pointer to the
500 * matching XML Node is returned. If not, 0 is returned. This is the const
501 * version of the routine.
502 *
503 * @param nm Name of the XML node
504 * @param depth Depth of the search. A value of 1 means that only the
505 * immediate children are searched.
506 * @returns the pointer to the XML node that fits the criteria
507 */
508 const XML_Node* findByName(const std::string& nm, int depth = 100000) const;
509
510 //! This routine carries out a recursive search for an XML node based
511 //! on the name of the node.
512 /*!
513 * If exact match is found with respect to XML_Node name, the pointer
514 * to the matching XML Node is returned. If not, 0 is returned.
515 * This is the non-const version of the routine.
516 *
517 * @param nm Name of the XML node
518 * @param depth Depth of the search. A value of 1 means that only the
519 * immediate children are searched.
520 * @returns the pointer to the XML node that fits the criteria
521 */
522 XML_Node* findByName(const std::string& nm, int depth = 100000);
523
524 //! Get a vector of pointers to XML_Node containing all of the children
525 //! of the current node which match the given name
526 /*!
527 * @param name Name of the XML_Node children to search for
528 * @return vector of pointers to child XML_Nodes with the matching name
529 */
530 std::vector<XML_Node*> getChildren(const std::string& name) const;
531
532 //! Return a changeable reference to a child of the current node, named by
533 //! the argument
534 /*!
535 * Note the underlying data allows for more than one XML element with the
536 * same name. This routine returns the first child with the given name.
537 *
538 * @param loc Name of the child to return
539 */
540 XML_Node& child(const std::string& loc) const;
541
542 //! Write the header to the XML file to the specified ostream
543 /*!
544 * @param s ostream to write the output to
545 */
546 void writeHeader(std::ostream& s);
547
548 //! Write an XML subtree to an output stream.
549 /*!
550 * This is a wrapper around the static routine write_int(). All this does
551 * is add an endl on to the output stream. write_int() is fine, but the
552 * last endl wasn't being written.
553 *
554 * @param s ostream to write to
555 * @param level Indentation level to work from
556 * @param numRecursivesAllowed Number of recursive calls allowed
557 */
558 void write(std::ostream& s, const int level = 0, int numRecursivesAllowed = 60000) const;
559
560 //! Return the root of the current XML_Node tree
561 /*!
562 * Returns a reference to the root of the current XML tree
563 */
564 XML_Node& root() const;
565
566 //! Set the root XML_Node value within the current node
567 /*!
568 * @param root Value of the root XML_Node.
569 */
570 void setRoot(const XML_Node& root);
571
572 //! Populate the XML tree from an input file
573 void build(const std::string& filename);
574
575 //! Main routine to create an tree-like representation of an XML file
576 /*!
577 * Given an input stream, this routine will read matched XML tags
578 * representing the ctml file until an EOF is read from the file. This
579 * routine is called by the root XML_Node object.
580 *
581 * @param f Input stream containing the ascii input file
582 * @param filename Name of the input file, used in error messages
583 */
584 void build(std::istream& f, const std::string& filename="[unknown]");
585
586 //! Copy all of the information in the current XML_Node tree into the
587 //! destination XML_Node tree, doing a union operation as we go
588 /*!
589 * Note this is a const function because the current XML_Node and its
590 * children isn't altered by this operation. copyUnion() doesn't duplicate
591 * existing entries in the destination XML_Node tree.
592 *
593 * @param node_dest This is the XML node to receive the information
594 */
595 void copyUnion(XML_Node* const node_dest) const;
596
597 //! Copy all of the information in the current XML_Node tree into the
598 //! destination XML_Node tree, doing a complete copy as we go.
599 /*!
600 * Note this is a const function because the current XML_Node and its
601 * children isn't altered by this operation.
602 *
603 * @param node_dest This is the XML node to receive the information
604 */
605 void copy(XML_Node* const node_dest) const;
606
607 //! Set the lock for this node and all of its children
608 void lock();
609
610 //! Unset the lock for this node and all of its children
611 void unlock();
612
613 private:
614 //! Write an XML subtree to an output stream.
615 /*!
616 * This is the main recursive routine. It doesn't put a final endl on. This
617 * is fixed up in the public method. A method to only write out a limited
618 * amount of the XML tree has been added.
619 *
620 * @param s ostream to write to
621 * @param level Indentation level to work from
622 * @param numRecursivesAllowed Number of recursive calls allowed
623 */
624 void write_int(std::ostream& s, int level = 0, int numRecursivesAllowed = 60000) const;
625
626 protected:
627 //! XML node name of the node.
628 /*!
629 * For example, if we were in the XML_Node where
630 *
631 * <phase dim="3" id="gas">
632 * </phase>
633 *
634 * Then, this string would be equal to "phase". "dim" and "id" are
635 * attributes of the XML_Node.
636 */
637 std::string m_name;
638
639 //! Value of the XML node
640 /*!
641 * This is the string contents of the XML node. For example. The XML node
642 * named eps:
643 *
644 * <eps>
645 * valueString
646 * </eps>
647 *
648 * has a m_value string containing "valueString".
649 */
650 std::string m_value;
651
652 //! Name of the file from which this XML node was read. Only populated for
653 //! the root node.
654 std::string m_filename;
655
656 //! Map containing an index between the node name and the
657 //! pointer to the node
658 /*!
659 * m_childindex[node.name()] = XML_Node *pointer
660 *
661 * This object helps to speed up searches.
662 */
663 std::multimap<std::string, XML_Node*> m_childindex;
664
665 //! Storage of attributes for a node
666 /*!
667 * m_attribs[attribName] = attribValue
668 */
669 std::map<std::string, std::string> m_attribs;
670
671 //! Pointer to the parent XML_Node for the current node
672 /*!
673 * Note, the top node has a parent value of 0
674 */
675 XML_Node* m_parent;
676
677 //! Pointer to the root XML_Node for the current node
678 /*!
679 * Note, the top node has a root value equal to itself
680 */
681 XML_Node* m_root;
682
683 //! Lock for this node
684 /*!
685 * Currently, unimplemented functionality. If locked,
686 * it means you can't delete this node.
687 */
688 bool m_locked;
689
690 //! Vector of pointers to child nodes
691 std::vector<XML_Node*> m_children;
692
693 //! True if the current node is a comment node
694 bool m_iscomment;
695
696 //! The member data m_linenum
697 /*!
698 * Currently, unimplemented functionality
699 */
700 int m_linenum;
701};
702
703//! Search an XML_Node tree for a named phase XML_Node
704/*!
705 * Search for a phase Node matching an id.
706 *
707 * @param root Starting XML_Node* pointer for the search
708 * @param phaseId id of the phase to search for
709 * @returns the XML_Node pointer if the phase is found. If the phase is not
710 * found, it returns 0
711 *
712 * @deprecated The XML input format is deprecated and will be removed in
713 * Cantera 3.0.
714 */
715 XML_Node* findXMLPhase(XML_Node* root, const std::string& phaseId);
716
717}
718
719#endif
Cantera::XML_Node
Class XML_Node is a tree-based representation of the contents of an XML file.
Definition: xml.h:103
Cantera::XML_Node::removeChild
void removeChild(const XML_Node *const node)
Remove a child from this node's list of children.
Definition: xml.cpp:417
Cantera::XML_Node::m_attribs
std::map< std::string, std::string > m_attribs
Storage of attributes for a node.
Definition: xml.h:669
Cantera::XML_Node::findByAttr
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.
Definition: xml.cpp:662
Cantera::XML_Node::setName
void setName(const std::string &name_)
Sets the name of the XML node.
Definition: xml.h:379
Cantera::XML_Node::attrib
std::string attrib(const std::string &attr) const
Function returns the value of an attribute.
Definition: xml.cpp:493
Cantera::XML_Node::XML_Node
XML_Node(const std::string &nm="--", XML_Node *const parent=0)
Constructor for XML_Node, representing a tree structure.
Definition: xml.cpp:310
Cantera::XML_Node::copy
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,...
Definition: xml.cpp:877
Cantera::XML_Node::name
std::string name() const
Returns the name of the XML node.
Definition: xml.h:371
Cantera::XML_Node::hasChild
bool hasChild(const std::string &ch) const
Tests whether the current node has a child node with a particular name.
Definition: xml.cpp:529
Cantera::XML_Node::lineNumber
int lineNumber() const
Return the line number.
Definition: xml.cpp:513
Cantera::XML_Node::build
void build(const std::string &filename)
Populate the XML tree from an input file.
Definition: xml.cpp:763
Cantera::XML_Node::operator()
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...
Definition: xml.cpp:452
Cantera::XML_Node::m_root
XML_Node * m_root
Pointer to the root XML_Node for the current node.
Definition: xml.h:681
Cantera::XML_Node::mergeAsChild
XML_Node & mergeAsChild(XML_Node &node)
Merge an existing node as a child node to the current node.
Definition: xml.cpp:383
Cantera::XML_Node::write_int
void write_int(std::ostream &s, int level=0, int numRecursivesAllowed=60000) const
Write an XML subtree to an output stream.
Definition: xml.cpp:921
Cantera::XML_Node::id
std::string id() const
Return the id attribute, if present.
Definition: xml.cpp:539
Cantera::XML_Node::root
XML_Node & root() const
Return the root of the current XML_Node tree.
Definition: xml.cpp:750
Cantera::XML_Node::addValue
void addValue(const std::string &val)
Modify the value for the current node.
Definition: xml.cpp:429
Cantera::XML_Node::attribs
std::map< std::string, std::string > & attribs()
Returns a changeable value of the attributes map for the current node.
Definition: xml.cpp:498
Cantera::XML_Node::m_linenum
int m_linenum
The member data m_linenum.
Definition: xml.h:700
Cantera::XML_Node::m_parent
XML_Node * m_parent
Pointer to the parent XML_Node for the current node.
Definition: xml.h:675
Cantera::XML_Node::addAttribute
void addAttribute(const std::string &attrib, const std::string &value)
Add or modify an attribute of the current node.
Definition: xml.cpp:467
Cantera::XML_Node::m_locked
bool m_locked
Lock for this node.
Definition: xml.h:688
Cantera::XML_Node::copyUnion
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,...
Definition: xml.cpp:833
Cantera::XML_Node::m_iscomment
bool m_iscomment
True if the current node is a comment node.
Definition: xml.h:694
Cantera::XML_Node::findByName
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.
Definition: xml.cpp:680
Cantera::XML_Node::int_value
integer int_value() const
Return the value of an XML node as a single int.
Definition: xml.cpp:462
Cantera::XML_Node::unlock
void unlock()
Unset the lock for this node and all of its children.
Definition: xml.cpp:908
Cantera::XML_Node::write
void write(std::ostream &s, const int level=0, int numRecursivesAllowed=60000) const
Write an XML subtree to an output stream.
Definition: xml.cpp:1038
Cantera::XML_Node::_require
void _require(const std::string &a, const std::string &v) const
Require that the current XML node has an attribute named by the first argument, a,...
Definition: xml.cpp:577
Cantera::XML_Node::fp_value
doublereal fp_value() const
Return the value of an XML node as a single double.
Definition: xml.cpp:457
Cantera::XML_Node::writeHeader
void writeHeader(std::ostream &s)
Write the header to the XML file to the specified ostream.
Definition: xml.cpp:916
Cantera::XML_Node::lock
void lock()
Set the lock for this node and all of its children.
Definition: xml.cpp:900
Cantera::XML_Node::findID
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 "id".
Definition: xml.cpp:646
Cantera::XML_Node::m_childindex
std::multimap< std::string, XML_Node * > m_childindex
Map containing an index between the node name and the pointer to the node.
Definition: xml.h:663
Cantera::XML_Node::children
const std::vector< XML_Node * > & children() const
Return an unchangeable reference to the vector of children of the current node.
Definition: xml.cpp:552
Cantera::XML_Node::findNameIDIndex
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 the XML element name, the attribute ID and...
Definition: xml.cpp:617
Cantera::XML_Node::setLineNumber
void setLineNumber(const int n)
Set the line number.
Definition: xml.cpp:508
Cantera::XML_Node::parent
XML_Node * parent() const
Returns a pointer to the parent node of the current node.
Definition: xml.cpp:518
Cantera::XML_Node::m_filename
std::string m_filename
Name of the file from which this XML node was read.
Definition: xml.h:654
Cantera::XML_Node::clear
void clear()
Clear the current node and everything under it.
Definition: xml.cpp:366
Cantera::XML_Node::addComment
void addComment(const std::string &comment)
Add a child node to the current node containing a comment.
Definition: xml.cpp:424
Cantera::XML_Node::attribsConst
const std::map< std::string, std::string > & attribsConst() const
Returns an unchangeable value of the attributes map for the current node.
Definition: xml.cpp:503
Cantera::XML_Node::getChildren
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...
Definition: xml.cpp:712
Cantera::XML_Node::value
std::string value() const
Return the value of an XML node as a string.
Definition: xml.cpp:442
Cantera::XML_Node::findNameID
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...
Definition: xml.cpp:587
Cantera::XML_Node::operator[]
std::string operator[](const std::string &attr) const
The operator[] is overloaded to provide a lookup capability on attributes for the current XML element...
Definition: xml.cpp:488
Cantera::XML_Node::m_value
std::string m_value
Value of the XML node.
Definition: xml.h:650
Cantera::XML_Node::nChildren
size_t nChildren(bool discardComments=false) const
Return the number of children.
Definition: xml.cpp:557
Cantera::XML_Node::setParent
XML_Node * setParent(XML_Node *const p)
Sets the pointer for the parent node of the current node.
Definition: xml.cpp:523
Cantera::XML_Node::m_name
std::string m_name
XML node name of the node.
Definition: xml.h:637
Cantera::XML_Node::child
XML_Node & child(const size_t n) const
Return a changeable reference to the n'th child of the current node.
Definition: xml.cpp:547
Cantera::XML_Node::setRoot
void setRoot(const XML_Node &root)
Set the root XML_Node value within the current node.
Definition: xml.cpp:755
Cantera::XML_Node::m_children
std::vector< XML_Node * > m_children
Vector of pointers to child nodes.
Definition: xml.h:691
Cantera::XML_Node::isComment
bool isComment() const
Boolean function indicating whether a comment.
Definition: xml.cpp:572
Cantera::XML_Node::hasAttrib
bool hasAttrib(const std::string &a) const
Tests whether the current node has an attribute with a particular name.
Definition: xml.cpp:534
Cantera::XML_Reader
Class XML_Reader reads an XML file into an XML_Node object.
Definition: xml.h:30
Cantera::XML_Reader::readTag
std::string readTag(std::map< std::string, std::string > &attribs)
Reads an XML tag into a string.
Definition: xml.cpp:232
Cantera::XML_Reader::m_line
int m_line
Line count.
Definition: xml.h:91
Cantera::XML_Reader::getchr
void getchr(char &ch)
Read a single character from the input stream and returns it.
Definition: xml.cpp:122
Cantera::XML_Reader::findQuotedString
int findQuotedString(const std::string &aline, std::string &rstring) const
Searches a string for the first occurrence of a valid quoted string.
Definition: xml.cpp:158
Cantera::XML_Reader::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.
Definition: xml.cpp:193
Cantera::XML_Reader::XML_Reader
XML_Reader(std::istream &input)
Sole Constructor for the XML_Reader class.
Definition: xml.cpp:116
Cantera::XML_Reader::m_s
std::istream & m_s
Input stream containing the XML file.
Definition: xml.h:87
Cantera::XML_Reader::readValue
std::string readValue()
Return the value portion of an XML element.
Definition: xml.cpp:279
ct_defs.h
This file contains definitions of constants, types and terms that are used in internal routines and a...
Cantera
Namespace for the Cantera kernel.
Definition: AnyMap.cpp:557
Cantera::findXMLPhase
XML_Node * findXMLPhase(XML_Node *root, const std::string &phaseId)
Search an XML_Node tree for a named phase XML_Node.
Definition: xml.cpp:1049
fmt
Versions 6.2.0 and 6.2.1 of fmtlib do not include this define before they include windows....
Definition: fmt.h:31