Jpp
18.0.1-rc.1
the software that should make you happy
Main Page
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
software
JDB
JPrintDB.cc
Go to the documentation of this file.
1
#include <iostream>
2
#include <sstream>
3
#include <iomanip>
4
5
#include "dbclient/KM3NeTDBClient.h"
6
7
#include "
JDB/JDB.hh
"
8
#include "
JDB/JSelector.hh
"
9
10
#include "
JSon/JSon.hh
"
11
#include "
JSon/JPrinter.hh
"
12
13
#include "
Jeep/JVersion.hh
"
14
#include "
Jeep/JParser.hh
"
15
#include "
Jeep/JMessage.hh
"
16
17
namespace
{
18
19
static
const
std::string
help_t =
"help"
;
20
}
21
22
23
/**
24
* \file
25
*
26
* Auxiliary program to print data from data base.
27
* \author mdejong
28
*/
29
int
main
(
int
argc,
char
**argv)
30
{
31
using namespace
std;
32
using namespace
JPP;
33
34
JServer server;
35
string
usr;
36
string
pwd;
37
string
cookie;
38
string
query;
39
JSelector selection;
40
string
api;
41
int
width;
42
string
csv;
43
string
key;
44
int
debug
;
45
46
try
{
47
48
JParser<>
zap(
"Auxiliary program to print data from data base."
);
49
50
zap[
's'
] =
make_field
(server) =
getServernames
();
51
zap[
'u'
] =
make_field
(usr) =
""
;
52
zap[
'!'
] =
make_field
(pwd) =
""
;
53
zap[
'C'
] =
make_field
(cookie) =
""
;
54
zap[
'q'
] =
make_field
(query) =
""
;
55
zap[
'@'
] =
make_field
(selection) =
JPARSER::initialised
();
56
zap[
'A'
] =
make_field
(api,
"API, possible values X.Y.Z[/help] ('apiv2') or \"\" ('streamds')"
) =
""
;
57
zap[
'W'
] =
make_field
(width) = 16;
58
zap[
'c'
] =
make_field
(csv) =
" "
;
59
zap[
'k'
] =
make_field
(key) =
""
;
60
zap[
'd'
] =
make_field
(
debug
) = 1;
61
62
zap(argc, argv);
63
}
64
catch
(
const
exception &error) {
65
FATAL
(error.what() << endl);
66
}
67
68
try
{
69
70
JDB::reset
(usr, pwd, cookie);
71
72
if
(api ==
""
) {
73
74
ResultSet& rs =
getResultSet
(query, selection);
75
{
76
for
(
unsigned
int
i
= 0;
i
!= rs.FieldCount(); ++
i
) {
77
cout << (
i
!= 0 ? csv :
""
) << setw(width) << left << rs.FieldName(
i
) << flush;
78
}
79
cout << endl;
80
}
81
while
(rs.Next()) {
82
for
(
unsigned
int
i
= 0;
i
!= rs.FieldCount(); ++
i
) {
83
cout << (
i
!= 0 ? csv :
""
) << setw(width) << left << rs.GetString(
i
) << flush;
84
}
85
cout << endl;
86
}
87
88
rs.Close();
89
90
}
else
{
91
92
JVersion
version
;
93
94
istringstream
is
(api);
95
96
if
(is >> version) {
97
98
json
js;
99
JSON::JPrinter
printer;
100
101
string
buffer;
102
103
if
(is.peek() == EOF)
104
*(
JDB::get
()->APIv2Select(version.toString().c_str(), query.c_str(), selection)) >> js;
105
else
if
(is.get() ==
'/'
&& is >> buffer && buffer == help_t)
106
*(
JDB::get
()->APIv2Help(version.toString().c_str(), (query !=
""
? query.c_str() :
"all/h"
))) >> js;
107
else
108
FATAL
(
"Error reading API version <"
<< api <<
">."
<< endl);
109
110
printer(cout, js, key);
111
112
}
else
{
113
114
FATAL
(
"Error reading API version <"
<< api <<
">."
<< endl);
115
}
116
}
117
}
118
catch
(
const
exception& error) {
119
FATAL
(error.what() << endl);
120
}
121
122
return
0;
123
}
JPARSER::JParser
Utility class to parse command line options.
Definition:
JParser.hh:1514
i
then rm i
Definition:
JEvtReweightGSeaGenParameterScan.sh:337
main
int main(int argc, char *argv[])
Definition:
Main.cc:15
version
version
Definition:
JEditTuneHV.sh:5
JSon.hh
JAANET::get
T get(const JHead &header)
Get object from header.
Definition:
JHeadToolkit.hh:261
JPARSER::initialised
Empty structure for specification of parser element that is initialised (i.e. does not require input)...
Definition:
JParser.hh:83
JPrinter.hh
is
is
Definition:
JDAQCHSM.chsm:167
JSelector.hh
make_field
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition:
JParser.hh:1989
JVersion.hh
string
then awk string
Definition:
pre-calibration.sh:45
JMessage.hh
General purpose messaging.
FATAL
#define FATAL(A)
Definition:
JMessage.hh:67
JTOOLS::reset
void reset(T &value)
Reset value.
Definition:
JToolsToolkit.hh:219
JParser.hh
Utility class to parse command line options.
json
nlohmann::json json
Definition:
JSupernovaMonitor.cc:28
JDATABASE::getResultSet
ResultSet & getResultSet(const std::string &query)
Get result set.
Definition:
JDB.hh:436
JDATABASE::getServernames
std::vector< JServer > getServernames()
Get list of names of available database servers.
Definition:
JDB.hh:106
JDB.hh
JSON::JPrinter
Auxiliary data structure to print (part of) JSon data.
Definition:
JPrinter.hh:29
debug
int debug
debug level
Definition:
archive-put-wiki-detectors.sh:92
Generated by
1.8.5