Cantera  2.1.2
ctml.cpp
Go to the documentation of this file.
1 /**
2  * @file ctml.cpp
3  * Definitions for functions to read and write CTML.
4  */
5 // Copyright 2002 California Institute of Technology
6 
7 #include "cantera/base/ctml.h"
8 
9 //@{
10 #define CTML_VERSION_1_4_1
11 //@}
12 
13 #include "cantera/base/global.h"
15 
16 using namespace std;
17 using namespace Cantera;
18 
19 namespace ctml
20 {
21 std::string FP_Format = "%23.15E";
22 std::string INT_Format = "%8d";
23 
24 void addInteger(Cantera::XML_Node& node, const std::string& title, const int val,
25  const std::string& units, const std::string& type)
26 {
27 #ifdef CTML_VERSION_1_4
28  XML_Node& f = node.addChild("integer", val);
29  f.addAttribute("title", title);
30 #else
31  XML_Node& f = node.addChild(title, val);
32 #endif
33  f.addAttribute("vtype", "integer");
34  if (type != "") {
35  f.addAttribute("type",type);
36  }
37  if (units != "") {
38  f.addAttribute("units",units);
39  }
40 }
41 
42 void addFloat(Cantera::XML_Node& node, const std::string& title,
43  const doublereal val, const std::string& units,
44  const std::string& type, const doublereal minval,
45  const doublereal maxval)
46 {
47 #ifdef CTML_VERSION_1_4
48  XML_Node& f = node.addChild("float", val, ctml::FP_Format);
49  f.addAttribute("title", title);
50 #else
51  XML_Node& f = node.addChild(title, val, ctml::FP_Format);
52 #endif
53  if (type != "") {
54  f.addAttribute("type",type);
55  }
56  if (units != "") {
57  f.addAttribute("units",units);
58  }
59  f.addAttribute("vtype", "float");
60  if (minval != Undef) {
61  f.addAttribute("min",minval);
62  }
63  if (maxval != Undef) {
64  f.addAttribute("max",maxval);
65  }
66 }
67 
68 void addFloatArray(Cantera::XML_Node& node, const std::string& title, const size_t n,
69  const doublereal* const vals, const std::string& units,
70  const std::string& type,
71  const doublereal minval, const doublereal maxval)
72 {
73  size_t i;
74  std::string v = "";
75  for (i = 0; i < n; i++) {
76  v += fp2str(vals[i],FP_Format);
77  if (i == n-1) {
78  v += "\n";
79  } else if (i > 0 && (i+1) % 3 == 0) {
80  v += ",\n";
81  } else {
82  v += ", ";
83  }
84  }
85  XML_Node& f = node.addChild("floatArray",v);
86  f.addAttribute("title",title);
87  if (type != "") {
88  f.addAttribute("type",type);
89  }
90  f.addAttribute("size", double(n));
91  if (units != "") {
92  f.addAttribute("units",units);
93  }
94  if (minval != Undef) {
95  f.addAttribute("min",minval);
96  }
97  if (maxval != Undef) {
98  f.addAttribute("max",maxval);
99  }
100 }
101 
102 void addNamedFloatArray(Cantera::XML_Node& node, const std::string& name, const int n,
103  const doublereal* const vals, const std::string units,
104  const std::string type, const doublereal minval,
105  const doublereal maxval)
106 {
107  int i;
108  std::string v = "";
109  for (i = 0; i < n; i++) {
110  v += fp2str(vals[i],FP_Format);
111  if (i == n-1) {
112  v += "\n";
113  } else if (i > 0 && (i+1) % 3 == 0) {
114  v += ",\n";
115  } else {
116  v += ", ";
117  }
118  }
119  XML_Node& f = node.addChild(name, v);
120  if (type != "") {
121  f.addAttribute("type",type);
122  }
123  /*
124  * Add vtype, which indicates the type of the value. Here we specify it as a list of floats separated
125  * by commas, with a length given by size attribute.
126  */
127  f.addAttribute("vtype", "floatArray");
128 
129  f.addAttribute("size", n);
130  if (units != "") {
131  f.addAttribute("units", units);
132  }
133  if (minval != Undef) {
134  f.addAttribute("min", minval);
135  }
136  if (maxval != Undef) {
137  f.addAttribute("max", maxval);
138  }
139 }
140 
141 void addString(Cantera::XML_Node& node, const std::string& titleString,
142  const std::string& valueString,
143  const std::string& typeString)
144 {
145  XML_Node& f = node.addChild("string", valueString);
146  f.addAttribute("title", titleString);
147  if (typeString != "") {
148  f.addAttribute("type", typeString);
149  }
150 }
151 
152 XML_Node* getByTitle(const Cantera::XML_Node& node, const std::string& title)
153 {
154  XML_Node* s = node.findByAttr("title", title);
155  if (!s) {
156  return 0;
157  }
158  if (s->parent() == &node) {
159  return s;
160  }
161  return 0;
162 }
163 
164 std::string getChildValue(const Cantera::XML_Node& parent, const std::string& nameString)
165 {
166  if (!parent.hasChild(nameString)) {
167  return "";
168  }
169  return parent(nameString);
170 }
171 
172 void getString(const Cantera::XML_Node& node, const std::string& titleString, std::string& valueString,
173  std::string& typeString)
174 {
175  valueString = "";
176  typeString = "";
177  XML_Node* s = getByTitle(node, titleString);
178  if (s)
179  if (s->name() == "string") {
180  valueString = (*s).value();
181  typeString = (*s)["type"];
182  return;
183  }
184 }
185 
186 void getNamedStringValue(const Cantera::XML_Node& node, const std::string& nameString, std::string& valueString,
187  std::string& typeString)
188 {
189  valueString = "";
190  typeString = "";
191  if (node.hasChild(nameString)) {
192  XML_Node& xc = node.child(nameString);
193  valueString = xc.value();
194  typeString = xc["type"];
195  } else {
196  XML_Node* s = getByTitle(node, nameString);
197  if (s) {
198  if (s->name() == "string") {
199  valueString = (*s).value();
200  typeString = (*s)["type"];
201  return;
202  }
203  }
204  }
205 }
206 
208  std::map<std::string, int>& v)
209 {
210  std::vector<XML_Node*> f;
211  node.getChildren("integer",f);
212  int n = static_cast<int>(f.size());
213  integer x;
214  std::string typ, title, vmin, vmax;
215  for (int i = 0; i < n; i++) {
216  const XML_Node& fi = *(f[i]);
217  x = atoi(fi().c_str());
218  title = fi["title"];
219  vmin = fi["min"];
220  vmax = fi["max"];
221  if (vmin != "")
222  if (fi["max"] != "") {
223  v[title] = x;
224  }
225  }
226 }
227 
228 void getFloats(const Cantera::XML_Node& node, std::map<std::string, double>& v,
229  const bool convert)
230 {
231  warn_deprecated("ctml::getFloats",
232  "To be removed in Cantera 2.2.");
233  std::vector<XML_Node*> f;
234  node.getChildren("float",f);
235  int n = static_cast<int>(f.size());
236  doublereal x, x0, x1, fctr;
237  std::string typ, title, units, vmin, vmax;
238  for (int i = 0; i < n; i++) {
239  const XML_Node& fi = *(f[i]);
240  x = fpValue(fi());
241  x0 = Undef;
242  x1 = Undef;
243  typ = fi["type"];
244  title = fi["title"];
245  units = fi["units"];
246  vmin = fi["min"];
247  vmax = fi["max"];
248  if (vmin != "") {
249  x0 = fpValue(vmin);
250  if (x < x0 - Tiny) {
251  writelog("\nWarning: value "+fi()+" is below lower limit of "
252  +vmin+".\n");
253  }
254  }
255  if (fi["max"] != "") {
256  x1 = fpValue(vmax);
257  if (x > x1 + Tiny) {
258  writelog("\nWarning: value "+fi()+" is above upper limit of "
259  +vmax+".\n");
260  }
261  }
262  fctr = (convert ? toSI(units) : 1.0); // toSI(typ,units);
263  v[title] = fctr*x;
264  }
265 }
266 
267 doublereal getFloat(const Cantera::XML_Node& parent,
268  const std::string& name,
269  const std::string& type)
270 {
271  if (!parent.hasChild(name))
272  throw CanteraError("getFloat (called from XML Node \"" +
273  parent.name() + "\"): ",
274  "no child XML element named \"" + name + "\" exists");
275  const XML_Node& node = parent.child(name);
276  return getFloatCurrent(node, type);
277 }
278 
279 doublereal getFloatCurrent(const Cantera::XML_Node& node,
280  const std::string& type)
281 {
282  doublereal x, x0, x1, fctr = 1.0;
283  string units, vmin, vmax;
284  x = fpValue(node());
285  x0 = Undef;
286  x1 = Undef;
287  units = node["units"];
288  vmin = node["min"];
289  vmax = node["max"];
290  if (vmin != "") {
291  x0 = fpValue(vmin);
292  if (x < x0 - Tiny) {
293  writelog("\nWarning: value "+node()+" is below lower limit of "
294  +vmin+".\n");
295  }
296  }
297  if (node["max"] != "") {
298  x1 = fpValue(vmax);
299  if (x > x1 + Tiny) {
300  writelog("\nWarning: value "+node()+" is above upper limit of "
301  +vmax+".\n");
302  }
303  }
304  // Note, most types of converters default to toSI() type atm.
305  // This may change and become more specific in the future.
306  if (type == "actEnergy" && units != "") {
307  fctr = actEnergyToSI(units);
308  } else if (type == "toSI" && units != "") {
309  fctr = toSI(units);
310  } else if (type == "temperature" && units != "") {
311  fctr = toSI(units);
312  } else if (type == "density" && units != "") {
313  fctr = toSI(units);
314  } else if (type == "pressure" && units != "") {
315  fctr = toSI(units);
316  } else if (type != "" && units != "") {
317  fctr = toSI(units);
318 #ifdef DEBUG_MODE
319  writelog("\nWarning: conversion toSI() was done on node value " + node.name() +
320  "but wasn't explicitly requested. Type was \"" + type + "\"\n");
321 #endif
322  }
323  // Note, below currently produces a lot of output due to transport blocks.
324  // This needs to be addressed.
325 #ifdef DEBUG_MODE_MORE
326  else if (type == "" && units != "") {
327  writelog("\nWarning: XML node " + node.name() +
328  "has a units attribute, \"" + units + "\","
329  "but no conversion was done because the getFloat() command didn't have a type\n");
330  }
331 #endif
332  return fctr*x;
333 }
334 
336  const std::string& name,
337  doublereal& fltRtn,
338  const std::string& type)
339 {
340  if (parent.hasChild(name)) {
341  fltRtn= getFloat(parent, name, type);
342  return true;
343  }
344  return false;
345 }
346 
347 doublereal getFloatDefaultUnits(const Cantera::XML_Node& parent,
348  const std::string& name,
349  const std::string& defaultUnits,
350  const std::string& type)
351 {
352  doublereal fctr = 1.0;
353  if (defaultUnits == "") {
354  throw CanteraError("getFloatDefaultUnits",
355  "need to supply an actual value of defaultUnits");
356  }
357  if (type == "actEnergy") {
358  fctr = actEnergyToSI(defaultUnits);
359  } else if (type == "toSI") {
360  fctr = toSI(defaultUnits);
361  } else if (defaultUnits == "temperature") {
362  fctr = toSI(defaultUnits);
363  } else if (type == "density") {
364  fctr = toSI(defaultUnits);
365  } else if (type == "pressure") {
366  fctr = toSI(defaultUnits);
367  } else {
368  throw CanteraError("getFloatDefaultUnits",
369  "type of units must be supplied and understood");
370  }
371  doublereal val = getFloat(parent, name, type);
372  val /= fctr;
373  return val;
374 }
375 
376 bool getOptionalModel(const Cantera::XML_Node& parent, const std::string& nodeName,
377  std::string& modelName)
378 {
379  if (parent.hasChild(nodeName)) {
380  const XML_Node& node = parent.child(nodeName);
381  modelName = node["model"];
382  return true;
383  }
384  return false;
385 }
386 
387 int getInteger(const Cantera::XML_Node& parent, const std::string& name)
388 {
389  if (!parent.hasChild(name)) {
390  throw CanteraError("getInteger (called from XML Node \"" +
391  parent.name() + "\"): ",
392  "no child XML element named " + name);
393  }
394  const XML_Node& node = parent.child(name);
395  int x, x0, x1;
396  string units, vmin, vmax;
397  x = atoi(node().c_str());
398  x0 = -9999999;
399  x1 = 9999999;
400  vmin = node["min"];
401  vmax = node["max"];
402  if (vmin != "") {
403  x0 = atoi(vmin.c_str());
404  if (x < x0) {
405  writelog("\nWarning: value "+node()+" is below lower limit of "
406  +vmin+".\n");
407  }
408  }
409  if (node["max"] != "") {
410  x1 = atoi(vmax.c_str());
411  if (x > x1) {
412  writelog("\nWarning: value "+node()+" is above upper limit of "
413  +vmax+".\n");
414  }
415  }
416  return x;
417 }
418 
419 size_t getFloatArray(const Cantera::XML_Node& node, std::vector<doublereal> & v,
420  const bool convert, const std::string& unitsString,
421  const std::string& nodeName)
422 {
423  std::string::size_type icom;
424  string numstr;
425  doublereal dtmp;
426  string nn = node.name();
427  const Cantera::XML_Node* readNode = &node;
428  if (nn != nodeName) {
429  vector<Cantera::XML_Node*> ll;
430  node.getChildren(nodeName, ll);
431  if (ll.size() == 0) {
432  throw CanteraError("getFloatArray",
433  "wrong xml element type/name: was expecting "
434  + nodeName + "but accessed " + node.name());
435  } else {
436  readNode = ll[0];
437  ll.clear();
438  readNode->getChildren("floatArray", ll);
439  if (ll.size() > 0) {
440  readNode = ll[0];
441  }
442  }
443  }
444 
445  v.clear();
446  doublereal vmin = Undef, vmax = Undef;
447 
448  doublereal funit = 1.0;
449  /*
450  * Get the attributes field, units, from the XML node
451  */
452  std::string units = (*readNode)["units"];
453  if (units != "" && convert) {
454  if (unitsString == "actEnergy" && units != "") {
455  funit = actEnergyToSI(units);
456  } else if (unitsString != "" && units != "") {
457  funit = toSI(units);
458  }
459  }
460 
461  if ((*readNode)["min"] != "") {
462  vmin = fpValueCheck((*readNode)["min"]);
463  }
464  if ((*readNode)["max"] != "") {
465  vmax = fpValueCheck((*readNode)["max"]);
466  }
467 
468  doublereal vv;
469  std::string val = readNode->value();
470  while (1 > 0) {
471  icom = val.find(',');
472  if (icom != string::npos) {
473  numstr = val.substr(0,icom);
474  val = val.substr(icom+1,val.size());
475  dtmp = fpValueCheck(numstr);
476  v.push_back(dtmp);
477  } else {
478  /*
479  * This little bit of code is to allow for the
480  * possibility of a comma being the last
481  * item in the value text. This was allowed in
482  * previous versions of Cantera, even though it
483  * would appear to be odd. So, we keep the
484  * possibility in for backwards compatibility.
485  */
486  if (!val.empty()) {
487  dtmp = fpValueCheck(val);
488  v.push_back(dtmp);
489  }
490  break;
491  }
492  vv = v.back();
493  if (vmin != Undef && vv < vmin - Tiny) {
494  writelog("\nWarning: value "+fp2str(vv)+
495  " is below lower limit of " +fp2str(vmin)+".\n");
496  }
497  if (vmax != Undef && vv > vmax + Tiny) {
498  writelog("\nWarning: value "+fp2str(vv)+
499  " is above upper limit of " +fp2str(vmin)+".\n");
500  }
501  }
502  for (size_t n = 0; n < v.size(); n++) {
503  v[n] *= funit;
504  }
505  return v.size();
506 }
507 
508 void getMap(const Cantera::XML_Node& node, std::map<std::string, std::string>& m)
509 {
510  std::vector<std::string> v;
511  getStringArray(node, v);
512  std::string key, val;
513  int n = static_cast<int>(v.size());
514  string::size_type icolon;
515  for (int i = 0; i < n; i++) {
516  icolon = v[i].find(":");
517  if (icolon == string::npos) {
518  throw CanteraError("getMap","missing colon in map entry ("
519  +v[i]+")");
520  }
521  key = v[i].substr(0,icolon);
522  val = v[i].substr(icolon+1, v[i].size());
523  m[key] = val;
524  }
525 }
526 
527 int getPairs(const Cantera::XML_Node& node, std::vector<std::string>& key,
528  std::vector<std::string>& val)
529 {
530  vector<string> v;
531  getStringArray(node, v);
532  int n = static_cast<int>(v.size());
533  string::size_type icolon;
534  for (int i = 0; i < n; i++) {
535  icolon = v[i].find(":");
536  if (icolon == string::npos) {
537  throw CanteraError("getPairs","Missing a colon in the Pair entry ("
538  +v[i]+")");
539  }
540  key.push_back(v[i].substr(0,icolon));
541  val.push_back(v[i].substr(icolon+1, v[i].size()));
542  //cout << "getPairs: " << key.back() << " " << val.back() << endl;
543  }
544  return n;
545 }
546 
548  const std::vector<std::string>& keyStringRow,
549  const std::vector<std::string>& keyStringCol,
550  Cantera::Array2D& retnValues, const bool convert,
551  const bool matrixSymmetric)
552 {
553  size_t szKey1 = keyStringRow.size();
554  size_t szKey2 = keyStringCol.size();
555  size_t nrow = retnValues.nRows();
556  size_t ncol = retnValues.nColumns();
557  if (szKey1 > nrow) {
558  throw CanteraError("getMatrixValues",
559  "size of key1 greater than numrows");
560  }
561  if (szKey2 > ncol) {
562  throw CanteraError("getMatrixValues",
563  "size of key2 greater than num cols");
564  }
565  if (matrixSymmetric) {
566  if (nrow != ncol) {
567  throw CanteraError("getMatrixValues",
568  "nrow != ncol for a symmetric matrix");
569  }
570  }
571 
572  /*
573  * Get the attributes field, units, from the XML node
574  * and determine the conversion factor, funit.
575  */
576  doublereal funit = 1.0;
577  string units = node["units"];
578  if (units != "" && convert) {
579  funit = toSI(units);
580  }
581 
582  string key1;
583  string key2;
584  string rmm;
585  string val;
586  vector<string> v;
587  getStringArray(node, v);
588  string::size_type icolon;
589  for (size_t i = 0; i < v.size(); i++) {
590  icolon = v[i].find(":");
591  if (icolon == string::npos) {
592  throw CanteraError("getMatrixValues","Missing two colons ("
593  +v[i]+")");
594  }
595  key1 = v[i].substr(0,icolon);
596  rmm = v[i].substr(icolon+1, v[i].size());
597  icolon = rmm.find(":");
598  if (icolon == string::npos) {
599  throw CanteraError("getMatrixValues","Missing one colon ("
600  +v[i]+")");
601  }
602  key2 = rmm.substr(0,icolon);
603  val = rmm.substr(icolon+1, rmm.size());
604 
605  size_t icol = npos;
606  size_t irow = npos;
607  for (size_t j = 0; j < szKey1; j++) {
608  if (key1 == keyStringRow[j]) {
609  irow = j;
610  break;
611  }
612  }
613  if (irow == npos) {
614  throw CanteraError("getMatrixValues","Row not matched by string: "
615  + key1);
616  }
617  for (size_t j = 0; j < szKey2; j++) {
618  if (key2 == keyStringCol[j]) {
619  icol = j;
620  break;
621  }
622  }
623  if (icol == npos) {
624  throw CanteraError("getMatrixValues","Col not matched by string: "
625  + key2);
626  }
627  double dval = fpValueCheck(val);
628  dval *= funit;
629  /*
630  * Finally, insert the value;
631  */
632  retnValues(irow, icol) = dval;
633  if (matrixSymmetric) {
634  retnValues(icol, irow) = dval;
635  }
636  }
637 }
638 
639 void getStringArray(const Cantera::XML_Node& node, std::vector<std::string>& v)
640 {
641  std::string val = node.value();
642  tokenizeString(val, v);
643 }
644 
645 }
doublereal fpValue(const std::string &val)
Translate a string into one doublereal value.
size_t nRows() const
Number of rows.
Definition: Array.h:317
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:716
CTML ("Cantera Markup Language") is the variant of XML that Cantera uses to store data...
doublereal actEnergyToSI(const std::string &unit)
Return the conversion factor to convert activation energy unit std::string 'unit' to Kelvin...
Definition: global.cpp:207
doublereal toSI(const std::string &unit)
Return the conversion factor to convert unit std::string 'unit' to SI units.
Definition: global.cpp:196
const size_t npos
index returned by functions to indicate "no position"
Definition: ct_defs.h:173
void addNamedFloatArray(Cantera::XML_Node &node, const std::string &name, const int n, const doublereal *const vals, const std::string units, const std::string type, const doublereal minval, const doublereal maxval)
This function adds a child node with the name given by the first parameter with a value consisting of...
Definition: ctml.cpp:102
bool getOptionalModel(const Cantera::XML_Node &parent, const std::string &nodeName, std::string &modelName)
Get an optional model name from a named child node.
Definition: ctml.cpp:376
Class XML_Node is a tree-based representation of the contents of an XML file.
Definition: xml.h:100
bool getOptionalFloat(const Cantera::XML_Node &parent, const std::string &name, doublereal &fltRtn, const std::string &type)
Get an optional floating-point value from a child element.
Definition: ctml.cpp:335
void warn_deprecated(const std::string &method, const std::string &extra)
Print a warning indicating that method is deprecated.
Definition: global.cpp:76
doublereal getFloat(const Cantera::XML_Node &parent, const std::string &name, const std::string &type)
Get a floating-point value from a child element.
Definition: ctml.cpp:267
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).
void addString(Cantera::XML_Node &node, const std::string &titleString, const std::string &valueString, const std::string &typeString)
This function adds a child node with the name string with a string value to the current node...
Definition: ctml.cpp:141
XML_Node & child(const size_t n) const
Return a changeable reference to the n'th child of the current node.
Definition: xml.cpp:584
const doublereal Undef
Fairly random number to be used to initialize variables against to see if they are subsequently defin...
Definition: ct_defs.h:147
A class for 2D arrays stored in column-major (Fortran-compatible) form.
Definition: Array.h:33
XML_Node * getByTitle(const Cantera::XML_Node &node, const std::string &title)
Search the child nodes of the current node for an XML Node with a Title attribute of a given name...
Definition: ctml.cpp:152
std::string fp2str(const double x, const std::string &fmt)
Convert a double into a c++ string.
Definition: stringUtils.cpp:29
size_t nColumns() const
Number of columns.
Definition: Array.h:322
std::string name() const
Returns the name of the XML node.
Definition: xml.h:390
void tokenizeString(const std::string &oval, std::vector< std::string > &v)
This function separates a string up into tokens according to the location of white space...
void addFloatArray(Cantera::XML_Node &node, const std::string &title, const size_t n, const doublereal *const vals, const std::string &units, const std::string &type, const doublereal minval, const doublereal maxval)
This function adds a child node with the name, "floatArray", with a value consisting of a comma separ...
Definition: ctml.cpp:68
doublereal getFloatCurrent(const Cantera::XML_Node &node, const std::string &type)
Get a floating-point value from the current XML element.
Definition: ctml.cpp:279
void addFloat(Cantera::XML_Node &node, const std::string &title, const doublereal val, const std::string &units, const std::string &type, const doublereal minval, const doublereal maxval)
This function adds a child node with the name, "float", with a value consisting of a single floating ...
Definition: ctml.cpp:42
Base class for exceptions thrown by Cantera classes.
Definition: ctexceptions.h:68
int getPairs(const Cantera::XML_Node &node, std::vector< std::string > &key, std::vector< std::string > &val)
This function interprets the value portion of an XML element as a series of "Pairs" separated by whit...
Definition: ctml.cpp:527
void getString(const Cantera::XML_Node &node, const std::string &titleString, std::string &valueString, std::string &typeString)
This function reads a child node with the name string with a specific title attribute named titleStri...
Definition: ctml.cpp:172
bool hasChild(const std::string &ch) const
Tests whether the current node has a child node with a particular name.
Definition: xml.cpp:574
void getIntegers(const Cantera::XML_Node &node, std::map< std::string, int > &v)
Get a vector of integer values from a child element.
Definition: ctml.cpp:207
void getNamedStringValue(const Cantera::XML_Node &node, const std::string &nameString, std::string &valueString, std::string &typeString)
This function attempts to read a named child node and returns with the contents in the value string...
Definition: ctml.cpp:186
void addAttribute(const std::string &attrib, const std::string &value)
Add or modify an attribute of the current node.
Definition: xml.cpp:518
std::string value() const
Return the value of an XML node as a string.
Definition: xml.cpp:488
doublereal getFloatDefaultUnits(const Cantera::XML_Node &parent, const std::string &name, const std::string &defaultUnits, const std::string &type)
Get a floating-point value from a child element with a defined units field.
Definition: ctml.cpp:347
void getFloats(const Cantera::XML_Node &node, std::map< std::string, double > &v, const bool convert)
Get a vector of floating-point values from a child element.
Definition: ctml.cpp:228
void getStringArray(const Cantera::XML_Node &node, std::vector< std::string > &v)
This function interprets the value portion of an XML element as a string.
Definition: ctml.cpp:639
const doublereal Tiny
Small number to compare differences of mole fractions against.
Definition: ct_defs.h:155
void addInteger(Cantera::XML_Node &node, const std::string &title, const int val, const std::string &units, const std::string &type)
This function adds a child node with the name, "integer", with a value consisting of a single integer...
Definition: ctml.cpp:24
void getMatrixValues(const Cantera::XML_Node &node, const std::vector< std::string > &keyStringRow, const std::vector< std::string > &keyStringCol, Cantera::Array2D &retnValues, const bool convert, const bool matrixSymmetric)
This function interprets the value portion of an XML element as a series of "Matrix ids and entries" ...
Definition: ctml.cpp:547
Contains declarations for string manipulation functions within Cantera.
void writelog(const std::string &msg)
Write a message to the screen.
Definition: global.cpp:43
void getMap(const Cantera::XML_Node &node, std::map< std::string, std::string > &m)
This routine is used to interpret the value portions of XML elements that contain colon separated pai...
Definition: ctml.cpp:508
std::string getChildValue(const Cantera::XML_Node &parent, const std::string &nameString)
This function reads a child node with the name, nameString, and returns its xml value as the return s...
Definition: ctml.cpp:164
int getInteger(const Cantera::XML_Node &parent, const std::string &name)
Get an integer value from a child element.
Definition: ctml.cpp:387
XML_Node * parent() const
Returns a pointer to the parent node of the current node.
Definition: xml.cpp:563
doublereal fpValueCheck(const std::string &val)
Translate a string into one doublereal value, with error checking.
size_t getFloatArray(const Cantera::XML_Node &node, std::vector< doublereal > &v, const bool convert, const std::string &unitsString, const std::string &nodeName)
This function reads the current node or a child node of the current node with the default name...
Definition: ctml.cpp:419
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...
Definition: xml.cpp:916