Exception.h

Go to the documentation of this file.
00001 //
00002 //  Copyright (c) 2003-2006 by Autodesk, Inc.
00003 //
00004 //  By using this code, you are agreeing to the terms and conditions of
00005 //  the License Agreement included in the documentation for this code.
00006 //
00007 //  AUTODESK MAKES NO WARRANTIES, EXPRESS OR IMPLIED,
00008 //  AS TO THE CORRECTNESS OF THIS CODE OR ANY DERIVATIVE
00009 //  WORKS WHICH INCORPORATE IT.
00010 //
00011 //  AUTODESK PROVIDES THE CODE ON AN "AS-IS" BASIS
00012 //  AND EXPLICITLY DISCLAIMS ANY LIABILITY, INCLUDING
00013 //  CONSEQUENTIAL AND INCIDENTAL DAMAGES FOR ERRORS,
00014 //  OMISSIONS, AND OTHER PROBLEMS IN THE CODE.
00015 //
00016 //  Use, duplication, or disclosure by the U.S. Government is subject to
00017 //  restrictions set forth in FAR 52.227-19 (Commercial Computer Software
00018 //  Restricted Rights) and DFAR 252.227-7013(c)(1)(ii) (Rights in Technical
00019 //  Data and Computer Software), as applicable.
00020 //
00021 
00022 
00023 #ifndef _DWFCORE_EXCEPTION_H
00024 #define _DWFCORE_EXCEPTION_H
00025 
00026 
00031 
00032 #include "dwfcore/Core.h"
00033 
00034 
00035 namespace DWFCore
00036 {
00037 
00046 class DWFException  : virtual public DWFCoreMemory
00047 {
00048 
00049 public:
00050 
00056     _DWFCORE_API
00057     virtual ~DWFException()
00058         throw();
00059 
00068     _DWFCORE_API
00069     DWFException( const DWFException& )
00070         throw();
00071 
00080     _DWFCORE_API
00081     DWFException& operator=( const DWFException& )
00082         throw();
00083 
00091     _DWFCORE_API
00092     virtual const wchar_t* type() const
00093         throw() = 0;
00094 
00101     _DWFCORE_API
00102     const wchar_t* message() const
00103         throw();
00104 
00112     _DWFCORE_API
00113     const char* function() const
00114         throw();
00115 
00123     _DWFCORE_API
00124     const wchar_t* file() const
00125         throw();
00126 
00133     _DWFCORE_API
00134     unsigned int line() const
00135         throw();
00136 
00137 protected:
00138 
00149     _DWFCORE_API DWFException( const wchar_t* zMessage,
00150                                const char*    zFunction,
00151                                const wchar_t* zFile,
00152                                unsigned int   nLine )
00153         throw();
00154 
00155 private:
00156 
00157     wchar_t         _zMessage[512];
00158     const char*     _zFunction;
00159     const wchar_t*  _zFile;
00160     unsigned int    _nLine;
00161 };
00162 
00163 
00164 
00165 #define _DWFCORE_STRING_ECHO( s )           #s
00166 #define _DWFCORE_FORCE_WIDE_STRING_( s )    L ## s
00167 #define _DWFCORE_FORCE_WIDE_STRING( s )     _DWFCORE_FORCE_WIDE_STRING_( s )
00168 
00169 
00177 #define _DWFCORE_DECLARE_EXCEPTION_CLASS( this, super )                                             \
00178 class DWF##this##Exception : public super                                                           \
00179 {                                                                                                   \
00180 public:                                                                                             \
00181     _DWFCORE_API DWF##this##Exception(const wchar_t* zMessage,                                      \
00182                                       const char*    zFunction,                                     \
00183                                       const wchar_t* zFile,                                         \
00184                                       unsigned int   nLine )                                        \
00185         : super(zMessage, zFunction, zFile, nLine) {;}                                              \
00186     _DWFCORE_API virtual ~DWF##this##Exception() throw() {;}                                        \
00187     _DWFCORE_API virtual const wchar_t* type() const                                                \
00188     throw() { return _DWFCORE_FORCE_WIDE_STRING(_DWFCORE_STRING_ECHO(DWF##this##Exception)); }      \
00189 };
00190 
00196 _DWFCORE_DECLARE_EXCEPTION_CLASS( IO, DWFException )
00197 
00198 
00199 
00200 
00201 
00202 
00203 _DWFCORE_DECLARE_EXCEPTION_CLASS( Memory, DWFException )
00204 
00210 _DWFCORE_DECLARE_EXCEPTION_CLASS( Overflow, DWFException )
00211 
00217 _DWFCORE_DECLARE_EXCEPTION_CLASS( String, DWFException )
00218 
00224 _DWFCORE_DECLARE_EXCEPTION_CLASS( Unexpected, DWFException )
00225 
00231 _DWFCORE_DECLARE_EXCEPTION_CLASS( NullPointer, DWFException )
00232 
00238 _DWFCORE_DECLARE_EXCEPTION_CLASS( InvalidType, DWFException )
00239 
00245 _DWFCORE_DECLARE_EXCEPTION_CLASS( DoesNotExist, DWFException )
00246 
00252 _DWFCORE_DECLARE_EXCEPTION_CLASS( TypeMismatch, DWFException )
00253 
00259 _DWFCORE_DECLARE_EXCEPTION_CLASS( InvalidArgument, DWFException )
00260 
00266 _DWFCORE_DECLARE_EXCEPTION_CLASS( NotImplemented, DWFException )
00267 
00273 _DWFCORE_DECLARE_EXCEPTION_CLASS( IllegalState, DWFException )
00274 
00280 _DWFCORE_DECLARE_EXCEPTION_CLASS( InvalidPassword, DWFException )
00281 
00287 _DWFCORE_DECLARE_EXCEPTION_CLASS( NameCollision, DWFIllegalStateException )
00288 
00294 _DWFCORE_DECLARE_EXCEPTION_CLASS( UserCancelled, DWFException )
00295 
00304 _DWFCORE_DECLARE_EXCEPTION_CLASS( ZlibData, DWFIOException )
00305 
00315 _DWFCORE_DECLARE_EXCEPTION_CLASS( XMLDuplicateAttribute, DWFIOException )
00316 
00317 
00318 }
00319 
00323 
00324 
00325     //
00326     // prefer ANSI C99 standard macro
00327     //
00328 #ifndef    __func__
00329 #define    __func__    __FUNCTION__
00330 #endif
00331 
00332 
00333 #define _DWFCORE_BUILD_EX( ex_class, message )                      \
00334     ex_class ex( message, __func__,                                 \
00335                           _DWFCORE_FORCE_WIDE_STRING(__FILE__),     \
00336                           __LINE__ );
00337 
00338 #define _DWFCORE_THROW_EX    throw ex;
00339 
00348 #define _DWFCORE_THROW( ex_class, message )                         \
00349     _DWFCORE_BUILD_EX( ex_class, message )                          \
00350     _DWFCORE_THROW_EX
00351 
00352 #endif

Generated on Tue Jan 6 22:39:28 2009 for Autodesk DWF Core Library by  doxygen 1.4.5