Jpp  15.0.1-rc.2-highQE
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JEquation.cc
Go to the documentation of this file.
1 
2 #include <string>
3 #include <iostream>
4 #include <fstream>
5 #include <sstream>
6 #include <locale>
7 #include <iomanip>
8 #include <limits>
9 #include <iterator>
10 
11 #include "JLang/JException.hh"
12 #include "JLang/JEquation.hh"
13 
14 #include "Jeep/JParser.hh"
15 #include "Jeep/JMessage.hh"
16 
17 
18 /**
19  * \file
20  *
21  * Example program to test JLANG::JEquation class.
22  * \author mdejong
23  */
24 int main(int argc, char **argv)
25 {
26  using namespace std;
27 
28  string inputFile;
29  int debug;
30 
31  try {
32 
33  JParser<> zap("Example program to test equation parsing");
34 
35  zap['f'] = make_field(inputFile);
36  zap['d'] = make_field(debug) = 0;
37 
38  zap(argc, argv);
39  }
40  catch(const exception &error) {
41  FATAL(error.what() << endl);
42  }
43 
44 
45  using namespace JPP;
46 
47  const int KEY_WIDTH = 6;
48  const int VAL_WIDTH = 30;
49  const char SEP = '|';
50 
51  const JEquationFacet facet(JEquationParameters("=", ";\n", "./", "#"));
52 
53  ifstream in(inputFile.c_str());
54 
55  in.imbue(locale(in.getloc(), facet.clone()));
56 
57  cout << setw(4) << " " << ' '
58  << setw(KEY_WIDTH) << left << "key" << SEP << ' '
59  << setw(VAL_WIDTH) << left << "value" << endl;
60 
61  cout << setw(KEY_WIDTH + 5) << setfill('-') << left << "-"
62  << setw(VAL_WIDTH + 0) << setfill('-') << left << "+" << setfill(' ') << endl;
63 
64  for (JEquation equation; in >> equation; ) {
65 
66  int i = 0;
67 
68  for ( ; facet.isDivision(equation.getSeparator()); ++i) {
69 
70  cout << "[" << setw(2) << right << i << "]" << ' '
71  << setw(KEY_WIDTH) << left << equation.getKey() << SEP << ' '
72  << setw(VAL_WIDTH) << left << equation.getValue() << endl;
73 
74  equation.setEquation(facet);
75  }
76 
77  cout << "[" << setw(2) << right << i << "]" << ' '
78  << setw(KEY_WIDTH) << left << equation.getKey() << SEP << ' '
79  << setw(VAL_WIDTH) << left << equation.getValue() << endl;
80  }
81 
82  in.close();
83 }
Utility class to parse command line options.
Definition: JParser.hh:1500
Exceptions.
int main(int argc, char *argv[])
Definition: Main.cc:15
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1961
int debug
debug level
Definition: JSirene.cc:63
General purpose messaging.
#define FATAL(A)
Definition: JMessage.hh:67
Utility class to parse command line options.
then fatal Wrong number of arguments fi set_variable DETECTOR $argv[1] set_variable INPUT_FILE $argv[2] eval JPrintDetector a $DETECTOR O IDENTIFIER eval JPrintDetector a $DETECTOR O SUMMARY source JAcoustics sh $DETECTOR_ID CHECK_EXIT_CODE typeset A TRIPODS get_tripods $WORKDIR tripod txt TRIPODS for EMITTER in
Definition: JCanberra.sh:41