42 G_EXCEPTION( InvalidSpecification ,
tx(
"invalid options specification string") )
44 explicit Options(
const std::string & spec ,
char sep_major =
'|' ,
char sep_minor =
'!' ,
char escape =
'^' ) ;
69 static void add(
Options & ,
char c ,
const char * name ,
const char * text ,
70 const char * more , Option::Multiplicity m ,
const char * argname ,
71 unsigned int level ,
unsigned int main_tag_bit ,
unsigned int tag_bits = 0U ) ;
80 void add(
const Option & ,
char sep =
'!' ,
char escape =
'\\' ) ;
86 const std::vector<Option> &
list()
const ;
89 std::string
lookup(
char c )
const ;
93 bool valid(
const std::string & )
const ;
96 const Option *
find(
const std::string & )
const ;
100 bool visible(
const std::string & name ,
unsigned int level ,
bool level_exact =
false )
const ;
105 bool visible(
const std::string & name )
const ;
109 bool valued(
char )
const ;
115 bool valued(
const std::string & )
const ;
128 bool unvalued(
const std::string & )
const ;
132 bool defaulting(
const std::string & )
const ;
145 using List = std::vector<Option> ;
146 void parseSpec(
const std::string & spec ,
char ,
char ,
char ) ;
147 void addOption(
Option ,
char ,
char ) ;
A class to assemble a list of command-line options and provide access by name.
std::string lookup(char c) const
Converts from short-form option character to the corresponding long-form name.
bool unvalued(const std::string &) const
Returns true if the given option name is valid and takes no value.
static void add(Options &, char c, const char *name, const char *text, const char *more, Option::Multiplicity m, const char *argname, unsigned int level, unsigned int main_tag_bit, unsigned int tag_bits=0U)
A convenience function that constructs an Option object with the trailing arguments and then calls ad...
bool visible(const std::string &name, unsigned int level, bool level_exact=false) const
Returns true if the option is visible at the given level.
bool defaulting(const std::string &) const
Returns true if the given long-form single-valued() option can optionally have no explicit value,...
bool valid(const std::string &) const
Returns true if the long-form option name is valid.
bool multivalued(char) const
Returns true if the short-form option can have multiple values.
bool valued(char) const
Returns true if the given short-form option takes a value, Returns true if the short-form option char...
const Option * find(const std::string &) const
Returns a pointer to the option with a matching long-form name.
Options()
Default constructor for no options.
const std::vector< Option > & list() const
Returns the sorted list of option structures.
constexpr const char * tx(const char *p) noexcept
A briefer alternative to G::gettext_noop().
A structure representing a G::Options command-line option.