Console node tree based command line option parser. More...
#include <senf/Utils/Console/ProgramOptions.hh>
Public Member Functions | |
template<class Container > | |
ProgramOptions & | nonOptions (Container &container) |
Set container to add non-option arguments to. More... | |
ProgramOptions & | alias (char letter, std::string const &longOpt, bool withArg=false) |
Set short option alias. More... | |
Public Member Functions inherited from senf::console::detail::BundleMixin | |
BundleMixin () | |
BundleMixin (DirectoryNode &root) | |
void | parse () |
Parse config file. More... | |
void | parse (DirectoryNode &restrict) |
Parse config file under restrict. More... | |
bool | complete () const |
true , if all nodes have been parsed More... | |
bool | parsed (GenericNode &node) const |
true . if node has been parsed More... | |
void | reset () |
Reset node parse info state. More... | |
Related Functions | |
(Note that these are not member functions.) | |
void | parseOptions (int argc, char const **argv, DirectoryNode &root=senf::console::root()) |
Parse command line options. More... | |
detail::ProgramOptionsSource::ptr | OptionsConfig (int argc, char const **argv) |
ConfigBundle source reading command line options. More... | |
Structors and default members | |
ProgramOptions (int argc, char const **argv, DirectoryNode &root=senf::console::root()) | |
Create ProgramOptions parser for given options. More... | |
Additional Inherited Members | |
Protected Member Functions inherited from senf::console::detail::BundleMixin | |
template<class Source > | |
Source & | add (boost::intrusive_ptr< Source > source) |
Console node tree based command line option parser.
A ProgramOptions instance allows flexible parsing of command line options against the console node tree. If you just want to parse all options, the senf::console::parseOptions() function will do that. ProgramOptions however allows to incrementally parse only a subset of the given command line options.
If your application uses multiple configuration sources, use a ConfigBundle and OptionsConfig.
Definition at line 58 of file ProgramOptions.hh.
senf::console::ProgramOptions::ProgramOptions | ( | int | argc, |
char const ** | argv, | ||
DirectoryNode & | root = senf::console::root() |
||
) |
Create ProgramOptions parser for given options.
The given argc/argv values are those passed to main by the operating system. Especially argv[0] is not an option and is ignored.
ProgramOptions& senf::console::ProgramOptions::alias | ( | char | letter, |
std::string const & | longOpt, | ||
bool | withArg = false |
||
) |
Set short option alias.
A short option is always an alias for a long option with or without argument. if withArg is true
, the short option will expect an argument on the command line. This argument will be appended (with an additional '=') to longOpt. If withArg is false
(the default), longOpt may optional contain an argument.
[in] | letter | option letter |
[in] | longOpt | long option alias |
[in] | withArg | true , if the option should take an argument. |
ProgramOptions& senf::console::ProgramOptions::nonOptions | ( | Container & | container | ) |
|
related |
ConfigBundle source reading command line options.
This constructor is used to create a config source parsing the given command line options to add to a ConfigBundle.
|
related |
Parse command line options.
The command line options in argc / argv will be parsed, interpreting all node's relative to root as root node.