Main Page   Namespace List   Alphabetical List   Compound List   File List   Compound Members  

cmdl::CmdLineException Class Reference

handles command line usage errors. More...

#include <cmdline.h>

List of all members.

Public Types

enum  error_t {
  unknown_option = 0, invalid_argument = 1, too_many_arguments = 2, no_multiple_use = 3,
  argument_expected = 4, option_expected = 5
}

Public Methods

 CmdLineException (const std::string &strOption, error_t nError)
virtual ~CmdLineException () throw ()
error_t get_error_code () const
const std::string & get_option ()
virtual const char * what () const throw ()

Private Attributes

std::string m_strOption
error_t m_nError
std::string m_strError


Detailed Description

handles command line usage errors.

CmdLineExceptions are thrown in case of command line usage error. They are thrown when parsing the command line using Cmdline::GetSingleValue(), CmdLine::Call() or CmdLine::Done().

See also:
CmdLine


Member Enumeration Documentation

enum cmdl::CmdLineException::error_t
 

Error codes used with a CmdLineException:

  • unknown_option:
    The option was not used in call of CmdLine::Call() or CmdLine::GetSingleValue(). The exception is thrown in CmdLine::Done().
  • invalid_argument:
    Conversion from argument (of const char *) to needed type failed.
  • too_many_arguments:
    The command line option may only have one (resp. 0) arguments.
  • no_multiple_use:
    The option may not be used multiple times.
  • argument_expected:
    The option must have an argument.
  • option_expected:
    The commandline must start with an option.
Enumeration values:
unknown_option 
invalid_argument 
too_many_arguments 
no_multiple_use 
argument_expected 
option_expected 


Constructor & Destructor Documentation

cmdl::CmdLineException::CmdLineException const std::string &    strOption,
error_t    nError
[inline]
 

Command line exceptions are usually thrown by members of class CmdLine. If a user defined class is used with CmdLine::Call or CmdLine::GetSingleValue, then the user defined istream& operator>>(istream &in, your_class_t) may throw a CmdLineException indicating an invalid argument. However, it is recommended to set the istream's status instead: in.clear( ios::failbit ). Then CmdLine's member functions will throw the CmdLineException.

virtual cmdl::CmdLineException::~CmdLineException   throw () [virtual]
 


Member Function Documentation

error_t cmdl::CmdLineException::get_error_code   const [inline]
 

Returns:
code of the error occurred.
See also:
error_t

const std::string& cmdl::CmdLineException::get_option   [inline]
 

Returns:
the command line option the error occurred with.

virtual const char* cmdl::CmdLineException::what   const throw () [virtual]
 

Translates the error code (given in the constructor) to an englisch error message. Informs the user which option the error occured with.

Returns:
error message (in english).


Member Data Documentation

error_t cmdl::CmdLineException::m_nError [private]
 

the error code.

std::string cmdl::CmdLineException::m_strError [private]
 

the error message constructed by what().

std::string cmdl::CmdLineException::m_strOption [private]
 

the command line option the error occurred with.


The documentation for this class was generated from the following file:
Generated on Sun Jan 12 11:17:52 2003 for CmdLine by doxygen1.2.16