NAIA
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 <argp.h>
2
#include <TROOT.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
[] = {
11
{
"overwrite"
,
'w'
, 0 , 0,
"Overwrite results"
},
12
{
"verbosity"
,
'v'
,
"LEVEL"
, 0,
"Verbosity level [Info, Debug, Trace]"
},
13
{
"input-file"
,
'i'
,
"FILE"
, 0,
"Input file"
},
14
{
"output-file"
,
'o'
,
"FILE"
, 0,
"Output file"
},
15
{
"event"
,
'E'
,
"INT"
, 0,
"Process Single Event"
},
16
{
"from-event"
,
'e'
,
"INT"
, 0,
"Process from Event"
},
17
{
"nevents"
,
'n'
,
"INT"
, 0,
"Process # events"
},
18
{0}
19
};
20
struct
argp
argp
= {
options
,
parse_opt
, 0, 0};
21
22
struct
arguments
{
23
const
char
*
infilename
;
24
const
char
*
outfilename
;
25
const
char
*
recotype
;
26
const
char
*
debug_level
;
27
bool
flag_overwrite
;
28
bool
flag_input
;
29
bool
flag_output
;
30
int
event
;
31
int
from_event
;
32
int
nevents
;
33
};
34
35
36
static
int
parse_opt
(
int
key,
char
* arg,
struct
argp_state* state){
37
38
struct
arguments
* a = (
struct
arguments
*) state->input;
39
40
switch
(key)
41
{
42
case
'w'
:
43
{
44
a->
flag_overwrite
= kTRUE;
45
break
;
46
}
47
case
'v'
:
48
{
49
a->
debug_level
= arg;
50
break
;
51
}
52
case
'i'
:
53
{
54
a->
flag_input
= kTRUE;
55
a->
infilename
= arg;
56
break
;
57
}
58
case
'o'
:
59
{
60
a->
flag_output
= kTRUE;
61
a->
outfilename
= arg;
62
break
;
63
}
64
case
'E'
:
65
{
66
a->
event
= atoi(arg);
67
break
;
68
}
69
case
'e'
:
70
{
71
a->
from_event
= atoi(arg);
72
break
;
73
}
74
case
'n'
:
75
{
76
a->
nevents
= atoi(arg);
77
break
;
78
}
79
case
ARGP_KEY_ARG:
80
{
81
argp_failure(state, 1, 0,
"No arguments requested"
);
82
break
;
83
}
84
case
ARGP_KEY_INIT:
85
{
86
a->
infilename
=
nullptr
;
87
a->
outfilename
=
nullptr
;
88
a->
debug_level
=
"Info"
;
89
a->
flag_overwrite
= kFALSE;
90
a->
flag_input
= kFALSE;
91
a->
flag_output
= kFALSE;
92
a->
event
= -1;
93
a->
from_event
= -1;
94
a->
nevents
= -1;
95
break
;
96
}
97
case
ARGP_KEY_END:
98
{
99
break
;
100
}
101
}
102
103
return
0;
104
105
}
106
107
108
#endif
arguments::recotype
const char * recotype
Definition:
cli_options.h:25
argp
struct argp argp
Definition:
cli_options.h:20
arguments::flag_overwrite
bool flag_overwrite
Definition:
cli_options.h:27
parse_opt
static int parse_opt(int key, char *arg, struct argp_state *state)
Definition:
cli_options.h:36
arguments::debug_level
const char * debug_level
Definition:
cli_options.h:26
arguments::infilename
const char * infilename
Definition:
cli_options.h:23
arguments::from_event
int from_event
Definition:
cli_options.h:31
arguments::event
int event
Definition:
cli_options.h:30
options
struct argp_option options[]
Definition:
cli_options.h:10
arguments::flag_output
bool flag_output
Definition:
cli_options.h:29
arguments::outfilename
const char * outfilename
Definition:
cli_options.h:24
arguments::nevents
int nevents
Definition:
cli_options.h:32
arguments
Definition:
cli_options.h:22
arguments::flag_input
bool flag_input
Definition:
cli_options.h:28
Generated by
1.8.5