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 
std::string _errorText
::std::string string
virtual ~ArgException()
std::string _typeDescription
std::string argId() const
std::string typeDescription() const
std::string error() const
const char * what() const
ArgException(const std::string &text="undefined exception", const std::string &id="undefined", const std::string &td="Generic ArgException")


xbot_node
Author(s): Roc, wangpeng@droid.ac.cn
autogenerated on Sat Oct 10 2020 03:28:13