Public Member Functions

base::CommandLine Class Reference

For parsing command line options, equivalent to UNIX getopt() function. More...

#include <libppbase/base/CommandLine.h>

List of all members.

Public Member Functions

 CommandLine (int argc, const char **argv, const char *optstring, bool bopterr=true)
 Constructor.
void dump (int ret) const
 Dumps the internal state to stdout.
int getopt ()
 Returns the next command line option.
const char * optarg () const
 Returns the option argument.
int optind () const
 Returns the current position in the command line.
int optopt () const
 Returns the value of the unknow option, in case getopt returned '?'.

Detailed Description

For parsing command line options, equivalent to UNIX getopt() function.

Author:
Christoph Schwarz
Version:
$Id: CommandLine.h 21 2010-09-05 04:18:17Z cschwarz1 $

Constructor & Destructor Documentation

base::CommandLine::CommandLine ( int  argc,
const char **  argv,
const char *  optstring,
bool  bopterr = true 
)

Constructor.

Parameters:
argc number of arguments, pass argc from main() here
argv command line arguments, pass argv from main() here
optstring pass option string here
bopterr true to print error messages, false to inhibit them

Member Function Documentation

void base::CommandLine::dump ( int  ret  )  const

Dumps the internal state to stdout.

Parameters:
ret the return code from getopt
int base::CommandLine::getopt (  ) 

Returns the next command line option.

Returns:
'?' when encountering an unknown option, -1 if there are no more options
const char* base::CommandLine::optarg (  )  const

Returns the option argument.

Returns:
NULL if there is no argument
int base::CommandLine::optind (  )  const

Returns the current position in the command line.

Returns:
the current position, in the range 1 .. argc
int base::CommandLine::optopt (  )  const

Returns the value of the unknow option, in case getopt returned '?'.

Returns:
the unknown option

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