mysqlpp::examples::CommandLine Class Reference

Command line parsing mechanism for ../examples/*.cpp. More...

`#include <cmdline.h>`

Inheritance diagram for mysqlpp::examples::CommandLine:
[legend]
Collaboration diagram for mysqlpp::examples::CommandLine:
[legend]

## Public Member Functions

| CommandLine (int argc, char *const argv[], const char *user=0, const char *pass=0, const char *usage_extra=0)
| Constructor. More...
void | print_usage () const
| Show a message explaining the program's proper usage. More...
void | print_usage (const char *extra) const
| Show a message explaining the program's proper usage, with custom extra info after standard command line usage bits.
bool | dtest_mode () const
| Return true if we're in "dtest" mode This happens when an example gets the -D flag, always passed by the dtest script to ask the programs it runs to suppress any nondeterministic output.
const char * | pass () const
| Return the DB password (-p argument)
int | run_mode () const
| Return the -m flag value. More...
const char * | server () const
| Return the DB server name (-s argument)
const char * | user () const
| Return the DB user name (-u argument)
Public Member Functions inherited from mysqlpp::CommandLineBase
const ArgumentList & | extra_args () const
| Get reference to list of command line arguments past the last flag and its possible argument. More...
| operator void * () const
| Return truthy value if command line was parsed successfully.

## Additional Inherited Members

Public Types inherited from mysqlpp::CommandLineBase
typedef std::vector< std::string > | ArgumentList
| Type for a list of arguments. More...
typedef ArgumentList::const_iterator | ArgumentListIt
| Iterator into ArgumentList.
Protected Member Functions inherited from mysqlpp::CommandLineBase
| CommandLineBase (int argc, char *const argv[], const char *opts)
| Hidden ctor to prevent instantiation. More...
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. More...
int | parse_next () const
| Wrapper for getopt()
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

Command line parsing mechanism for ../examples/*.cpp.

## Constructor & Destructor Documentation

mysqlpp::examples::CommandLine::CommandLine | ( | int | argc,
|  | char *const | argv[],
|  | const char * | user = `0`,
|  | const char * | pass = `0`,
|  | const char * | usage_extra = `0`
| ) |  |

Constructor.

Public interface

References mysqlpp::CommandLineBase::finish_parse(), mysqlpp::CommandLineBase::option_argument(), mysqlpp::CommandLineBase::parse_error(), mysqlpp::CommandLineBase::parse_next(), and mysqlpp::CommandLineBase::successful().

## Member Function Documentation

void mysqlpp::examples::CommandLine::print_usage | ( |  | ) | const

inline virtual

Show a message explaining the program's proper usage.

Calls print_usage(const char*), passing along the "usage_extra" parameter passed to the ctor

Implements mysqlpp::CommandLineBase.

References print_usage().

Referenced by print_usage().

int mysqlpp::examples::CommandLine::run_mode | ( |  | ) | const

inline

Return the -m flag value.

This flag is currently only used by examples/deadlock, but it's really a nonspecific "mode" value, which could be used by other examples in the future.

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

- cmdline.h
- cmdline.cpp