#include <CommandOptionParser.hpp>
By default, any CommandOptions you create will be put on a static vector<CommandOption> which is used by CommandOptionParser. You can make your own as well but that isn't necessary. You can also use addOption() to add individual CommandOptions to the parser, but again this isn't necessary as the default list is usually sufficient.
Call parseOptions() to process the command line, then call hasErrors() to see if there were any problems parsing the string. Errors can occur when a required option isn't found on the command line, when an option requiring an argument doesn't have one, or when an argument appers more than its maxCount number of times among other errors. If so, use dumpErrors() to display the errors to an output stream, then use displayUsage() to display a well formatted list of the correct command line options. Of course, you can just as well ignore any command line errors. After hitting an error (which most often happens when it hits an argument that has no CommandOption), you can use CommandOptionRest to get the unprocessed command line options.
Definition at line 93 of file CommandOptionParser.hpp.
Public Types | |
| typedef std::map< std::string, gpstk::CommandOption * > | CommandOptionMap |
| Typedef for a map between the command line option (-f) and the associated CommandOption. | |
Public Member Functions | |
| CommandOptionParser (const std::string &description, const CommandOptionVec optList=defaultCommandOptionList) | |
| Constructor given a text description of the program. | |
| CommandOptionParser & | addOption (gpstk::CommandOption &co) |
| Adds the CommandOption to the list for parsing. | |
| void | parseOptions (int argc, char *argv[]) |
| Parses the command line. | |
| bool | hasErrors () |
| Returns true if any processing errors occurred. | |
| std::ostream & | dumpErrors (std::ostream &out) |
Writes the errors to out. | |
| std::ostream & | displayUsage (std::ostream &out, bool doPretty=true) |
| Writes the arguments nicely to the output. | |
|
|
Typedef for a map between the command line option (-f) and the associated CommandOption.
Definition at line 98 of file CommandOptionParser.hpp. Referenced by CommandOptionParser::parseOptions(). |
|
||||||||||||
|
Constructor given a text description of the program.
Definition at line 106 of file CommandOptionParser.hpp. |
|
|
Adds the CommandOption to the list for parsing.
Definition at line 115 of file CommandOptionParser.hpp. |
|
||||||||||||
|
Writes the arguments nicely to the output.
Definition at line 287 of file CommandOptionParser.cpp. References gpstk::StringUtils::asInt(), CommandOption::description, index(), gpstk::StringUtils::leftJustify(), gpstk::max(), and gpstk::StringUtils::prettyPrint(). Referenced by ObsEphReaderFramework::initialize(), BasicFramework::initialize(), and main(). |
|
|
Writes the errors to
Definition at line 277 of file CommandOptionParser.cpp. References index(). Referenced by ObsEphReaderFramework::initialize(), BasicFramework::initialize(), and main(). |
|
|
Returns true if any processing errors occurred.
Definition at line 122 of file CommandOptionParser.hpp. Referenced by ObsEphReaderFramework::initialize(), BasicFramework::initialize(), and main(). |
|
||||||||||||
|
Parses the command line.
Definition at line 71 of file CommandOptionParser.cpp. References CommandOption::checkArguments(), CommandOptionParser::CommandOptionMap, CommandOption::count, CommandOption::getOptionString(), index(), CommandOption::optFlag, CommandOption::order, CommandOption::toGetoptLongOption(), CommandOption::toGetoptShortOption(), and CommandOption::value. Referenced by ObsEphReaderFramework::initialize(), BasicFramework::initialize(), and main(). |
1.3.9.1