Jpp
Functions
JPrintDB.cc File Reference
#include <iostream>
#include <iomanip>
#include "KM3NeTDBClient.h"
#include "JDB/JDB.hh"
#include "JDB/JSelector.hh"
#include "Jeep/JParser.hh"
#include "Jeep/JMessage.hh"

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Detailed Description

Auxiliary program to print data from data base.

Author
mdejong

Definition in file JPrintDB.cc.

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 18 of file JPrintDB.cc.

19 {
20  using namespace std;
21  using namespace JPP;
22 
23  string usr;
24  string pwd;
25  string cookie;
26  string query;
27  JSelector selection;
28  int width;
29  int debug;
30 
31  try {
32 
33  JParser<> zap("Auxiliary program to print data from data base.");
34 
35  zap['u'] = make_field(usr) = "";
36  zap['!'] = make_field(pwd) = "";
37  zap['C'] = make_field(cookie) = "";
38  zap['q'] = make_field(query) = "";
39  zap['@'] = make_field(selection) = JPARSER::initialised();
40  zap['W'] = make_field(width) = 16;
41  zap['d'] = make_field(debug) = 1;
42 
43  zap(argc, argv);
44  }
45  catch(const exception &error) {
46  FATAL(error.what() << endl);
47  }
48 
49  DEBUG("Selection:" << endl << selection << endl);
50 
51  try {
52 
53  JDB::reset(usr, pwd, cookie);
54 
55  ResultSet& rs = getResultSet(query, selection);
56 
57  for (unsigned int i = 0; i != rs.FieldCount(); ++i) {
58  cout << ' ' << setw(width) << left << rs.FieldName(i);
59  }
60  cout << endl;
61 
62  while (rs.Next()) {
63  for (unsigned int i = 0; i != rs.FieldCount(); ++i) {
64  cout << ' ' << setw(width) << left << rs.GetString(i);
65  }
66  cout << endl;
67  }
68  }
69  catch(const exception& error) {
70  FATAL(error.what() << endl);
71  }
72 
73  return 0;
74 }
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
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
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