Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv
Project
Project
Details
Activity
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
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
opencv
Commits
08dd126f
Commit
08dd126f
authored
Sep 10, 2015
by
Pavel Rojtberg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
do not parse empty default values and improve error messages
parent
9c3f9578
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
8 deletions
+18
-8
utility.hpp
modules/core/include/opencv2/core/utility.hpp
+1
-1
command_line_parser.cpp
modules/core/src/command_line_parser.cpp
+17
-7
No files found.
modules/core/include/opencv2/core/utility.hpp
View file @
08dd126f
...
...
@@ -618,7 +618,7 @@ For the described keys:
# Bad call
$ ./app -fps=aaa
ERRORS:
Exception
: can not convert: [aaa] to [double]
Parameter 'fps'
: can not convert: [aaa] to [double]
@endcode
*/
class
CV_EXPORTS
CommandLineParser
...
...
modules/core/src/command_line_parser.cpp
View file @
08dd126f
...
...
@@ -97,23 +97,28 @@ void CommandLineParser::getByName(const String& name, bool space_delete, int typ
{
for
(
size_t
j
=
0
;
j
<
impl
->
data
[
i
].
keys
.
size
();
j
++
)
{
if
(
name
.
compare
(
impl
->
data
[
i
].
keys
[
j
])
==
0
)
if
(
name
==
impl
->
data
[
i
].
keys
[
j
]
)
{
String
v
=
impl
->
data
[
i
].
def_value
;
if
(
space_delete
)
v
=
impl
->
cat_string
(
v
);
// it is an error if we just got the default value here
if
(
v
.
empty
())
break
;
from_str
(
v
,
type
,
dst
);
return
;
}
}
}
impl
->
error
=
true
;
impl
->
error_message
=
impl
->
error_message
+
"
Unknown parameter "
+
name
+
"
\n
"
;
impl
->
error_message
=
impl
->
error_message
+
"
Missing parameter: '"
+
name
+
"'
\n
"
;
}
catch
(
std
::
e
xception
&
e
)
catch
(
E
xception
&
e
)
{
impl
->
error
=
true
;
impl
->
error_message
=
impl
->
error_message
+
"
Exception: "
+
String
(
e
.
what
())
+
"
\n
"
;
impl
->
error_message
=
impl
->
error_message
+
"
Parameter '"
+
name
+
"': "
+
e
.
err
+
"
\n
"
;
}
}
...
...
@@ -128,17 +133,22 @@ void CommandLineParser::getByIndex(int index, bool space_delete, int type, void*
{
String
v
=
impl
->
data
[
i
].
def_value
;
if
(
space_delete
==
true
)
v
=
impl
->
cat_string
(
v
);
// it is an error if we just got the default value here
if
(
v
.
empty
())
break
;
from_str
(
v
,
type
,
dst
);
return
;
}
}
impl
->
error
=
true
;
impl
->
error_message
=
impl
->
error_message
+
"
Unknown
parameter #"
+
format
(
"%d"
,
index
)
+
"
\n
"
;
impl
->
error_message
=
impl
->
error_message
+
"
Missing
parameter #"
+
format
(
"%d"
,
index
)
+
"
\n
"
;
}
catch
(
std
::
exception
&
e
)
catch
(
Exception
&
e
)
{
impl
->
error
=
true
;
impl
->
error_message
=
impl
->
error_message
+
"Exception: "
+
String
(
e
.
what
())
+
"
\n
"
;
impl
->
error_message
=
impl
->
error_message
+
format
(
"Parameter #%d: "
,
index
)
+
e
.
err
+
"
\n
"
;
}
}
...
...
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