Cantera  2.0
cti2ctml.cpp
Go to the documentation of this file.
1 /**
2  * @file cti2ctml.cpp
3  */
4 
5 #include <iostream>
6 #include <string>
7 #include <vector>
8 
9 #include "cantera/base/ct_defs.h"
10 #include "cantera/base/xml.h"
11 #include "cantera/base/ctml.h"
12 
13 using namespace Cantera;
14 using namespace std;
15 
16 
17 /*****************************************************************/
18 /*****************************************************************/
19 /*****************************************************************/
20 static void printUsage()
21 {
22  cout << "cti2ctml [-h] infile.cti" << endl;
23  cout << " Translates a cti formated file to an xml file" << endl;
24  cout << " The xml file will be named ./basename(infile).xml" << endl;
25  cout << " - It will always be written to the current directory" << endl;
26 }
27 
28 
29 
30 /*****************************************************************/
31 
32 
33 int main(int argc, char** argv)
34 {
35  std::string infile;
36  // look for command-line options
37  if (argc > 1) {
38  std::string tok;
39  for (int j = 1; j < argc; j++) {
40  tok = string(argv[j]);
41  if (tok[0] == '-') {
42  int nopt = static_cast<int>(tok.size());
43  for (int n = 1; n < nopt; n++) {
44  if (tok[n] == 'h') {
45  printUsage();
46  exit(0);
47  } else {
48  printUsage();
49  exit(1);
50  }
51  }
52  } else if (infile == "") {
53  infile = tok;
54  } else {
55  printUsage();
56  exit(1);
57  }
58  }
59  }
60  if (infile == "") {
61  printUsage();
62  exit(1);
63  }
64 
65  try {
66  XML_Node* xc = new XML_Node();
67  std::string path = findInputFile(infile);
68  ctml::get_CTML_Tree(xc, path, 0);
69  //XML_Node *xd = new XML_Node();
70  //xc->copy(xd);
71 
72  } catch (CanteraError& err) {
73  std::cout << err.what() << std::endl;
74  }
75 
76  return 0;
77 }
78 /***********************************************************/