70 G_EXCEPTION( InvalidSpecification ,
"invalid options specification string" ) ;
72 explicit Options(
const std::string & spec ,
char sep_major =
'|' ,
char sep_minor =
'!' ,
char escape =
'^' ) ;
90 std::string
lookup(
char c )
const ;
94 bool valid(
const std::string & )
const ;
97 bool visible(
const std::string & name ,
Level ,
bool exact )
const ;
101 bool valued(
char )
const ;
105 bool valued(
const std::string & )
const ;
117 bool unvalued(
const std::string & option_name )
const ;
134 std::string
usageSummary(
const std::string & exe ,
const std::string & args ,
144 void showUsage( std::ostream & stream ,
const std::string & exe ,
145 const std::string & args = std::string() ,
const std::string & introducer =
introducerDefault() ,
147 bool extra =
true )
const ;
157 std::string description ;
158 std::string description_extra ;
159 unsigned int value_multiplicity ;
161 std::string value_description ;
164 Option(
char c_ ,
const std::string & name_ ,
const std::string & description_ ,
165 const std::string & description_extra_ ,
unsigned int value_multiplicity_ ,
166 const std::string & vd_ ,
unsigned int level_ ) ;
170 void parseSpec(
const std::string & spec ,
char ,
char ,
char ) ;
171 void addSpec(
const std::string & ,
char c ,
const std::string & ,
const std::string & ,
172 unsigned int ,
const std::string & ,
unsigned int ) ;
173 static size_t widthFloor(
size_t w ) ;
174 std::string usageSummaryPartOne(
Level )
const ;
175 std::string usageSummaryPartTwo(
Level )
const ;
176 std::string usageHelpCore(
const std::string & ,
Level ,
Layout ,
bool ,
bool )
const ;
179 typedef std::map<std::string,Option> Map ;
185 G::OptionsLevel::OptionsLevel(
unsigned int l ) :
191 G::OptionsLayout::OptionsLayout(
size_t column_ ) :
193 width(G::Options::widthDefault())
198 G::OptionsLayout::OptionsLayout(
size_t column_ ,
size_t width_ ) :
bool valid(const std::string &) const
Returns true if the long-form option name is valid.
bool unvalued(const std::string &option_name) const
Returns true if the given option name is valid and takes no value.
static Level levelDefault()
Returns the default level.
Describes the layout for G::Options output.
bool multivalued(char) const
Returns true if the short-form option can have multiple values.
std::vector< std::string > StringArray
A std::vector of std::strings.
static size_t widthDefault()
Returns a default, non-zero word-wrapping width, reflecting the size of the standard output where pos...
Used by G::Options for extra type safety.
std::string usageHelp(Level level=levelDefault(), Layout layout=layoutDefault(), bool level_exact=false, bool extra=true) const
Returns a multi-line string giving help on each option.
std::string lookup(char c) const
Converts from short-form option character to the corresponding long-form name.
static std::string introducerDefault()
Returns the string "usage: ".
std::string usageSummary(const std::string &exe, const std::string &args, const std::string &introducer=introducerDefault(), Level level=levelDefault(), size_t wrap_width=widthDefault()) const
Returns a one-line (or line-wrapped) usage summary, as "usage: <exe> <options> <args>".
static Layout layoutDefault()
Returns a default column layout.
std::string separator
separator between columns for two-column output
size_t width
overall width for wrapping, or zero for no newlines
bool valued(char) const
Returns true if the short-form option character is valid.
size_t column
left hand column width if no separator defined
bool visible(const std::string &name, Level, bool exact) const
Returns true if the option is visible at the given level.
const StringArray & names() const
Returns the sorted list of long-form option names.
std::string indent
indent for wrapped lines in two-column output
Options()
Default constructor for no options.
A class to represent allowed command-line options and to provide command-line usage text...
void showUsage(std::ostream &stream, const std::string &exe, const std::string &args=std::string(), const std::string &introducer=introducerDefault(), Level level=levelDefault(), Layout layout=layoutDefault(), bool extra=true) const
Streams out multi-line usage text using usageSummary() and usageHelp().