Cantera  2.1.2
cti2ctml.cpp
Go to the documentation of this file.
1 /**
2  * @file cti2ctml.cpp
3  */
4 
5 #include "cantera/base/ct_defs.h"
6 #include "cantera/base/xml.h"
7 #include "cantera/base/ctml.h"
8 
9 using namespace Cantera;
10 using namespace std;
11 
12 
13 /*****************************************************************/
14 /*****************************************************************/
15 /*****************************************************************/
16 static void printUsage()
17 {
18  cout << "cti2ctml [-h] infile.cti" << endl;
19  cout << " Translates a cti formated file to an xml file" << endl;
20  cout << " The xml file will be named ./basename(infile).xml" << endl;
21  cout << " - It will always be written to the current directory" << endl;
22 }
23 
24 
25 
26 /*****************************************************************/
27 
28 
29 int main(int argc, char** argv)
30 {
31  std::string infile;
32  // look for command-line options
33  if (argc > 1) {
34  std::string tok;
35  for (int j = 1; j < argc; j++) {
36  tok = string(argv[j]);
37  if (tok[0] == '-') {
38  int nopt = static_cast<int>(tok.size());
39  for (int n = 1; n < nopt; n++) {
40  if (tok[n] == 'h') {
41  printUsage();
42  exit(0);
43  } else {
44  printUsage();
45  exit(1);
46  }
47  }
48  } else if (infile == "") {
49  infile = tok;
50  } else {
51  printUsage();
52  exit(1);
53  }
54  }
55  }
56  if (infile == "") {
57  printUsage();
58  exit(1);
59  }
60 
61  try {
62  XML_Node* xc = new XML_Node();
63  std::string path = findInputFile(infile);
64  ctml::get_CTML_Tree(xc, path, 0);
65  //XML_Node *xd = new XML_Node();
66  //xc->copy(xd);
67 
68  } catch (CanteraError& err) {
69  std::cout << err.what() << std::endl;
70  }
71 
72  return 0;
73 }
74 /***********************************************************/
CTML ("Cantera Markup Language") is the variant of XML that Cantera uses to store data...
std::string findInputFile(const std::string &name)
Find an input file.
Definition: global.cpp:191
Class XML_Node is a tree-based representation of the contents of an XML file.
Definition: xml.h:100
This file contains definitions of terms that are used in internal routines and are unlikely to need m...
const char * what() const
Get a description of the error.
Classes providing support for XML data files.
Base class for exceptions thrown by Cantera classes.
Definition: ctexceptions.h:68
void get_CTML_Tree(Cantera::XML_Node *rootPtr, const std::string &file, const int debug)
Read an ctml file from a file and fill up an XML tree.
Definition: ct2ctml.cpp:219