Jpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
getLocationID.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/JPersons.hh"
8 #include "JDB/JSelector.hh"
9 #include "JDB/JDBToolkit.hh"
10 
11 #include "Jeep/JParser.hh"
12 #include "Jeep/JMessage.hh"
13 
14 
15 /**
16  * \file
17  *
18  * Auxiliary program to get location ID corresponding to given user login.
19  * \author bjung
20  */
21 int main(int argc, char **argv)
22 {
23  using namespace std;
24  using namespace JPP;
25 
26  string usr;
27  string pwd;
28  string cookie;
29  string login;
30  int debug;
31 
32  try {
33 
34  JParser<> zap("Auxiliary program to get location ID corresponding to given user login.");
35 
36  zap['u'] = make_field(usr) = "";
37  zap['!'] = make_field(pwd) = "";
38  zap['C'] = make_field(cookie) = "";
39  zap['L'] = make_field(login) = "";
40  zap['d'] = make_field(debug) = 1;
41 
42  zap(argc, argv);
43  }
44  catch(const exception &error) {
45  FATAL(error.what() << endl);
46  }
47 
48 
49  try {
50 
51  JDB::reset(usr, pwd, cookie);
52 
53  JSelector selector = getSelector<JPersons>(login.empty() ? JDB::get()->User() : login);
54  ResultSet& rs = getResultSet(getTable<JPersons>(), selector);
55 
56  JPersons personalia;
57  rs >> personalia;
58 
59  cout << personalia.LOCATIONID << endl;
60  }
61  catch(const exception& error) {
62  FATAL(error.what() << endl);
63  }
64 }
Utility class to parse command line options.
Definition: JParser.hh:1500
int main(int argc, char *argv[])
Definition: Main.cc:15
T get(const JHead &header)
Get object from header.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1961
int debug
debug level
Definition: JSirene.cc:63
General purpose messaging.
#define FATAL(A)
Definition: JMessage.hh:67
void reset(T &value)
Reset value.
Utility class to parse command line options.
ResultSet & getResultSet(const std::string &query)
Get result set.
Definition: JDB.hh:269