VR-Link API Documentation for HLA 1516
cmdArgException.h
Go to the documentation of this file.
00001 
00002 /****************************************************************************** 
00003  * 
00004  *  file:  ArgException.h
00005  * 
00006  *  Copyright (c) 2003, Michael E. Smoot .
00007  *  All rights reverved.
00008  * 
00009  *  See the file COPYING in the top directory of this distribution for
00010  *  more information.
00011  *  
00012  *  THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS 
00013  *  OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
00014  *  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 
00015  *  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
00016  *  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
00017  *  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 
00018  *  DEALINGS IN THE SOFTWARE.  
00019  *  
00020  *****************************************************************************/ 
00024 
00025 
00026 #ifndef DtCmdLine_ARG_EXCEPTION_H
00027 #define DtCmdLine_ARG_EXCEPTION_H
00028  
00029 
00030 #include <string>
00031 #include <exception>
00032 
00033 #ifdef DtUSE_UTILITIES_NAMESPACE
00034 namespace DtUSE_UTILITIES_NAMESPACE
00035 {
00036 #endif
00037 
00038 namespace DtCmdLine {
00039 
00043    class ArgException : public std::exception
00044    {
00045    public:
00046 
00052       ArgException( const std::string& text = "undefined exception", 
00053                     const std::string& id = "undefined",
00054                     const std::string& td = "Generic ArgException")
00055          : std::exception(), 
00056          _errorText(text), 
00057          _argId( id ), 
00058          _typeDescription(td)
00059       { } 
00060 
00064       virtual ~ArgException() throw() 
00065       { }
00066 
00070       std::string error() const 
00071       { return ( _errorText ); }
00072 
00076       std::string argId() const  
00077       { 
00078          if ( _argId == "undefined" )
00079             return " ";
00080          else
00081             return ( "Argument: " + _argId ); 
00082       }
00083 
00087       const char* what() const throw() 
00088       {
00089          std::string ex = _argId + " -- " + _errorText;
00090          return ex.c_str();
00091       }
00092 
00097       std::string typeDescription() const
00098       {
00099          return _typeDescription; 
00100       }
00101 
00102 
00103    private:
00104 
00108       std::string _errorText;
00109 
00113       std::string _argId;
00114 
00119       std::string _typeDescription;
00120 
00121    };
00122 
00127    class ArgParseException : public ArgException
00128    { 
00129    public:
00136       ArgParseException( const std::string& text = "undefined exception", 
00137                          const std::string& id = "undefined" )
00138          : ArgException( text, 
00139                          id, 
00140                          std::string( "Exception found while parsing " ) + 
00141                          std::string( "the value the Arg has been passed." ))
00142       { }
00143    };
00144 
00149    class CmdLineParseException : public ArgException
00150    {
00151    public:
00158       CmdLineParseException( const std::string& text = "undefined exception", 
00159                              const std::string& id = "undefined" )
00160          : ArgException( text, 
00161                          id,
00162                          std::string( "Exception found when the values ") +
00163                          std::string( "on the command line do not meet ") +
00164                          std::string( "the requirements of the defined ") +
00165                          std::string( "Args." ))
00166          { }
00167    };
00168 
00173    class SpecificationException : public ArgException
00174    {
00175    public:
00182       SpecificationException( const std::string& text = "undefined exception",
00183                               const std::string& id = "undefined" )
00184          : ArgException( text, 
00185                          id,
00186                          std::string("Exception found when an Arg object ")+
00187                          std::string("is improperly defined by the ") +
00188                          std::string("developer." )) 
00189          { }
00190 
00191    };
00192 
00193 } 
00194 
00195 #ifdef DtUSE_UTILITIES_NAMESPACE
00196 }     
00197 #endif
00198 
00199 #endif
00200 

Document ID: Generated on Mon May 14 08:06:18 EDT 2012 from SVN revision 114750
Copyright © 2005-2012 VT MÄK Inc. All Rights Reserved (www.mak.com)