libtabula::CommandLineBase Class Reference

Parses command line arguments and holds the results. More...

#include <cmdline.h>

Inheritance diagram for libtabula::CommandLineBase:
Inheritance graph
[legend]

List of all members.

Public Types

typedef std::vector< std::string > ArgumentList
 Type for a list of arguments.
typedef
ArgumentList::const_iterator 
ArgumentListIt
 Iterator into ArgumentList.

Public Member Functions

const ArgumentListextra_args () const
 Get reference to list of command line arguments past the last flag and its possible argument.
 operator void * () const
 Return truthy value if command line was parsed successfully.

Protected Member Functions

 CommandLineBase (int argc, char *const argv[], const char *opts)
 Hidden ctor to prevent instantiation.
virtual ~CommandLineBase ()
 Hidden dtor to prevent instantiation.
void finish_parse ()
 If object is still marked as "successful", save non-option arguments to extra_args_ list. Subclass ctor should call this after the parse_next() loop gets EOF.
const char * option_argument () const
 Accessor for getopt()'s optarg global.
int option_index () const
 Accessor for getopt()'s optind global.
void parse_error (const char *message=0)
 Called by a subclass when encountering a command line parsing error.
int parse_next () const
 Wrapper for getopt().
virtual void print_usage () const =0
 Show a message explaining the program's proper usage.
const char * program_name () const
 Get the file name of the program's executable.
bool successful () const
 Returns true if nothing has gone wrong since calling the ctor.

Detailed Description

Parses command line arguments and holds the results.

This class just contains common functionality and data structures; instantiable subclasses follow.


Member Typedef Documentation

typedef std::vector<std::string> libtabula::CommandLineBase::ArgumentList

Type for a list of arguments.

Public types


Constructor & Destructor Documentation

libtabula::CommandLineBase::CommandLineBase ( int  argc,
char *const   argv[],
const char *  opts 
) [inline, protected]

Hidden ctor to prevent instantiation.

Subclass interface


Member Function Documentation

const ArgumentList& libtabula::CommandLineBase::extra_args (  )  const [inline]

Get reference to list of command line arguments past the last flag and its possible argument.

Public interface

void libtabula::CommandLineBase::parse_error ( const char *  message = 0  )  [protected]

Called by a subclass when encountering a command line parsing error.

Prints the passed message, calls subclass's print_usage(), and marks the object as no longer successful.

References print_usage().

Referenced by libtabula::ssqlsxlat::CommandLine::CommandLine(), and libtabula::examples::CommandLine::CommandLine().


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

Generated on 26 May 2014 for Libtabula by  doxygen 1.6.1