Jpp  15.0.1-rc.2-highQE
the software that should make you happy
 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  JServer server;
25  string usr;
26  string pwd;
27  string cookie;
28  string query;
29  JSelector selection;
30  int width;
31  int debug;
32 
33  try {
34 
35  JParser<> zap("Auxiliary program to print data from data base.");
36 
37  zap['s'] = make_field(server) = getServernames();
38  zap['u'] = make_field(usr) = "";
39  zap['!'] = make_field(pwd) = "";
40  zap['C'] = make_field(cookie) = "";
41  zap['q'] = make_field(query) = "";
42  zap['@'] = make_field(selection) = JPARSER::initialised();
43  zap['W'] = make_field(width) = 16;
44  zap['d'] = make_field(debug) = 1;
45 
46  zap(argc, argv);
47  }
48  catch(const exception &error) {
49  FATAL(error.what() << endl);
50  }
51 
52  DEBUG("Server: " << JDB::getServer().HostName() << endl);
53  DEBUG("Selection:" << endl << selection << endl);
54 
55  try {
56 
57  JDB::reset(usr, pwd, cookie);
58 
59  ResultSet& rs = getResultSet(query, selection);
60 
61  for (unsigned int i = 0; i != rs.FieldCount(); ++i) {
62  cout << ' ' << setw(width) << left << rs.FieldName(i) << flush;
63  }
64  cout << endl;
65 
66  while (rs.Next()) {
67  for (unsigned int i = 0; i != rs.FieldCount(); ++i) {
68  cout << ' ' << setw(width) << left << rs.GetString(i) << flush;
69  }
70 
71  cout << endl;
72  }
73  }
74  catch(const exception& error) {
75  FATAL(error.what() << endl);
76  }
77 
78  return 0;
79 }
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
const Server & getServer(const std::string &server)
Get server by name.
Definition: JDB.hh:81
#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.
then usage $script< input_file >< detector_file > fi set_variable OUTPUT_DIR set_variable SELECTOR JDAQTimesliceL1 set_variable DEBUG case set_variable DEBUG
ResultSet & getResultSet(const std::string &query)
Get result set.
Definition: JDB.hh:432
std::vector< JServer > getServernames()
Get list of names of available database servers.
Definition: JDB.hh:98