Merging upstream version 0.9.
Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
parent
7a8d5107f2
commit
b4a17774a7
14 changed files with 193 additions and 200 deletions
22
arg_parser.h
22
arg_parser.h
|
@ -26,12 +26,12 @@
|
|||
Public License.
|
||||
*/
|
||||
|
||||
/* Arg_parser reads the arguments in `argv' and creates a number of
|
||||
/* Arg_parser reads the arguments in 'argv' and creates a number of
|
||||
option codes, option arguments and non-option arguments.
|
||||
|
||||
In case of error, `error' returns a non-empty error message.
|
||||
In case of error, 'error' returns a non-empty error message.
|
||||
|
||||
`options' is an array of `struct Option' terminated by an element
|
||||
'options' is an array of 'struct Option' terminated by an element
|
||||
containing a code which is zero. A null name means a short-only
|
||||
option. A code value outside the unsigned char range means a
|
||||
long-only option.
|
||||
|
@ -40,13 +40,13 @@
|
|||
were specified before all the non-option arguments for the purposes
|
||||
of parsing, even if the user of your program intermixed option and
|
||||
non-option arguments. If you want the arguments in the exact order
|
||||
the user typed them, call `Arg_parser' with `in_order' = true.
|
||||
the user typed them, call 'Arg_parser' with 'in_order' = true.
|
||||
|
||||
The argument `--' terminates all options; any following arguments are
|
||||
The argument '--' terminates all options; any following arguments are
|
||||
treated as non-option arguments, even if they begin with a hyphen.
|
||||
|
||||
The syntax for optional option arguments is `-<short_option><argument>'
|
||||
(without whitespace), or `--<long_option>=<argument>'.
|
||||
The syntax for optional option arguments is '-<short_option><argument>'
|
||||
(without whitespace), or '--<long_option>=<argument>'.
|
||||
*/
|
||||
|
||||
class Arg_parser
|
||||
|
@ -85,20 +85,20 @@ public:
|
|||
Arg_parser( const char * const opt, const char * const arg,
|
||||
const Option options[] );
|
||||
|
||||
const std::string & error() const throw() { return error_; }
|
||||
const std::string & error() const { return error_; }
|
||||
|
||||
// The number of arguments parsed (may be different from argc)
|
||||
int arguments() const throw() { return data.size(); }
|
||||
int arguments() const { return data.size(); }
|
||||
|
||||
// If code( i ) is 0, argument( i ) is a non-option.
|
||||
// Else argument( i ) is the option's argument (or empty).
|
||||
int code( const int i ) const throw()
|
||||
int code( const int i ) const
|
||||
{
|
||||
if( i >= 0 && i < arguments() ) return data[i].code;
|
||||
else return 0;
|
||||
}
|
||||
|
||||
const std::string & argument( const int i ) const throw()
|
||||
const std::string & argument( const int i ) const
|
||||
{
|
||||
if( i >= 0 && i < arguments() ) return data[i].argument;
|
||||
else return error_;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue