Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
D
dlib
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
钟尚武
dlib
Commits
b78f1cb8
Commit
b78f1cb8
authored
Jun 18, 2011
by
Davis King
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added the check_sub_option() method to the command line parser check
object.
parent
13269d7f
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
78 additions
and
1 deletion
+78
-1
cmd_line_parser_check_1.h
dlib/cmd_line_parser/cmd_line_parser_check_1.h
+27
-1
cmd_line_parser_check_abstract.h
dlib/cmd_line_parser/cmd_line_parser_check_abstract.h
+22
-0
cmd_line_parser_check_c.h
dlib/cmd_line_parser/cmd_line_parser_check_c.h
+29
-0
No files found.
dlib/cmd_line_parser/cmd_line_parser_check_1.h
View file @
b78f1cb8
...
...
@@ -3,7 +3,7 @@
#ifndef DLIB_CMD_LINE_PARSER_CHECk_1_
#define DLIB_CMD_LINE_PARSER_CHECk_1_
#include "cmd_line_parser_
kernel
_abstract.h"
#include "cmd_line_parser_
check
_abstract.h"
#include <sstream>
#include <string>
#include "../string.h"
...
...
@@ -191,6 +191,11 @@ namespace dlib
const
string_type
&
option_name2
)
const
;
void
check_sub_option
(
const
string_type
&
parent_option
,
const
string_type
&
sub_option
)
const
;
template
<
size_t
length
>
...
...
@@ -423,6 +428,27 @@ namespace dlib
}
}
// ----------------------------------------------------------------------------------------
template
<
typename
clp_base
>
void
cmd_line_parser_check_1
<
clp_base
>::
check_sub_option
(
const
string_type
&
parent_option
,
const
string_type
&
sub_option
)
const
{
if
(
this
->
option
(
parent_option
).
count
()
==
0
)
{
if
(
this
->
option
(
sub_option
).
count
()
!=
0
)
{
std
::
vector
<
string_type
>
vect
;
vect
.
resize
(
1
);
vect
[
0
]
=
parent_option
;
throw
cmd_line_check_error
(
EMISSING_REQUIRED_OPTION
,
sub_option
,
vect
);
}
}
}
// ----------------------------------------------------------------------------------------
template
<
typename
clp_base
>
...
...
dlib/cmd_line_parser/cmd_line_parser_check_abstract.h
View file @
b78f1cb8
...
...
@@ -217,6 +217,28 @@ namespace dlib
- opt2 == The next incompatible option found.
!*/
void
check_sub_option
(
const
string_type
&
parent_option
,
const
string_type
&
sub_option
)
const
;
/*!
requires
- parsed_line() == true
- option_is_defined(parent_option) == true
- option_is_defined(sub_option) == true
ensures
- if (option(parent_option).count() == 0) then
- option(sub_option).count() == 0
throws
- std::bad_alloc
- cmd_line_check_error
This exception is thrown if the ensures clause could not be satisfied.
The exception's members will be set as follows:
- type == EMISSING_REQUIRED_OPTION
- opt == sub_option.
- required_opts == a vector that contains only parent_option.
!*/
template
<
size_t
length
>
...
...
dlib/cmd_line_parser/cmd_line_parser_check_c.h
View file @
b78f1cb8
...
...
@@ -75,6 +75,11 @@ namespace dlib
const
string_type
&
option_name2
)
const
;
void
check_sub_option
(
const
string_type
&
parent_option
,
const
string_type
&
sub_option
)
const
;
template
<
size_t
length
>
...
...
@@ -266,6 +271,30 @@ namespace dlib
clp_check
::
check_incompatible_options
(
option_name1
,
option_name2
);
}
// ----------------------------------------------------------------------------------------
template
<
typename
clp_check
>
void
cmd_line_parser_check_c
<
clp_check
>::
check_sub_option
(
const
string_type
&
parent_option
,
const
string_type
&
sub_option
)
const
{
// make sure requires clause is not broken
DLIB_CASSERT
(
this
->
parsed_line
()
==
true
&&
this
->
option_is_defined
(
parent_option
)
&&
this
->
option_is_defined
(
sub_option
),
"
\t
void cmd_line_parser_check::check_sub_option()"
<<
"
\n\t
See the requires clause for this function."
<<
"
\n\t
this: "
<<
this
<<
"
\n\t
parsed_line(): "
<<
this
->
parsed_line
()
<<
"
\n\t
option_is_defined(parent_option): "
<<
this
->
option_is_defined
(
parent_option
)
<<
"
\n\t
option_is_defined(sub_option): "
<<
this
->
option_is_defined
(
sub_option
)
<<
"
\n\t
parent_option: "
<<
parent_option
<<
"
\n\t
sub_option: "
<<
sub_option
);
clp_check
::
check_sub_option
(
parent_option
,
sub_option
);
}
// ----------------------------------------------------------------------------------------
template
<
typename
clp_check
>
...
...
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