Main::CommandLine Class Reference

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

#include <commandline.h>

List of all members.

Public Member Functions

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

Static Public Member Functions

static std::string switchSpec (bool is_windows)
 Returns an o/s-specific G::GetOpt switch specification string.


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 
)

Constructor.

Definition at line 547 of file commandline_full.cpp.

Main::CommandLine::~CommandLine (  ) 

Destructor.

Definition at line 553 of file commandline_full.cpp.


Member Function Documentation

std::string Main::CommandLine::switchSpec ( bool  is_windows  )  [static]

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

Definition at line 542 of file commandline_full.cpp.

References Main::CommandLineImp::switchSpec().

Referenced by main().

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

Returns a Configuration object.

Definition at line 558 of file commandline_full.cpp.

Referenced by hasSemanticError(), logSemanticWarnings(), and showSemanticError().

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

Returns true if the command line contained the give switch.

Definition at line 563 of file commandline_full.cpp.

References Main::CommandLineImp::contains().

Referenced by contains(), Main::Run::hidden(), and value().

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

Returns true if the command line contained the give switch.

Definition at line 648 of file commandline_full.cpp.

References contains().

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

Returns the given switch's string value.

Definition at line 568 of file commandline_full.cpp.

References Main::CommandLineImp::value().

Referenced by Main::Configuration::listeningInterfaces(), and value().

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

Returns the given switch's string value.

Definition at line 653 of file commandline_full.cpp.

References value().

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

Returns the given switch's integer value.

Definition at line 633 of file commandline_full.cpp.

References Main::CommandLineImp::contains(), G::Str::toUInt(), and value().

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

Returns the given switch's integer value.

Definition at line 658 of file commandline_full.cpp.

References value().

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 638 of file commandline_full.cpp.

References contains(), result, G::Str::splitIntoFields(), and value().

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

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

Definition at line 663 of file commandline_full.cpp.

References value().

unsigned int Main::CommandLine::argc (  )  const

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

Definition at line 573 of file commandline_full.cpp.

References Main::CommandLineImp::argc().

bool Main::CommandLine::hasUsageErrors (  )  const

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

Definition at line 578 of file commandline_full.cpp.

References Main::CommandLineImp::hasUsageErrors().

bool Main::CommandLine::hasSemanticError (  )  const

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

Definition at line 583 of file commandline_full.cpp.

References cfg(), and Main::CommandLineImp::hasSemanticError().

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

Writes help text.

Definition at line 588 of file commandline_full.cpp.

References Main::CommandLineImp::showHelp().

Referenced by Main::Run::prepare().

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

Writes the usage errors.

Definition at line 593 of file commandline_full.cpp.

References Main::CommandLineImp::showUsageErrors().

Referenced by Main::Run::prepare().

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

Writes the logic errors.

Definition at line 598 of file commandline_full.cpp.

References cfg(), and Main::CommandLineImp::showSemanticError().

Referenced by Main::Run::prepare().

void Main::CommandLine::logSemanticWarnings (  )  const

Emits warnings about conflicting switches.

Definition at line 603 of file commandline_full.cpp.

References cfg(), and Main::CommandLineImp::logSemanticWarnings().

Referenced by Main::Run::prepare().

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

Writes a too-many-arguments error message.

Definition at line 608 of file commandline_full.cpp.

References Main::CommandLineImp::showArgcError().

Referenced by Main::Run::prepare().

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

Writes a nothing-to-do message.

Definition at line 613 of file commandline_full.cpp.

References Main::CommandLineImp::showNoop().

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

Writes the version number.

Definition at line 618 of file commandline_full.cpp.

References Main::CommandLineImp::showVersion().

Referenced by Main::Run::prepare().

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

Writes a startup banner.

Definition at line 623 of file commandline_full.cpp.

References Main::CommandLineImp::showBanner().

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

Writes a copyright message.

Definition at line 628 of file commandline_full.cpp.

References Main::CommandLineImp::showCopyright().


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

Generated on Fri Apr 18 15:56:14 2008 for E-MailRelay by  doxygen 1.5.5