|
mxlib
c++ tools for analyzing astronomical data and other tasks by Jared R. Males. [git repo]
|
Command line options parser.
This is a wrapper for the "The Lean Mean C++ Option Parser" command line parser.
Definition at line 58 of file clOptions.hpp.
#include <app/clOptions.hpp>
Public Member Functions | |
| ~clOptions () | |
| D'tor. Deletes the options and buffer pointers. | |
| void | clear () |
| Clear the memory held by this object. | |
| void | add (const std::string &optName, const char *const shortOpt, const char *const longOpt, int argT) |
| Add a command line option target. | |
| void | parse (int argc, char **argv, std::vector< std::string > *nonOptions=0) |
| Parse the command line. | |
| const char * | operator[] (const std::string &key) |
| Get the value of the option, if present. | |
| int | count (const std::string &key) |
| Get the number of times the option was set on the command line. | |
| void | getAll (std::vector< std::string > &args, const std::string &key) |
| Fill a vector of strings with the arguments supplied for key, last to first. | |
| bool | optSet (const std::string &key) |
| Test whether this option was set. | |
| int | numUnknown () |
| Get the number of unknown options found by the parser. | |
| int | unknown (std::vector< std::string > &unk) |
| Get a vector of the unknown options found by the parser. | |
Public Attributes | |
| unsigned int | nOpts { 0 } |
| The number of options added. | |
| mx::app::clOptions::~clOptions | ( | ) |
D'tor. Deletes the options and buffer pointers.
Definition at line 48 of file clOptions.cpp.
| void mx::app::clOptions::add | ( | const std::string & | optName, |
| const char *const | shortOpt, | ||
| const char *const | longOpt, | ||
| int | argT | ||
| ) |
Add a command line option target.
| [in] | optName | The name of the option, used as its key |
| [in] | shortOpt | The short option character |
| [in] | longOpt | The long option keyword |
| [in] | argT | The option type |
Definition at line 71 of file clOptions.cpp.
References nOpts.
Referenced by mx::app::appConfigurator::parseCommandLine().
| void mx::app::clOptions::clear | ( | ) |
Clear the memory held by this object.
Definition at line 56 of file clOptions.cpp.
| int mx::app::clOptions::count | ( | const std::string & | key | ) |
Get the number of times the option was set on the command line.
| [in] | key | the key identifying the element |
Definition at line 166 of file clOptions.cpp.
Referenced by mx::app::appConfigurator::parseCommandLine().
| void mx::app::clOptions::getAll | ( | std::vector< std::string > & | args, |
| const std::string & | key | ||
| ) |
Fill a vector of strings with the arguments supplied for key, last to first.
| [out] | args | will be resized and populated with the arguments. Will be empty if no arguments specified. |
| [in] | key | the key identifying the element |
Definition at line 176 of file clOptions.cpp.
Referenced by mx::app::appConfigurator::parseCommandLine().
| int mx::app::clOptions::numUnknown | ( | ) |
Get the number of unknown options found by the parser.
Definition at line 253 of file clOptions.cpp.
References nOpts.
Referenced by mx::app::appConfigurator::parseCommandLine(), and unknown().
| const char * mx::app::clOptions::operator[] | ( | const std::string & | key | ) |
Get the value of the option, if present.
For a true/false type, returns true or false as appropriate. Returns an empty string if no argument for the key. Otherwise return the argument.
| [in] | key | the key identifying the element |
Definition at line 130 of file clOptions.cpp.
| bool mx::app::clOptions::optSet | ( | const std::string & | key | ) |
Test whether this option was set.
| [in] | key | the key identifying the element |
Definition at line 241 of file clOptions.cpp.
Referenced by mx::app::appConfigurator::parseCommandLine().
| void mx::app::clOptions::parse | ( | int | argc, |
| char ** | argv, | ||
| std::vector< std::string > * | nonOptions = 0 |
||
| ) |
Parse the command line.
| [in] | argc | From main(argc, argv), the number of command line arguments |
| argv | in] From main(argc, argv), the command line arguments | |
| [out] | nonOptions | [optional] the elements in argv which are not option or option-arguments. |
Definition at line 99 of file clOptions.cpp.
References nOpts, and parse().
Referenced by parse(), and mx::app::appConfigurator::parseCommandLine().
| int mx::app::clOptions::unknown | ( | std::vector< std::string > & | unk | ) |
Get a vector of the unknown options found by the parser.
| [out] | unk | the vector to populate with the unknown options found |
Definition at line 259 of file clOptions.cpp.
References nOpts, and numUnknown().
Referenced by mx::app::appConfigurator::parseCommandLine().
| unsigned int mx::app::clOptions::nOpts { 0 } |
The number of options added.
Definition at line 70 of file clOptions.hpp.
Referenced by add(), numUnknown(), parse(), mx::app::appConfigurator::parseCommandLine(), and unknown().