Jpp
JPrintDB.cc
Go to the documentation of this file.
1 #include <iostream>
2 #include <iomanip>
3 
4 #include "dbclient/KM3NeTDBClient.h"
5 
6 #include "JDB/JDB.hh"
7 #include "JDB/JSelector.hh"
8 
9 #include "Jeep/JParser.hh"
10 #include "Jeep/JMessage.hh"
11 
12 
13 /**
14  * \file
15  *
16  * Auxiliary program to print data from data base.
17  * \author mdejong
18  */
19 int main(int argc, char **argv)
20 {
21  using namespace std;
22  using namespace JPP;
23 
24  string usr;
25  string pwd;
26  string cookie;
27  string query;
28  JSelector selection;
29  int width;
30  int debug;
31 
32  try {
33 
34  JParser<> zap("Auxiliary program to print data from data base.");
35 
36  zap['u'] = make_field(usr) = "";
37  zap['!'] = make_field(pwd) = "";
38  zap['C'] = make_field(cookie) = "";
39  zap['q'] = make_field(query) = "";
40  zap['@'] = make_field(selection) = JPARSER::initialised();
41  zap['W'] = make_field(width) = 16;
42  zap['d'] = make_field(debug) = 1;
43 
44  zap(argc, argv);
45  }
46  catch(const exception &error) {
47  FATAL(error.what() << endl);
48  }
49 
50  DEBUG("Selection:" << endl << selection << endl);
51 
52  try {
53 
54  JDB::reset(usr, pwd, cookie);
55 
56  ResultSet& rs = getResultSet(query, selection);
57 
58  for (unsigned int i = 0; i != rs.FieldCount(); ++i) {
59  cout << ' ' << setw(width) << left << rs.FieldName(i);
60  }
61  cout << endl;
62 
63  while (rs.Next()) {
64  for (unsigned int i = 0; i != rs.FieldCount(); ++i) {
65  cout << ' ' << setw(width) << left << rs.GetString(i);
66  }
67  cout << endl;
68  }
69  }
70  catch(const exception& error) {
71  FATAL(error.what() << endl);
72  }
73 
74  return 0;
75 }
JMessage.hh
JSelector.hh
JPARSER::initialised
Empty structure for specification of parser element that is initialised (i.e.
Definition: JParser.hh:63
JPARSER::JParser
Utility class to parse command line options.
Definition: JParser.hh:1493
JDATABASE::getResultSet
ResultSet & getResultSet(const std::string &query)
Get result set.
Definition: JDB.hh:403
JPP
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Definition: JAAnetToolkit.hh:37
JDB.hh
main
int main(int argc, char **argv)
Definition: JPrintDB.cc:19
debug
int debug
debug level
Definition: JSirene.cc:59
JDETECTOR::reset
void reset(JCLBInput &data, size_t size)
Reset CLB buffers.
Definition: JCLBSimulator.hh:41
JParser.hh
make_field
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1954
DEBUG
#define DEBUG(A)
Message macros.
Definition: JMessage.hh:62
std
Definition: jaanetDictionary.h:36
FATAL
#define FATAL(A)
Definition: JMessage.hh:67