- Main Page
- Namespaces
- Classes
- Files

- Class List
- Class Hierarchy
- Class Members

Public Member Functions | Static Public Member Functions | List of all members
Main::CommandLine Class Reference

A class which deals with the command-line interface to the process, both input and output. More...

`#include <commandline.h>`

## Public Member Functions
| CommandLine (Main::Output &output, const G::Arg &arg, const std::string &spec, const std::string &version, const std::string &capabilities)
| Constructor. More...
| ~CommandLine ()
| Destructor. More...
Configuration | cfg () const
| Returns a Configuration object. More...
bool | contains (const std::string &switch_) const
| Returns true if the command line contained the give switch. More...
bool | contains (const char *switch_) const
| Returns true if the command line contained the give switch. More...
std::string | value (const std::string &switch_) const
| Returns the given switch's string value. More...
std::string | value (const char *switch_) const
| Returns the given switch's string value. More...
unsigned int | value (const std::string &switch_, unsigned int default_) const
| Returns the given switch's integer value. More...
unsigned int | value (const char *switch_, unsigned int default_) const
| Returns the given switch's integer value. More...
G::Strings | value (const std::string &switch_, const std::string &separators) const
| Returns the given switch's list-of-string value. More...
G::Strings | value (const char *switch_, const char *separators) const
| Returns the given switch's list-of-string value. More...
G::Arg::size_type | argc () const
| Returns the number of non-switch arguments on the command line. More...
bool | hasUsageErrors () const
| Returns true if the command line has usage errors (eg. invalid switch). More...
bool | hasSemanticError () const
| Returns true if the command line has logical errors (eg. conflicting switches). More...
void | showHelp (bool error_stream=false) const
| Writes help text. More...
void | showUsageErrors (bool error_stream=true) const
| Writes the usage errors. More...
void | showSemanticError (bool error_stream=true) const
| Writes the logic errors. More...
void | logSemanticWarnings () const
| Emits warnings about conflicting switches. More...
void | showArgcError (bool error_stream=true) const
| Writes a too-many-arguments error message. More...
void | showNoop (bool error_stream=false) const
| Writes a nothing-to-do message. More...
void | showError (const std::string &reason, bool error_stream=true) const
| Writes a failed message. More...
void | showVersion (bool error_stream=false) const
| Writes the version number. More...
void | showBanner (bool error_stream=false, const std::string &=std::string()) const
| Writes a startup banner. More...
void | showCopyright (bool error_stream=false, const std::string &=std::string()) const
| Writes a copyright message. More...
void | showCapabilities (bool error_stream=false, const std::string &=std::string()) const
| Writes a capability line. More...

## Static Public Member Functions
static std::string | switchSpec (bool is_windows)
| Returns an o/s-specific G::GetOpt switch specification string. More...

## Detailed Description

A class which deals with the command-line interface to the process, both input and output.

The input side is mostly done by providing a Configuration object via the cfg() method.

Definition at line 44 of file commandline.h.

## Constructor & Destructor Documentation

Main::CommandLine::CommandLine | ( | Main::Output & | output,
|  | const G::Arg & | arg,
|  | const std::string & | spec,
|  | const std::string & | version,
|  | const std::string & | capabilities
| ) |  |

Constructor.

Definition at line 609 of file commandline_full.cpp.

Main::CommandLine::~CommandLine | ( |  | ) |

Destructor.

Definition at line 615 of file commandline_full.cpp.

## Member Function Documentation

G::Arg::size_type Main::CommandLine::argc | ( |  | ) | const

Returns the number of non-switch arguments on the command line.

Definition at line 635 of file commandline_full.cpp.

Main::Configuration Main::CommandLine::cfg | ( |  | ) | const

Returns a Configuration object.

Definition at line 620 of file commandline_full.cpp.

bool Main::CommandLine::contains | ( | const std::string & | switch_ | ) | const

Returns true if the command line contained the give switch.

Definition at line 625 of file commandline_full.cpp.

bool Main::CommandLine::contains | ( | const char * | switch_ | ) | const

Returns true if the command line contained the give switch.

Definition at line 720 of file commandline_full.cpp.

bool Main::CommandLine::hasSemanticError | ( |  | ) | const

Returns true if the command line has logical errors (eg. conflicting switches).

Definition at line 645 of file commandline_full.cpp.

bool Main::CommandLine::hasUsageErrors | ( |  | ) | const

Returns true if the command line has usage errors (eg. invalid switch).

Definition at line 640 of file commandline_full.cpp.

void Main::CommandLine::logSemanticWarnings | ( |  | ) | const

Emits warnings about conflicting switches.

Definition at line 665 of file commandline_full.cpp.

void Main::CommandLine::showArgcError | ( | bool | error_stream = `true` | ) | const

Writes a too-many-arguments error message.

Definition at line 670 of file commandline_full.cpp.

void Main::CommandLine::showBanner | ( | bool | error_stream = `false`,
|  | const std::string & | s = `std::string()`
| ) |  | const

Writes a startup banner.

Definition at line 690 of file commandline_full.cpp.

void Main::CommandLine::showCapabilities | ( | bool | error_stream = `false`,
|  | const std::string & | s = `std::string()`
| ) |  | const

Writes a capability line.

Definition at line 700 of file commandline_full.cpp.

void Main::CommandLine::showCopyright | ( | bool | error_stream = `false`,
|  | const std::string & | s = `std::string()`
| ) |  | const

Writes a copyright message.

Definition at line 695 of file commandline_full.cpp.

void Main::CommandLine::showError | ( | const std::string & | reason,
|  | bool | error_stream = `true`
| ) |  | const

Writes a failed message.

Definition at line 680 of file commandline_full.cpp.

void Main::CommandLine::showHelp | ( | bool | error_stream = `false` | ) | const

Writes help text.

Definition at line 650 of file commandline_full.cpp.

void Main::CommandLine::showNoop | ( | bool | error_stream = `false` | ) | const

Writes a nothing-to-do message.

Definition at line 675 of file commandline_full.cpp.

void Main::CommandLine::showSemanticError | ( | bool | error_stream = `true` | ) | const

Writes the logic errors.

Definition at line 660 of file commandline_full.cpp.

void Main::CommandLine::showUsageErrors | ( | bool | error_stream = `true` | ) | const

Writes the usage errors.

Definition at line 655 of file commandline_full.cpp.

void Main::CommandLine::showVersion | ( | bool | error_stream = `false` | ) | const

Writes the version number.

Definition at line 685 of file commandline_full.cpp.

std::string Main::CommandLine::switchSpec | ( | bool | is_windows | ) |
| static

Returns an o/s-specific G::GetOpt switch specification string.

Definition at line 604 of file commandline_full.cpp.

References Main::CommandLineImp::switchSpec().

Referenced by main().

std::string Main::CommandLine::value | ( | const std::string & | switch_ | ) | const

Returns the given switch's string value.

Definition at line 630 of file commandline_full.cpp.

std::string Main::CommandLine::value | ( | const char * | switch_ | ) | const

Returns the given switch's string value.

Definition at line 725 of file commandline_full.cpp.

unsigned int Main::CommandLine::value | ( | const std::string & | switch_,
|  | unsigned int | default_
| ) |  | const

Returns the given switch's integer value.

Definition at line 705 of file commandline_full.cpp.

References G::Str::toUInt().

unsigned int Main::CommandLine::value | ( | const char * | switch_,
|  | unsigned int | default_
| ) |  | const

Returns the given switch's integer value.

Definition at line 730 of file commandline_full.cpp.

G::Strings Main::CommandLine::value | ( | const std::string & | switch_,
|  | const std::string & | separators
| ) |  | const

Returns the given switch's list-of-string value.

Definition at line 710 of file commandline_full.cpp.

References G::Str::splitIntoFields().

G::Strings Main::CommandLine::value | ( | const char * | switch_,
|  | const char * | separators
| ) |  | const

Returns the given switch's list-of-string value.

Definition at line 735 of file commandline_full.cpp.

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

- commandline.h
- commandline_full.cpp