|
Squid Web Cache master
|
Manages arguments passed to a program (i.e., main(argc, argv) parameters). More...
#include <CommandLine.h>
Public Types | |
| typedef void | Visitor(const int optId, const char *optValue) |
Public Member Functions | |
| CommandLine (int argc, char *argv[], const char *shortRules, const RawLongOption *longRules) | |
| expects main() input plus getopt_long(3) grammar rules for parsing argv | |
| CommandLine (const CommandLine &them) | |
| ~CommandLine () | |
| CommandLine & | operator= (const CommandLine &) |
| bool | hasOption (const int optId, const char **optValue=nullptr) const |
| void | forEachOption (Visitor) const |
| calls Visitor for each of the configured command line option | |
| const char * | arg0 () const |
| int | argc () const |
| char ** | argv () const |
| void | resetArg0 (const char *programName) |
| replaces argv[0] with the new value | |
| void | pushFrontOption (const char *name, const char *value=nullptr) |
| inserts a (possibly duplicated) option at the beginning of options (just after argv[0]) | |
Private Member Functions | |
| const RawLongOption * | longOptions () const |
| bool | nextOption (int &optId) const |
Private Attributes | |
| std::vector< char * > | argv_ |
| raw main() parameters, including argv[0] and a nil argv[argc] | |
| const char * | shortOptions_ |
| single-dash, single-letter (-x) option rules | |
| std::vector< LongOption > | longOptions_ |
| long –option rules | |
Definition at line 34 of file CommandLine.h.
| typedef void CommandLine::Visitor(const int optId, const char *optValue) |
A callback function for forEachOption(); receives parsed options. Must not call pushFrontOption(), hasOption() or forEachOption() – getopt(3) uses globals!
Definition at line 52 of file CommandLine.h.
| CommandLine::CommandLine | ( | int | argc, |
| char * | argv[], | ||
| const char * | shortRules, | ||
| const RawLongOption * | longRules | ||
| ) |
Definition at line 24 of file CommandLine.cc.
References argv_, assert, longOptions_, and xstrdup.
| CommandLine::CommandLine | ( | const CommandLine & | them | ) |
Definition at line 46 of file CommandLine.cc.
| CommandLine::~CommandLine | ( | ) |
Definition at line 62 of file CommandLine.cc.
References argv_, shortOptions_, and xfree.
|
inline |
Definition at line 58 of file CommandLine.h.
References argv_.
Referenced by watch_child().
|
inline |
Definition at line 61 of file CommandLine.h.
References argv_.
Referenced by nextOption().
|
inline |
Definition at line 64 of file CommandLine.h.
References argv_.
Referenced by nextOption().
| void CommandLine::forEachOption | ( | Visitor | visitor | ) | const |
Definition at line 89 of file CommandLine.cc.
References nextOption(), optarg, and ResetGetopt().
Referenced by SquidMain().
| bool CommandLine::hasOption | ( | const int | optId, |
| const char ** | optValue = nullptr |
||
| ) | const |
Definition at line 71 of file CommandLine.cc.
References nextOption(), optarg, and ResetGetopt().
Referenced by ConfigureCurrentKid().
|
inlineprivate |
|
private |
extracts the next option (if any)
Definition at line 101 of file CommandLine.cc.
References argc(), argv(), argv_, assert, longOptions(), optind, SBuf::Printf(), shortOptions_, and TexcHere.
Referenced by forEachOption(), and hasOption().
| CommandLine & CommandLine::operator= | ( | const CommandLine & | them | ) |
Definition at line 52 of file CommandLine.cc.
References argv_, longOptions_, and shortOptions_.
| void CommandLine::pushFrontOption | ( | const char * | name, |
| const char * | value = nullptr |
||
| ) |
Definition at line 123 of file CommandLine.cc.
| void CommandLine::resetArg0 | ( | const char * | programName | ) |
Definition at line 115 of file CommandLine.cc.
References argv_, assert, xfree, and xstrdup.
Referenced by watch_child().
|
private |
Definition at line 77 of file CommandLine.h.
Referenced by CommandLine(), ~CommandLine(), arg0(), argc(), argv(), nextOption(), operator=(), pushFrontOption(), and resetArg0().
|
private |
Definition at line 81 of file CommandLine.h.
Referenced by CommandLine(), longOptions(), and operator=().
|
private |
Definition at line 80 of file CommandLine.h.
Referenced by ~CommandLine(), nextOption(), and operator=().