Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
audiowmark
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Stefan Westerfeld
audiowmark
Commits
5cd39930
Commit
5cd39930
authored
Jul 08, 2020
by
Stefan Westerfeld
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve ArgParser.
Signed-off-by:
Stefan Westerfeld
<
stefan@space.twc.de
>
parent
febc8a07
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
40 additions
and
5 deletions
+40
-5
audiowmark.cc
src/audiowmark.cc
+40
-5
No files found.
src/audiowmark.cc
View file @
5cd39930
...
...
@@ -567,22 +567,22 @@ public:
return
false
;
}
bool
parse_opt
(
const
string
&
option
,
int
&
out
)
parse_opt
(
const
string
&
option
,
string
&
out_s
)
{
bool
found_option
=
false
;
auto
it
=
m_args
.
begin
();
while
(
it
!=
m_args
.
end
())
{
auto
next_it
=
it
+
1
;
if
(
*
it
==
option
&&
next_it
!=
m_args
.
end
())
/* --option
12345
*/
if
(
*
it
==
option
&&
next_it
!=
m_args
.
end
())
/* --option
foo
*/
{
out
=
atoi
(
next_it
->
c_str
())
;
out
_s
=
*
next_it
;
next_it
=
m_args
.
erase
(
it
,
it
+
2
);
found_option
=
true
;
}
else
if
(
starts_with
(
*
it
,
(
option
+
"="
)))
/* --option=
12345
*/
else
if
(
starts_with
(
*
it
,
(
option
+
"="
)))
/* --option=
foo
*/
{
out
=
atoi
(
it
->
substr
(
option
.
size
()
+
1
).
c_str
()
);
out
_s
=
it
->
substr
(
option
.
size
()
+
1
);
next_it
=
m_args
.
erase
(
it
);
found_option
=
true
;
}
...
...
@@ -590,6 +590,41 @@ public:
}
return
found_option
;
}
bool
parse_opt
(
const
string
&
option
,
int
&
out_i
)
{
string
out_s
;
if
(
parse_opt
(
option
,
out_s
))
{
out_i
=
atoi
(
out_s
.
c_str
());
return
true
;
}
return
false
;
}
bool
parse_opt
(
const
string
&
option
,
float
&
out_f
)
{
string
out_s
;
if
(
parse_opt
(
option
,
out_s
))
{
out_f
=
atof
(
out_s
.
c_str
());
return
true
;
}
return
false
;
}
bool
parse_opt
(
const
string
&
option
)
{
for
(
auto
it
=
m_args
.
begin
();
it
!=
m_args
.
end
();
it
++
)
{
if
(
*
it
==
option
)
/* --option */
{
m_args
.
erase
(
it
);
return
true
;
}
}
return
false
;
}
vector
<
string
>
args
()
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment