arg_exception.hpp
Go to the documentation of this file.
1 
11 /*****************************************************************************
12 ** Ifdefs
13 *****************************************************************************/
14 
15 #ifndef TCLAP_ARG_EXCEPTION_H
16 #define TCLAP_ARG_EXCEPTION_H
17 
18 #include <string>
19 #include <exception>
20 
21 namespace ecl {
22 
23 
30 class ArgException : public std::exception
31 {
32  public:
33 
41  ArgException( const std::string& text = "undefined exception",
42  const std::string& id = "undefined",
43  const std::string& td = "Generic ArgException")
44  : std::exception(),
45  _errorText(text),
46  _argId( id ),
48  { }
49 
53  virtual ~ArgException() throw() { }
54 
58  std::string error() const { return ( _errorText ); }
59 
63  std::string argId() const
64  {
65  if ( _argId == "undefined" )
66  return " ";
67  else
68  return ( "Argument: " + _argId );
69  }
70 
74  const char* what() const throw()
75  {
76  static std::string ex;
77  ex = _argId + " -- " + _errorText;
78  return ex.c_str();
79  }
80 
85  std::string typeDescription() const
86  {
87  return _typeDescription;
88  }
89 
90 
91  private:
92 
96  std::string _errorText;
97 
101  std::string _argId;
102 
107  std::string _typeDescription;
108 
109 };
110 
117 class ArgParseException : public ArgException
118 {
119  public:
126  ArgParseException( const std::string& text = "undefined exception",
127  const std::string& id = "undefined" )
128  : ArgException( text,
129  id,
130  std::string( "Exception found while parsing " ) +
131  std::string( "the value the Arg has been passed." ))
132  { }
133 };
134 
141 class CmdLineParseException : public ArgException
142 {
143  public:
150  CmdLineParseException( const std::string& text = "undefined exception",
151  const std::string& id = "undefined" )
152  : ArgException( text,
153  id,
154  std::string( "Exception found when the values ") +
155  std::string( "on the command line do not meet ") +
156  std::string( "the requirements of the defined ") +
157  std::string( "Args." ))
158  { }
159 };
160 
167 class SpecificationException : public ArgException
168 {
169  public:
176  SpecificationException( const std::string& text = "undefined exception",
177  const std::string& id = "undefined" )
178  : ArgException( text,
179  id,
180  std::string("Exception found when an Arg object ")+
181  std::string("is improperly defined by the ") +
182  std::string("developer." ))
183  { }
184 
185 };
186 
187 }; // namespace ecl
188 
189 
190 #endif
191 
ecl::ArgException::_argId
std::string _argId
Definition: arg_exception.hpp:105
ecl::CmdLineParseException::CmdLineParseException
CmdLineParseException(const std::string &text="undefined exception", const std::string &id="undefined")
Definition: arg_exception.hpp:152
ecl::ArgException::_errorText
std::string _errorText
Definition: arg_exception.hpp:100
ecl::SpecificationException::SpecificationException
SpecificationException(const std::string &text="undefined exception", const std::string &id="undefined")
Definition: arg_exception.hpp:178
ecl::ArgException
Defines the exception that is thrown whenever a command line is created and parsed.
Definition: arg_exception.hpp:32
ecl::ArgException::_typeDescription
std::string _typeDescription
Definition: arg_exception.hpp:111
ecl::ArgParseException
Defines the exception that is thrown when an argument is improperly parsed.
Definition: arg_exception.hpp:119
ecl::ArgException::ArgException
ArgException(const std::string &text="undefined exception", const std::string &id="undefined", const std::string &td="Generic ArgException")
Definition: arg_exception.hpp:45
ecl::ArgException::what
const char * what() const
Definition: arg_exception.hpp:78
ecl::ArgParseException::ArgParseException
ArgParseException(const std::string &text="undefined exception", const std::string &id="undefined")
Definition: arg_exception.hpp:128
ecl::ArgException::argId
std::string argId() const
Definition: arg_exception.hpp:67
ecl::ArgException::error
std::string error() const
Definition: arg_exception.hpp:62
ecl::ArgException::typeDescription
std::string typeDescription() const
Definition: arg_exception.hpp:89
ecl::ArgException::~ArgException
virtual ~ArgException()
Definition: arg_exception.hpp:57
ecl


ecl_command_line
Author(s): Daniel Stonier
autogenerated on Sun Aug 2 2020 03:12:03