NGetOpt Class Template Reference

class implements an easy to use command-line processing utility More...

Inheritance diagram for NGetOpt:

NObject

List of all members.

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.
NGetOptadd (const NString &opt_short, const NString &opt_long, bool opt_opt, const NString &help, typename NOpt< HandlerType >::Handler handler)
 Adds a command-line option.
NGetOptadd (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.


Detailed Description

template<typename HandlerType>
class NGetOpt< HandlerType >

class implements an easy to use command-line processing utility
Examples:

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.


Member Enumeration Documentation

enum Style

Enumerates acceptable command-line styles.

Enumerator:
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.


Constructor & Destructor Documentation

NGetOpt ( int  argc,
char **  argv,
HandlerType *  handler,
nuint32  min_args = 0,
Style  style = GNU_STYLE 
) [inline]

Constructs a NGetOpt object.

Parameters:
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.

References BSD_STYLE, and GNU_STYLE.


Member Function Documentation

void setStyle ( Style  style  )  [inline]

Sets the style used for the command line options.

Parameters:
style The style of command-line as defined by the enum Style

Definition at line 188 of file ngetopt.hpp.

NGetOpt< HandlerType >::Style getStyle ( void   )  const [inline]

Gets the style used for the command line options.

Returns:
The style used for the command line options as defined by the enum Style

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.

Parameters:
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
Returns:
A reference to the current object

Definition at line 200 of file ngetopt.hpp.

References NDebug::print().

NGetOpt< HandlerType > & add ( const NOpt< HandlerType > &  opt  )  [inline]

Adds a command-line option.

Parameters:
opt An already set up NOpt object
Returns:
A reference to the current 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.

Returns:
True in case of success or false otherwise

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().


The documentation for this class was generated from the following file:
Generated on Wed Mar 5 23:10:36 2008 for NemesisUtilitiesSystem by  doxygen 1.5.4