diff options
author | Daniel Baumann <mail@daniel-baumann.ch> | 2015-11-07 10:16:35 +0000 |
---|---|---|
committer | Daniel Baumann <mail@daniel-baumann.ch> | 2015-11-07 10:16:35 +0000 |
commit | 9c4f65be76622adb3e5429760e1828c36343c15e (patch) | |
tree | afc77153dd2432a0c71fe3589f0a431920b1ed33 /arg_parser.h | |
parent | Adding upstream version 1.13~rc2. (diff) | |
download | lziprecover-9c4f65be76622adb3e5429760e1828c36343c15e.tar.xz lziprecover-9c4f65be76622adb3e5429760e1828c36343c15e.zip |
Adding upstream version 1.13.upstream/1.13
Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
Diffstat (limited to 'arg_parser.h')
-rw-r--r-- | arg_parser.h | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/arg_parser.h b/arg_parser.h index d1e5c02..4fbd1af 100644 --- a/arg_parser.h +++ b/arg_parser.h @@ -1,5 +1,6 @@ /* Arg_parser - POSIX/GNU command line argument parser. (C++ version) - Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Antonio Diaz Diaz. + Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012 + Antonio Diaz Diaz. This library is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -25,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. @@ -39,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 @@ -65,7 +66,7 @@ private: { int code; std::string argument; - Record( const int c = 0 ) : code( c ) {} + explicit Record( const int c = 0 ) : code( c ) {} }; std::string error_; @@ -84,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_; |