NOpt Class Template Reference

NOpt class is used to store a command line option passed to the application. More...

Inheritance diagram for NOpt:

NObject

List of all members.

Public Types

typedef bool(HandlerType::* Handler )(const NOpt &)
 Option handler type definition.

Public Member Functions

 NOpt (void)
 Creates a NOpt object.
 NOpt (const NString &opt_short, const NString &opt_long, bool opt_opt, const NString &help, Handler handler)
 Creates a NOpt object.
 ~NOpt ()
 Destroys a NOpt object.
void setShort (const NString &opt_short)
 Sets the identifier for the short option.
NString getShort (void) const
 Gets the identifier for the short option.
void setLong (const NString &opt_long)
 Sets the long option name.
NString getLong (void) const
 Gets the long option name.
void setOpt (bool opt_opt)
 Sets whether the option is required or not.
bool hasOpt (void) const
 Gets whether the option is required or not.
void setHelp (const NString &help)
 Sets a help text for the option.
NString getHelp (void) const
 Gets the help text for the option.
void addValue (const NString &value)
 Adds a value to the values list.
void addValues (const NList< NString > &values)
 Adds a set of values to the values list.
NList< NStringgetValues (void) const
 Gets the list of values of the option.
void setHandler (NOpt< HandlerType >::Handler handle)
 Sets the handler for the option.
Handler getHandler (void) const
 Gets the handler for te option.
bool isNull (void) const
 Tests whether the object is null or not.
void setRequired (bool required)
 Sets whether this option is required.
bool getRequired (void) const
 Gets whether this options is required.
bool operator== (const NOpt &rhs) const
 Tests whether the object equals another object.
bool operator!= (const NOpt &rhs) const
 Tests whether the object is different than another object.


Detailed Description

template<typename HandlerType>
class NOpt< HandlerType >

NOpt class is used to store a command line option passed to the application.
Examples:

clientapp.cpp, ex_ndir.cpp, ex_nfileinfo.cpp, ex_ngetopt.cpp, ex_nregex.cpp, hashapp.cpp, nsqlapp.cpp, xmlreader.cpp, and xmlreader.h.

Definition at line 37 of file nopt.hpp.


Constructor & Destructor Documentation

NOpt ( const NString opt_short,
const NString opt_long,
bool  opt_opt,
const NString help,
Handler  handler 
) [inline]

Creates a NOpt object.

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 method for the option

Definition at line 214 of file nopt.hpp.


Member Function Documentation

void setShort ( const NString opt_short  )  [inline]

Sets the identifier for the short option.

Parameters:
opt_short A letter identifying the option

Definition at line 235 of file nopt.hpp.

NString getShort ( void   )  const [inline]

Gets the identifier for the short option.

Returns:
A letter identifying the option

Definition at line 241 of file nopt.hpp.

Referenced by NGetOpt::add(), operator!=(), and operator==().

void setLong ( const NString opt_long  )  [inline]

Sets the long option name.

Parameters:
opt_long A long option name or "" in case it doesn't exist

Definition at line 247 of file nopt.hpp.

NString getLong ( void   )  const [inline]

Gets the long option name.

Returns:
The long option name

Definition at line 253 of file nopt.hpp.

Referenced by NGetOpt::add(), operator!=(), and operator==().

void setOpt ( bool  opt_opt  )  [inline]

Sets whether the option is required or not.

Parameters:
opt_opt A boolean value: true if it's required or false otherwise

Definition at line 259 of file nopt.hpp.

bool hasOpt ( void   )  const [inline]

Gets whether the option is required or not.

Returns:
A boolean value: true if it's required or false otherwise

Definition at line 265 of file nopt.hpp.

Referenced by NGetOpt::proccess().

void setHelp ( const NString help  )  [inline]

Sets a help text for the option.

Parameters:
help A help text describing the option, its arguments, etc

Definition at line 271 of file nopt.hpp.

NString getHelp ( void   )  const [inline]

Gets the help text for the option.

Returns:
The help text for the option

Definition at line 277 of file nopt.hpp.

void addValue ( const NString value  )  [inline]

Adds a value to the values list.

Parameters:
value The value to be added

Definition at line 284 of file nopt.hpp.

References NList::append().

void addValues ( const NList< NString > &  values  )  [inline]

Adds a set of values to the values list.

Parameters:
values A NList<NString> object containing a list of values

Definition at line 290 of file nopt.hpp.

References NList::copy().

NList< NString > getValues ( void   )  const [inline]

Gets the list of values of the option.

Returns:
A NList<NString> object with the values

Definition at line 296 of file nopt.hpp.

void setHandler ( NOpt< HandlerType >::Handler  handle  )  [inline]

Sets the handler for the option.

Parameters:
handle A method pointer of type void (NObject::*Handler)(const NOpt &)

Definition at line 302 of file nopt.hpp.

NOpt< HandlerType >::Handler getHandler ( void   )  const [inline]

Gets the handler for te option.

Returns:
A method pointer of type void (NObject::*Handler)(const NOpt &)

Definition at line 308 of file nopt.hpp.

Referenced by NGetOpt::proccess().

bool isNull ( void   )  const [inline]

Tests whether the object is null or not.

Returns:
true if it's null or false otherwise

Definition at line 314 of file nopt.hpp.

Referenced by NGetOpt::proccess().

void setRequired ( bool  required  ) 

Sets whether this option is required.

Parameters:
required True if it's required or false otherwise

bool getRequired ( void   )  const

Gets whether this options is required.

Returns:
True if it's required or false otherwise

bool operator== ( const NOpt< HandlerType > &  rhs  )  const [inline]

Tests whether the object equals another object.

Parameters:
rhs The object to test against
Returns:
true if it is equal or false otherwise

Definition at line 324 of file nopt.hpp.

References getLong(), and getShort().

bool operator!= ( const NOpt< HandlerType > &  rhs  )  const [inline]

Tests whether the object is different than another object.

Parameters:
rhs The object to test against
Returns:
true if it is different or false otherwise

Definition at line 347 of file nopt.hpp.

References getLong(), and getShort().


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