Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
U
utils
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
FSL
utils
Commits
42065158
Commit
42065158
authored
24 years ago
by
David Flitney
Browse files
Options
Downloads
Patches
Plain Diff
*** empty log message ***
parent
f551f2b1
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
options.cc
+46
-41
46 additions, 41 deletions
options.cc
with
46 additions
and
41 deletions
options.cc
+
46
−
41
View file @
42065158
...
...
@@ -40,38 +40,65 @@ ostream& operator<<(ostream &os, const BaseOption& o) {
void
OptionParser
::
usage
()
{
cerr
<<
"Usage: "
<<
endl
<<
"
\t
"
<<
progname_
<<
" "
<<
example_
<<
endl
;
cerr
<<
endl
<<
"Compulsory arguments:"
<<
endl
;
cerr
<<
endl
<<
progname_
<<
endl
<<
endl
;
cerr
<<
"Usage: "
<<
endl
<<
example_
<<
endl
;
for
(
Options
::
iterator
option
=
options_
.
begin
();
option
!=
options_
.
end
();
option
++
)
{
if
((
*
option
)
->
compulsory
())
if
((
*
option
)
->
compulsory
())
{
static
bool
banner
=
true
;
if
(
banner
)
{
cerr
<<
endl
<<
"Compulsory arguments (You MUST set one or more of):"
<<
endl
;
banner
=
false
;
}
cerr
<<
**
option
<<
endl
;
}
}
cerr
<<
endl
<<
"Optional arguments:"
<<
endl
;
for
(
Options
::
iterator
option
=
options_
.
begin
();
option
!=
options_
.
end
();
option
++
)
{
if
(
!
(
*
option
)
->
compulsory
())
if
(
!
(
*
option
)
->
compulsory
())
{
static
bool
banner
=
true
;
if
(
banner
)
{
cerr
<<
endl
<<
"Optional arguments (You may optionally specify one or more of):"
<<
endl
;
banner
=
false
;
}
cerr
<<
**
option
<<
endl
;
}
}
cerr
<<
endl
;
cerr
<<
endl
;
}
// BaseOption * OptionParser::operator[](const string& key)
// {
// OptionMap::iterator option = options_.find(key);
// if(option != options_.end())
// return option->second;
// else // An unknown option!
// return NULL;
// }
bool
OptionParser
::
check_compulsory_arguments
(
bool
verbose
)
{
bool
okay
=
true
;
for
(
Options
::
iterator
option
=
options_
.
begin
();
option
!=
options_
.
end
();
option
++
)
{
if
((
*
option
)
->
compulsory
()
&&
(
*
option
)
->
unset
())
{
if
(
okay
)
{
if
(
verbose
)
{
cerr
<<
"***************************************************"
<<
endl
;
cerr
<<
"The following COMPULSORY options have not been set:"
<<
endl
;
}
okay
=
false
;
}
if
(
verbose
)
cerr
<<
**
option
<<
endl
;
}
}
if
(
!
okay
&&
verbose
)
cerr
<<
"***************************************************"
<<
endl
;
return
okay
;
}
unsigned
int
OptionParser
::
parse_command_line
(
unsigned
int
argc
,
char
**
argv
)
...
...
@@ -123,28 +150,6 @@ unsigned int OptionParser::parse_command_line(unsigned int argc,
}
argcount
+=
increments
;
}
// Now check that any compulsory options
// have been set
for
(
Options
::
iterator
option
=
options_
.
begin
();
option
!=
options_
.
end
();
option
++
)
{
static
bool
banner
=
true
;
if
((
*
option
)
->
compulsory
()
&&
(
*
option
)
->
unset
())
{
if
(
banner
)
{
cerr
<<
"***************************************************"
<<
endl
;
cerr
<<
"The following COMPULSORY options have not been set!"
<<
endl
;
banner
=
false
;
usage_needed
=
true
;
}
cerr
<<
**
option
<<
endl
;
}
}
if
(
usage_needed
)
{
cerr
<<
"***************************************************"
<<
endl
;
usage
();
exit
(
-
1
);
}
return
argcount
;
// User should process any remaining args
}
...
...
@@ -177,11 +182,11 @@ int main(unsigned int argc, char **argv) {
OptionParser
options
(
"options"
,
"-d <number> --mask <filename> --res <filename>"
);
options
.
add
(
&
verbose
);
options
.
add
(
&
help
);
options
.
add
(
&
dof
);
options
.
add
(
&
mask
);
options
.
add
(
&
resid
);
options
.
add
(
verbose
);
options
.
add
(
help
);
options
.
add
(
dof
);
options
.
add
(
mask
);
options
.
add
(
resid
);
for
(
unsigned
int
a
=
options
.
parse_command_line
(
argc
,
argv
);
a
<
argc
;
a
++
)
cout
<<
argv
[
a
]
<<
endl
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment