Jpp test-rotations-old
the software that should make you happy
Loading...
Searching...
No Matches
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 */
14struct JEvent {
15 int number;
16 int type;
17
18 static int count; // global event counter
19};
20
21
22int JEvent::count = 0; // initialisation of global event counter
23
24
25inline std::istream& operator>>(std::istream& in, JEvent& event)
26{
27 JEvent::count += 1;
28
29 return in >> event.number >> event.type;
30}
31
32
33inline 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 */
44int 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}
General purpose messaging.
#define FATAL(A)
Definition JMessage.hh:67
int debug
debug level
Definition JSirene.cc:72
Utility class to parse command line options.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition JParser.hh:2142
int main(int argc, char **argv)
std::ostream & operator<<(std::ostream &out, const JEvent &event)
std::istream & operator>>(std::istream &in, JEvent &event)
Utility class to parse parameter values.
Utility class to parse parameter values.
bool read(const JEquation &equation)
Read equation.
Simple data structure to support I/O of equations (see class JLANG::JEquation).
Utility class to parse command line options.
Definition JParser.hh:1698
int read(const int argc, const char *const argv[])
Parse the program's command line options.
Definition JParser.hh:1992
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Data structure for start_event tag.
int number
static int count