libDwm-0.9.45
Dwm::OptArgs Class Reference

Class to encapsulate command line options and parse them. More...

#include <DwmOptArgs.hh>

Public Member Functions

void AddOptArg (const OptArg &optarg)
 Adds an optional argument.
 
void AddOptArg (const std::string &name, const std::string &longName, bool isRequired=false, const std::string &def="", const std::string &help="")
 Adds an optional argument.
 
void AddNormalArg (const std::string &name, bool required)
 
template<typename T >
Get (int c)
 Fetches the value of an optional argument by its short name.
 
template<typename T >
Get (const std::string &s)
 Fetches the value of an optional argument by its long name.
 
int Parse (int argc, const std::string argv[])
 Parses all optional arguments.
 
int Parse (int argc, char *argv[])
 Parses all optional arguments.
 
void Usage (const std::string &argv0) const
 Prints the usage statement.
 

Protected Attributes

std::map< int, OptArg_args
 
std::map< std::string, OptArg * > _longArgs
 
std::vector< std::pair< std::string, bool > > _normalArgs
 

Detailed Description

Class to encapsulate command line options and parse them.

Member Function Documentation

◆ Parse() [1/2]

int Dwm::OptArgs::Parse ( int argc,
char * argv[] )

Parses all optional arguments.

Returns the next argument index, which the caller should compare against argc. If parsing fails, will emit a usage statement and exit.

◆ Parse() [2/2]

int Dwm::OptArgs::Parse ( int argc,
const std::string argv[] )

Parses all optional arguments.

Returns the next argument index, which the caller should compare against argc. If parsing fails, will emit a usage statement and exit.


The documentation for this class was generated from the following file: