Jpp  18.5.0
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JProperties.cc
Go to the documentation of this file.
1 
2 #include <iostream>
3 #include <iomanip>
4 #include <fstream>
5 
6 #include "Jeep/JProperties.hh"
7 #include "Jeep/JParser.hh"
8 #include "Jeep/JMessage.hh"
9 
10 
11 /**
12  * Data structure for start_event tag.
13  */
14 struct JEvent {
15  int number;
16  int type;
17 
18  static int count; // global event counter
19 };
20 
21 
22 int JEvent::count = 0; // initialisation of global event counter
23 
24 
25 inline std::istream& operator>>(std::istream& in, JEvent& event)
26 {
27  JEvent::count += 1;
28 
29  return in >> event.number >> event.type;
30 }
31 
32 
33 inline std::ostream& operator<<(std::ostream& out, const JEvent& event)
34 {
35  return out << event.number << ' ' << event.type;
36 }
37 
38 
39 /**
40  * \file
41  * Example program to test JPROPERTIES::JProperties class.
42  * \author mdejong
43  */
44 int main(int argc, char **argv)
45 {
46  using namespace std;
47 
48  string inputFile;
49  int debug;
50 
51  try {
52 
53  JParser<> zap;
54 
55  zap['f'] = make_field(inputFile);
56  zap['d'] = make_field(debug) = 0;
57 
58  zap.read(argc, argv);
59  }
60  catch(const exception &error) {
61  FATAL(error.what() << endl);
62  }
63 
64  using namespace JPP;
65 
66  JEvent event;
67 
68  {
69  JProperties zap(JEquationParameters(":", "\n", "", ""), debug);
70 
71  zap["start_event"] = event;
72 
73  ifstream in(inputFile.c_str());
74 
75  zap.read(in);
76 
77  in.close();
78  }
79 
80  cout << "Number of events " << JEvent::count << endl;
81 }
Utility class to parse command line options.
Definition: JParser.hh:1514
bool read(const JEquation &equation)
Read equation.
Definition: JProperties.hh:679
int main(int argc, char *argv[])
Definition: Main.cc:15
Utility class to parse parameter values.
Definition: JProperties.hh:497
static int count
Definition: JProperties.cc:18
Simple data structure to support I/O of equations (see class JLANG::JEquation).
int type
Definition: JProperties.cc:16
Utility class to parse parameter values.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1989
int number
Definition: JProperties.cc:15
General purpose messaging.
#define FATAL(A)
Definition: JMessage.hh:67
std::istream & operator>>(std::istream &in, JAANET::JHead &header)
Read header from input.
Definition: JHead.hh:1829
int read(const int argc, const char *const argv[])
Parse the program&#39;s command line options.
Definition: JParser.hh:1811
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 JAcoustics sh $DETECTOR_ID source JAcousticsToolkit sh CHECK_EXIT_CODE typeset A EMITTERS get_tripods $WORKDIR tripod txt EMITTERS get_transmitters $WORKDIR transmitter txt EMITTERS for EMITTER in
Definition: JCanberra.sh:48
Utility class to parse command line options.
std::ostream & operator<<(std::ostream &stream, const CLBCommonHeader &header)
Data structure for start_event tag.
Definition: JProperties.cc:14
int debug
debug level