clingo
|
A (logically grouped) list of unique options. More...
#include <program_options.h>
Public Types | |
enum | FindType { find_name = 1, find_prefix = 2, find_name_or_prefix = find_name|find_prefix, find_alias = 4 } |
typedef OptionList::const_iterator | option_iterator |
Type for identifying an option within a context. More... | |
typedef PrefixRange | OptionRange |
Public Member Functions | |
OptionContext (const std::string &caption="", DescriptionLevel desc_default=desc_level_default) | |
~OptionContext () | |
const std::string & | caption () const |
OptionContext & | add (const OptionGroup &group) |
Adds the given group of options to this context. More... | |
OptionContext & | addAlias (const std::string &aliasName, option_iterator option) |
Adds an alias name for the given option. More... | |
OptionContext & | add (const OptionContext &other) |
Adds all groups (and their options) from other to this context. More... | |
option_iterator | begin () const |
option_iterator | end () const |
std::size_t | size () const |
Returns the number of options in this context. More... | |
std::size_t | groups () const |
Returns the number of groups in this context. More... | |
option_iterator | find (const char *key, FindType t=find_name) const |
Returns the option with the given key. More... | |
option_iterator | tryFind (const char *key, FindType t=find_name) const |
OptionRange | findImpl (const char *key, FindType t, unsigned eMask=unsigned(-1)) const |
OptionRange | findImpl (const char *key, FindType t, unsigned eMask, const std::string &eCtx) const |
const OptionGroup & | findGroup (const std::string &caption) const |
const OptionGroup * | tryFindGroup (const std::string &caption) const |
void | setActiveDescLevel (DescriptionLevel level) |
Sets the description level to be used when generating description. More... | |
DescriptionLevel | getActiveDescLevel () const |
OptionOutput & | description (OptionOutput &out) const |
Writes a formatted description of options in this context. More... | |
std::string | defaults (std::size_t prefixSize=0) const |
Returns the default command-line of this context. More... | |
bool | assignDefaults (const ParsedOptions &exclude) const |
Assigns any default values to all options not in exclude. More... | |
Friends | |
std::ostream & | operator<< (std::ostream &os, const OptionContext &ctx) |
Writes a formatted description of options in this context to os. More... | |
A (logically grouped) list of unique options.
An option context stores a list of option groups. Options in a context have to be unique (w.r.t name and alias) within that context.
An OptionContext defines the granularity of option parsing and option lookup.
typedef OptionList::const_iterator ProgramOptions::OptionContext::option_iterator |
Type for identifying an option within a context.
typedef PrefixRange ProgramOptions::OptionContext::OptionRange |
ProgramOptions::OptionContext::OptionContext | ( | const std::string & | caption = "" , |
DescriptionLevel | desc_default = desc_level_default |
||
) |
ProgramOptions::OptionContext::~OptionContext | ( | ) |
OptionContext & ProgramOptions::OptionContext::add | ( | const OptionGroup & | group | ) |
Adds the given group of options to this context.
DuplicateOption | if an option in group has the same short or long name as one of the options in this context. |
OptionContext & ProgramOptions::OptionContext::add | ( | const OptionContext & | other | ) |
Adds all groups (and their options) from other to this context.
DuplicateOption | if an option in other has the same short or long name as one of the options in this context. |
OptionContext & ProgramOptions::OptionContext::addAlias | ( | const std::string & | aliasName, |
option_iterator | option | ||
) |
Adds an alias name for the given option.
DuplicateOption | if an option with the name aliasName already exists. |
bool ProgramOptions::OptionContext::assignDefaults | ( | const ParsedOptions & | exclude | ) | const |
Assigns any default values to all options not in exclude.
ValueError | if some default value is actually invalid for its option. |
|
inline |
const std::string & ProgramOptions::OptionContext::caption | ( | ) | const |
std::string ProgramOptions::OptionContext::defaults | ( | std::size_t | prefixSize = 0 | ) | const |
Returns the default command-line of this context.
OptionOutput & ProgramOptions::OptionContext::description | ( | OptionOutput & | out | ) | const |
Writes a formatted description of options in this context.
|
inline |
OptionContext::option_iterator ProgramOptions::OptionContext::find | ( | const char * | key, |
FindType | t = find_name |
||
) | const |
Returns the option with the given key.
UnknownOption | if no option matches key. |
AmbiguousOption | if more than one option matches key. |
const OptionGroup & ProgramOptions::OptionContext::findGroup | ( | const std::string & | caption | ) | const |
|
inline |
OptionContext::PrefixRange ProgramOptions::OptionContext::findImpl | ( | const char * | key, |
FindType | t, | ||
unsigned | eMask, | ||
const std::string & | eCtx | ||
) | const |
|
inline |
|
inline |
Returns the number of groups in this context.
void ProgramOptions::OptionContext::setActiveDescLevel | ( | DescriptionLevel | level | ) |
Sets the description level to be used when generating description.
Once set, functions generating descriptions will only consider groups and options with description level <= std::min(level, desc_level_all).
|
inline |
Returns the number of options in this context.
OptionContext::option_iterator ProgramOptions::OptionContext::tryFind | ( | const char * | key, |
FindType | t = find_name |
||
) | const |
Behaves like find but returns end() instead of throwing UnknownOption or AmbiguousOption.
const OptionGroup * ProgramOptions::OptionContext::tryFindGroup | ( | const std::string & | caption | ) | const |
|
friend |
Writes a formatted description of options in this context to os.