1
- //
2
- // Created by nathan on 2/1/18.
3
- //
1
+ /* -*- c++ -*- */
2
+ /*
3
+ * Copyright 2018-2020 Free Software Foundation, Inc.
4
+ *
5
+ * This file is part of GNU Radio
6
+ *
7
+ * GNU Radio is free software; you can redistribute it and/or modify
8
+ * it under the terms of the GNU General Public License as published by
9
+ * the Free Software Foundation; either version 3, or (at your option)
10
+ * any later version.
11
+ *
12
+ * GNU Radio is distributed in the hope that it will be useful,
13
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ * GNU General Public License for more details.
16
+ *
17
+ * You should have received a copy of the GNU General Public License
18
+ * along with GNU Radio; see the file COPYING. If not, write to
19
+ * the Free Software Foundation, Inc., 51 Franklin Street,
20
+ * Boston, MA 02110-1301, USA.
21
+ */
22
+
4
23
5
24
#include " volk_option_helpers.h"
6
25
14
33
/*
15
34
* Option type
16
35
*/
17
- option_t ::option_t (std::string longform,
18
- std::string shortform,
19
- std::string msg,
20
- void (*callback)())
21
- : longform(" --" + longform), shortform(" -" + shortform), msg(msg), callback(callback)
36
+ option_t ::option_t (std::string t_longform,
37
+ std::string t_shortform,
38
+ std::string t_msg,
39
+ void (*t_callback)())
40
+ : longform(" --" + t_longform),
41
+ shortform(" -" + t_shortform),
42
+ msg(t_msg),
43
+ callback(t_callback)
22
44
{
23
45
option_type = VOID_CALLBACK;
24
46
}
25
47
26
- option_t ::option_t (std::string longform ,
27
- std::string shortform ,
28
- std::string msg ,
29
- void (*callback )(int ))
30
- : longform(" --" + longform ),
31
- shortform(" -" + shortform ),
32
- msg(msg ),
33
- callback((void (*)())callback )
48
+ option_t ::option_t (std::string t_longform ,
49
+ std::string t_shortform ,
50
+ std::string t_msg ,
51
+ void (*t_callback )(int ))
52
+ : longform(" --" + t_longform ),
53
+ shortform(" -" + t_shortform ),
54
+ msg(t_msg ),
55
+ callback((void (*)())t_callback )
34
56
{
35
57
option_type = INT_CALLBACK;
36
58
}
37
59
38
- option_t ::option_t (std::string longform ,
39
- std::string shortform ,
40
- std::string msg ,
41
- void (*callback )(float ))
42
- : longform(" --" + longform ),
43
- shortform(" -" + shortform ),
44
- msg(msg ),
45
- callback((void (*)())callback )
60
+ option_t ::option_t (std::string t_longform ,
61
+ std::string t_shortform ,
62
+ std::string t_msg ,
63
+ void (*t_callback )(float ))
64
+ : longform(" --" + t_longform ),
65
+ shortform(" -" + t_shortform ),
66
+ msg(t_msg ),
67
+ callback((void (*)())t_callback )
46
68
{
47
69
option_type = FLOAT_CALLBACK;
48
70
}
49
71
50
- option_t ::option_t (std::string longform ,
51
- std::string shortform ,
52
- std::string msg ,
53
- void (*callback )(bool ))
54
- : longform(" --" + longform ),
55
- shortform(" -" + shortform ),
56
- msg(msg ),
57
- callback((void (*)())callback )
72
+ option_t ::option_t (std::string t_longform ,
73
+ std::string t_shortform ,
74
+ std::string t_msg ,
75
+ void (*t_callback )(bool ))
76
+ : longform(" --" + t_longform ),
77
+ shortform(" -" + t_shortform ),
78
+ msg(t_msg ),
79
+ callback((void (*)())t_callback )
58
80
{
59
81
option_type = BOOL_CALLBACK;
60
82
}
61
83
62
- option_t ::option_t (std::string longform ,
63
- std::string shortform ,
64
- std::string msg ,
65
- void (*callback )(std::string))
66
- : longform(" --" + longform ),
67
- shortform(" -" + shortform ),
68
- msg(msg ),
69
- callback((void (*)())callback )
84
+ option_t ::option_t (std::string t_longform ,
85
+ std::string t_shortform ,
86
+ std::string t_msg ,
87
+ void (*t_callback )(std::string))
88
+ : longform(" --" + t_longform ),
89
+ shortform(" -" + t_shortform ),
90
+ msg(t_msg ),
91
+ callback((void (*)())t_callback )
70
92
{
71
93
option_type = STRING_CALLBACK;
72
94
}
73
95
74
- option_t ::option_t (std::string longform,
75
- std::string shortform,
76
- std::string msg,
77
- std::string printval)
78
- : longform(" --" + longform), shortform(" -" + shortform), msg(msg), printval(printval)
96
+ option_t ::option_t (std::string t_longform,
97
+ std::string t_shortform,
98
+ std::string t_msg,
99
+ std::string t_printval)
100
+ : longform(" --" + t_longform),
101
+ shortform (" -" + t_shortform),
102
+ msg(t_msg),
103
+ printval(t_printval)
79
104
{
80
105
option_type = STRING;
81
106
}
@@ -85,29 +110,29 @@ option_t::option_t(std::string longform,
85
110
* Option List
86
111
*/
87
112
88
- option_list::option_list (std::string program_name) : program_name (program_name)
113
+ option_list::option_list (std::string program_name) : d_program_name (program_name)
89
114
{
90
- internal_list = std::vector<option_t >();
115
+ d_internal_list = std::vector<option_t >();
91
116
}
92
117
93
118
94
- void option_list::add (option_t opt) { internal_list .push_back (opt); }
119
+ void option_list::add (option_t opt) { d_internal_list .push_back (opt); }
95
120
96
121
void option_list::parse (int argc, char ** argv)
97
122
{
98
123
for (int arg_number = 0 ; arg_number < argc; ++arg_number) {
99
- for (std::vector<option_t >::iterator this_option = internal_list .begin ();
100
- this_option != internal_list .end ();
124
+ for (std::vector<option_t >::iterator this_option = d_internal_list .begin ();
125
+ this_option != d_internal_list .end ();
101
126
this_option++) {
102
127
int int_val = INT_MIN;
103
128
if (this_option->longform == std::string (argv[arg_number]) ||
104
129
this_option->shortform == std::string (argv[arg_number])) {
105
130
106
- if (present_options .count (this_option->longform ) == 0 ) {
107
- present_options .insert (
131
+ if (d_present_options .count (this_option->longform ) == 0 ) {
132
+ d_present_options .insert (
108
133
std::pair<std::string, int >(this_option->longform , 1 ));
109
134
} else {
110
- present_options [this_option->longform ] += 1 ;
135
+ d_present_options [this_option->longform ] += 1 ;
111
136
}
112
137
switch (this_option->option_type ) {
113
138
case VOID_CALLBACK:
@@ -184,15 +209,15 @@ void option_list::parse(int argc, char** argv)
184
209
}
185
210
if (std::string (" --help" ) == std::string (argv[arg_number]) ||
186
211
std::string (" -h" ) == std::string (argv[arg_number])) {
187
- present_options .insert (std::pair<std::string, int >(" --help" , 1 ));
212
+ d_present_options .insert (std::pair<std::string, int >(" --help" , 1 ));
188
213
help ();
189
214
}
190
215
}
191
216
}
192
217
193
218
bool option_list::present (std::string option_name)
194
219
{
195
- if (present_options .count (" --" + option_name)) {
220
+ if (d_present_options .count (" --" + option_name)) {
196
221
return true ;
197
222
} else {
198
223
return false ;
@@ -201,10 +226,10 @@ bool option_list::present(std::string option_name)
201
226
202
227
void option_list::help ()
203
228
{
204
- std::cout << program_name << std::endl;
229
+ std::cout << d_program_name << std::endl;
205
230
std::cout << " -h [ --help ] \t\t display this help message" << std::endl;
206
- for (std::vector<option_t >::iterator this_option = internal_list .begin ();
207
- this_option != internal_list .end ();
231
+ for (std::vector<option_t >::iterator this_option = d_internal_list .begin ();
232
+ this_option != d_internal_list .end ();
208
233
this_option++) {
209
234
std::string help_line (" " );
210
235
if (this_option->shortform == " -" ) {
0 commit comments