Hold and process options.
More...
#include <opt.h>
Hold and process options.
◆ loop_val
parsing return code
Enumerator |
---|
OPT_ERR | Parsing error
|
OPT_MSG | Pass a message from parsing like a version string
|
OPT_HELP | Need to print help
|
OPT_DONE | parsing success
|
◆ Options()
Options::Options |
( |
bool |
useDef = true | ) |
|
constructor
- Parameters
-
[in] | useDef | use PMC default options |
◆ get_help()
const char* Options::get_help |
( |
| ) |
|
Get help message
- Returns
- help message
◆ get_msg()
const std::string& Options::get_msg |
( |
| ) |
const |
|
inline |
◆ get_msg_c()
const char* Options::get_msg_c |
( |
| ) |
const |
|
inline |
◆ get_net_transport()
char Options::get_net_transport |
( |
| ) |
const |
|
inline |
get Network Transport value
- Returns
- Network Transport
- Note
- return 0 if not select on command line
◆ have()
bool Options::have |
( |
char |
opt | ) |
const |
|
inline |
Is option on command line
- Parameters
-
[in] | opt | short option character |
- Returns
- true if option on command line
◆ have_more()
bool Options::have_more |
( |
| ) |
const |
|
inline |
Do we have more argumends on the command line, left unprocessed
- Returns
- true if we have more to process
◆ insert()
Insert option
- Parameters
-
[in] | opt | new option parameters |
- Returns
- true on adding the option
- Note
- should be called before calling parse_options()
◆ parse_options()
loop_val Options::parse_options |
( |
int |
argc, |
|
|
char *const |
argv[] |
|
) |
| |
Parse command line
- Parameters
-
[in] | argc | number of arguments |
[in] | argv | array of command line arguments |
- Returns
- Parse state
- Note
- Follow the command line. Argument 0 is the application name,
as appear in the command line.
The class do not store it.
-
Regarding using scripts:
Python, Go and PHP uses full argument list.
With Ruby, Perl, Tcl and Lua, users need to add argument 0. To call from scripts:
Pythonobj.parse_options(sys.argv)
Goobj.Parse_options(os.Args)
PHP$obj->parse_options($argv)
Ruby$obj.parse_options([$0] + ARGV)
Perlobj->parse_options([$0, @@ARGV]);
Tclobj parse_options [list {*}$argv0 {*}$@::argv]
Luatable.insert(arg, 1, debug.getinfo(1, 'S').short_src);
obj:parse_options(arg)
◆ process_next()
int Options::process_next |
( |
| ) |
const |
|
inline |
First argumend on the command line, left unprocessed
- Returns
- index of argument
◆ useDefOption()
void Options::useDefOption |
( |
| ) |
|
◆ val()
const std::string& Options::val |
( |
char |
opt | ) |
const |
get option value
- Parameters
-
[in] | opt | short option character |
- Returns
- option value
- Note
- relevant for option with argument
◆ val_c()
const char* Options::val_c |
( |
char |
opt | ) |
const |
|
inline |
get option value
- Parameters
-
[in] | opt | short option character |
- Returns
- option char pointer of value string (C style)
- Note
- relevant for option with argument
◆ val_i()
int Options::val_i |
( |
char |
opt | ) |
const |
|
inline |
get option integer value
- Parameters
-
[in] | opt | short option character |
- Returns
- option integer value
- Note
- relevant for option with argument of integer value
The documentation for this class was generated from the following file: