NAIA
1.0.2
Main Page
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
include
NtpMaker
cli_options.h
Go to the documentation of this file.
1
#include <TROOT.h>
2
#include <argp.h>
3
4
#ifndef _PARSER_
5
#define _PARSER_
6
7
static
int
parse_opt
(
int
key,
char
*arg,
struct
argp_state *state);
8
9
// -- Global variables
10
struct
argp_option
options
[] = {{
"overwrite"
,
'w'
, 0, 0,
"Overwrite results"
},
11
{
"verbosity"
,
'v'
,
"LEVEL"
, 0,
"Verbosity level [Info, Debug, Trace]"
},
12
{
"input-file"
,
'i'
,
"FILE"
, 0,
"Input file"
},
13
{
"output-file"
,
'o'
,
"FILE"
, 0,
"Output file"
},
14
{
"event"
,
'E'
,
"INT"
, 0,
"Process Single Event"
},
15
{
"from-event"
,
'e'
,
"INT"
, 0,
"Process from Event"
},
16
{
"nevents"
,
'n'
,
"INT"
, 0,
"Process # events"
},
17
{0}};
18
struct
argp
argp
= {
options
,
parse_opt
, 0, 0};
19
20
struct
arguments
{
21
const
char
*
infilename
;
22
const
char
*
outfilename
;
23
const
char
*
recotype
;
24
const
char
*
debug_level
;
25
bool
flag_overwrite
;
26
bool
flag_input
;
27
bool
flag_output
;
28
int
event
;
29
int
from_event
;
30
int
nevents
;
31
};
32
33
static
int
parse_opt
(
int
key,
char
*arg,
struct
argp_state *state) {
34
35
struct
arguments
*a = (
struct
arguments
*)state->input;
36
37
switch (key) {
38
case
'w'
: {
39
a->
flag_overwrite
= kTRUE;
40
break
;
41
}
42
case
'v'
: {
43
a->
debug_level
= arg;
44
break
;
45
}
46
case
'i'
: {
47
a->
flag_input
= kTRUE;
48
a->
infilename
= arg;
49
break
;
50
}
51
case
'o'
: {
52
a->
flag_output
= kTRUE;
53
a->
outfilename
= arg;
54
break
;
55
}
56
case
'E'
: {
57
a->
event
= atoi(arg);
58
break
;
59
}
60
case
'e'
: {
61
a->
from_event
= atoi(arg);
62
break
;
63
}
64
case
'n'
: {
65
a->
nevents
= atoi(arg);
66
break
;
67
}
68
case
ARGP_KEY_ARG: {
69
argp_failure(state, 1, 0,
"No arguments requested"
);
70
break
;
71
}
72
case
ARGP_KEY_INIT: {
73
a->
infilename
=
nullptr
;
74
a->
outfilename
=
nullptr
;
75
a->
debug_level
=
"Info"
;
76
a->
flag_overwrite
= kFALSE;
77
a->
flag_input
= kFALSE;
78
a->
flag_output
= kFALSE;
79
a->
event
= -1;
80
a->
from_event
= -1;
81
a->
nevents
= -1;
82
break
;
83
}
84
case
ARGP_KEY_END: {
85
break
;
86
}
87
}
88
89
return
0;
90
}
91
92
#endif
arguments::recotype
const char * recotype
Definition:
cli_options.h:23
argp
struct argp argp
Definition:
cli_options.h:18
arguments::flag_overwrite
bool flag_overwrite
Definition:
cli_options.h:25
parse_opt
static int parse_opt(int key, char *arg, struct argp_state *state)
Definition:
cli_options.h:33
arguments::debug_level
const char * debug_level
Definition:
cli_options.h:24
arguments::infilename
const char * infilename
Definition:
cli_options.h:21
arguments::from_event
int from_event
Definition:
cli_options.h:29
arguments::event
int event
Definition:
cli_options.h:28
options
struct argp_option options[]
Definition:
cli_options.h:10
arguments::flag_output
bool flag_output
Definition:
cli_options.h:27
arguments::outfilename
const char * outfilename
Definition:
cli_options.h:22
arguments::nevents
int nevents
Definition:
cli_options.h:30
arguments
Definition:
cli_options.h:20
arguments::flag_input
bool flag_input
Definition:
cli_options.h:26
Generated by
1.8.5