Jpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Functions
JPrintDB.cc File Reference

Auxiliary program to print data from data base. More...

#include <iostream>
#include <iomanip>
#include "dbclient/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

int main ( int  argc,
char **  argv 
)

Definition at line 19 of file JPrintDB.cc.

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) << flush;
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) << flush;
66  }
67 
68  cout << endl;
69  }
70  }
71  catch(const exception& error) {
72  FATAL(error.what() << endl);
73  }
74 
75  return 0;
76 }
Utility class to parse command line options.
Definition: JParser.hh:1500
Empty structure for specification of parser element that is initialised (i.e. does not require input)...
Definition: JParser.hh:66
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1961
int debug
debug level
Definition: JSirene.cc:63
#define FATAL(A)
Definition: JMessage.hh:67
void reset(T &value)
Reset value.
ResultSet & getResultSet(const std::string &query)
Get result set.
Definition: JDB.hh:269
#define DEBUG(A)
Message macros.
Definition: JMessage.hh:62