UniversalIndentGUI 1.2.0
ArgException.h
Go to the documentation of this file.
00001 // -*- Mode: c++; c-basic-offset: 4; tab-width: 4; -*-
00002 
00003 /****************************************************************************** 
00004  * 
00005  *  file:  ArgException.h
00006  * 
00007  *  Copyright (c) 2003, Michael E. Smoot .
00008  *  All rights reverved.
00009  * 
00010  *  See the file COPYING in the top directory of this distribution for
00011  *  more information.
00012  *  
00013  *  THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS 
00014  *  OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
00015  *  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 
00016  *  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
00017  *  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
00018  *  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 
00019  *  DEALINGS IN THE SOFTWARE.  
00020  *  
00021  *****************************************************************************/ 
00022 
00023 
00024 #ifndef TCLAP_ARG_EXCEPTION_H
00025 #define TCLAP_ARG_EXCEPTION_H
00026 
00027 #include <string>
00028 #include <exception>
00029 
00030 namespace TCLAP {
00031 
00036 class ArgException : public std::exception
00037 {
00038     public:
00039     
00047         ArgException( const std::string& text = "undefined exception", 
00048                       const std::string& id = "undefined",
00049                       const std::string& td = "Generic ArgException")
00050             : std::exception(), 
00051               _errorText(text), 
00052               _argId( id ), 
00053               _typeDescription(td)
00054         { } 
00055         
00059         virtual ~ArgException() throw() { }
00060 
00064         std::string error() const { return ( _errorText ); }
00065 
00069         std::string argId() const  
00070         { 
00071             if ( _argId == "undefined" )
00072                 return " ";
00073             else
00074                 return ( "Argument: " + _argId ); 
00075         }
00076 
00080         const char* what() const throw() 
00081         {
00082             static std::string ex; 
00083             ex = _argId + " -- " + _errorText;
00084             return ex.c_str();
00085         }
00086 
00091         std::string typeDescription() const
00092         {
00093             return _typeDescription; 
00094         }
00095 
00096 
00097     private:
00098 
00102         std::string _errorText;
00103 
00107         std::string _argId;
00108 
00113         std::string _typeDescription;
00114 
00115 };
00116 
00121 class ArgParseException : public ArgException
00122 { 
00123     public:
00130         ArgParseException( const std::string& text = "undefined exception", 
00131                            const std::string& id = "undefined" )
00132             : ArgException( text, 
00133                             id, 
00134                             std::string( "Exception found while parsing " ) + 
00135                             std::string( "the value the Arg has been passed." ))
00136             { }
00137 };
00138 
00143 class CmdLineParseException : public ArgException
00144 {
00145     public:
00152         CmdLineParseException( const std::string& text = "undefined exception", 
00153                                const std::string& id = "undefined" )
00154             : ArgException( text, 
00155                             id,
00156                             std::string( "Exception found when the values ") +
00157                             std::string( "on the command line do not meet ") +
00158                             std::string( "the requirements of the defined ") +
00159                             std::string( "Args." ))
00160         { }
00161 };
00162 
00167 class SpecificationException : public ArgException
00168 {
00169     public:
00176         SpecificationException( const std::string& text = "undefined exception",
00177                                 const std::string& id = "undefined" )
00178             : ArgException( text, 
00179                             id,
00180                             std::string("Exception found when an Arg object ")+
00181                             std::string("is improperly defined by the ") +
00182                             std::string("developer." )) 
00183         { }
00184 
00185 };
00186 
00187 class ExitException {
00188 public:
00189     ExitException(int estat) : _estat(estat) {}
00190 
00191     int getExitStatus() const { return _estat; }
00192 
00193 private:
00194     int _estat;
00195 };
00196 
00197 } // namespace TCLAP
00198 
00199 #endif
00200 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines