Public Types | |
enum | Style { GNU_STYLE, BSD_STYLE, WINDOWS_STYLE } |
Enumerates acceptable command-line styles. More... | |
typedef NList< NOpt < HandlerType > > | NOptList |
Type definition for the command-line options list. | |
Public Member Functions | |
NGetOpt (int argc, char **argv, HandlerType *handler, nuint32 min_args=0, Style style=GNU_STYLE) | |
Constructs a NGetOpt object. | |
~NGetOpt (void) | |
Destroys a NGetOpt object. | |
void | setStyle (Style style) |
Sets the style used for the command line options. | |
Style | getStyle (void) const |
Gets the style used for the command line options. | |
NGetOpt & | add (const NString &opt_short, const NString &opt_long, bool opt_opt, const NString &help, typename NOpt< HandlerType >::Handler handler) |
Adds a command-line option. | |
NGetOpt & | add (const NOpt< HandlerType > &opt) |
Adds a command-line option. | |
bool | proccess (void) |
Proccess the command-line options. | |
void | help (void) |
Shows the help text of each function in a fancy/formatted output. |
ex_ndir.cpp, ex_nfileinfo.cpp, ex_ngetopt.cpp, ex_nregex.cpp, ex_nxmlreader.cpp, hashapp.cpp, and nsqlapp.cpp.
Definition at line 37 of file ngetopt.hpp.
enum Style |
Enumerates acceptable command-line styles.
GNU_STYLE | Use GNU style: (- and --). This is the default |
BSD_STYLE | Use BSD style: (- and -) |
WINDOWS_STYLE | Use Windows style: (/ and /) |
Definition at line 43 of file ngetopt.hpp.
NGetOpt | ( | int | argc, | |
char ** | argv, | |||
HandlerType * | handler, | |||
nuint32 | min_args = 0 , |
|||
Style | style = GNU_STYLE | |||
) | [inline] |
Constructs a NGetOpt object.
argc | Number of arguments | |
argv | The command-line arguments | |
handler | The handler object. The object to which one maps the treatment of each option | |
min_args | Minimum number of arguments that must be provided when calling the application | |
style | The style of command-line as defined by the enum Style |
Definition at line 148 of file ngetopt.hpp.
void setStyle | ( | Style | style | ) | [inline] |
Sets the style used for the command line options.
style | The style of command-line as defined by the enum Style |
Definition at line 188 of file ngetopt.hpp.
Gets the style used for the command line options.
Definition at line 194 of file ngetopt.hpp.
NGetOpt< HandlerType > & add | ( | const NString & | opt_short, | |
const NString & | opt_long, | |||
bool | opt_opt, | |||
const NString & | help, | |||
typename NOpt< HandlerType >::Handler | handler | |||
) | [inline] |
Adds a command-line option.
opt_short | A letter identifying the option | |
opt_long | A long option name or "" in case it doesn't exist | |
opt_opt | A boolean value indicating whether the option is required or not | |
help | A help text describing the option and its arguments | |
handler | The handler object. The object to which one maps the treatment of each option |
Definition at line 200 of file ngetopt.hpp.
References NDebug::print().
Adds a command-line option.
opt | An already set up NOpt object |
Definition at line 216 of file ngetopt.hpp.
References NList::append(), NList::contains(), NOpt::getLong(), NOpt::getShort(), and NWarning::print().
bool proccess | ( | void | ) | [inline] |
Proccess the command-line options.
Definition at line 394 of file ngetopt.hpp.
References NList::append(), NList::begin(), NList::end(), NOpt::getHandler(), NOpt::hasOpt(), help(), NOpt::isNull(), and NWarning::print().