00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef TCLAP_ARG_EXCEPTION_H
00024 #define TCLAP_ARG_EXCEPTION_H
00025
00026 #include <string>
00027 #include <exception>
00028
00029 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00030 namespace TCLAP {
00031
00037 class ArgException : public std::exception
00038 {
00039 public:
00040
00048 ArgException( const std::string& text = "undefined exception",
00049 const std::string& id = "undefined",
00050 const std::string& td = "Generic ArgException")
00051 : std::exception(),
00052 _errorText(text),
00053 _argId( id ),
00054 _typeDescription(td)
00055 { }
00056
00060 virtual ~ArgException() throw() { }
00061
00065 std::string error() const { return ( _errorText ); }
00066
00070 std::string argId() const
00071 {
00072 if ( _argId == "undefined" )
00073 return " ";
00074 else
00075 return ( "Argument: " + _argId );
00076 }
00077
00081 const char* what() const throw()
00082 {
00083 static std::string ex;
00084 ex = _argId + " -- " + _errorText;
00085 return ex.c_str();
00086 }
00087
00092 std::string typeDescription() const
00093 {
00094 return _typeDescription;
00095 }
00096
00097
00098 private:
00099
00103 std::string _errorText;
00104
00108 std::string _argId;
00109
00114 std::string _typeDescription;
00115
00116 };
00117
00122 class ArgParseException : public ArgException
00123 {
00124 public:
00131 ArgParseException( const std::string& text = "undefined exception",
00132 const std::string& id = "undefined" )
00133 : ArgException( text,
00134 id,
00135 std::string( "Exception found while parsing " ) +
00136 std::string( "the value the Arg has been passed." ))
00137 { }
00138 };
00139
00144 class CmdLineParseException : public ArgException
00145 {
00146 public:
00153 CmdLineParseException( const std::string& text = "undefined exception",
00154 const std::string& id = "undefined" )
00155 : ArgException( text,
00156 id,
00157 std::string( "Exception found when the values ") +
00158 std::string( "on the command line do not meet ") +
00159 std::string( "the requirements of the defined ") +
00160 std::string( "Args." ))
00161 { }
00162 };
00163
00168 class SpecificationException : public ArgException
00169 {
00170 public:
00177 SpecificationException( const std::string& text = "undefined exception",
00178 const std::string& id = "undefined" )
00179 : ArgException( text,
00180 id,
00181 std::string("Exception found when an Arg object ")+
00182 std::string("is improperly defined by the ") +
00183 std::string("developer." ))
00184 { }
00185
00186 };
00187
00188 }
00189 #endif
00190
00191
00192 #endif
00193