home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c083 / 19.ddi / OWLINC.PAK / EXCEPT.H < prev    next >
Encoding:
C/C++ Source or Header  |  1993-12-02  |  2.6 KB  |  89 lines

  1. //----------------------------------------------------------------------------
  2. // ObjectWindows - (C) Copyright 1993 by Borland International
  3. //   owl\include\except.h
  4. //   OWL base exception class definition
  5. //----------------------------------------------------------------------------
  6. #if !defined(__OWL_EXCEPT_H)
  7. #define __OWL_EXCEPT_H
  8.  
  9. #if !defined(__OWL_OWLDEFS_H)
  10.   #include <owl\owldefs.h>
  11. #endif
  12. #if !defined(__EXCEPT_H)
  13.   #include <except.h>
  14. #endif
  15. #include "owl\except.rh"
  16.  
  17. class _OWLCLASS TModule;     
  18.  
  19. extern TModule* Module;
  20.  
  21. const int MAX_RSRC_ERROR_STRING = 255;
  22.  
  23. int _OWLFUNC
  24. HandleGlobalException(xmsg& x, char* caption, char* canResume=0);
  25.  
  26. class _OWLCLASS_RTL TXOwl : public xmsg {
  27.   public:
  28.     TXOwl(const string& msg) : xmsg(msg), ResId(0) {}
  29.     TXOwl(unsigned resId, TModule* module = ::Module);
  30.     virtual ~TXOwl() {}
  31.     virtual TXOwl* Clone();
  32.     virtual void Throw();
  33.     virtual int Unhandled(TModule* app, unsigned promptResId);
  34.     static string ResourceIdToString(BOOL *found, unsigned resId,
  35.                                      TModule* module = ::Module);
  36.     unsigned ResId;
  37. };
  38.  
  39. class _OWLCLASS_RTL TXCompatibility : public TXOwl {
  40.   public:
  41.     TXCompatibility(int statusCode);
  42.     TXCompatibility(const TXCompatibility& src);
  43.     TXOwl* Clone();
  44.     void   Throw();
  45.     int    Unhandled(TModule* app, unsigned promptResId);
  46.     static string MapStatusCodeToString(int statusCode);
  47.  
  48.     int Status;
  49. };
  50.  
  51. class _OWLCLASS_RTL TXOutOfMemory : public TXOwl {
  52.   public:
  53.     TXOutOfMemory();
  54.     TXOwl* Clone();
  55.     void   Throw();
  56. };
  57.  
  58. class _OWLCLASS TStatus {
  59.   public:
  60.     TStatus() {StatusCode = 0;}
  61.     TStatus& operator =(int statusCode) {Set(statusCode); return *this;}
  62.     operator int() const {return StatusCode;}
  63.  
  64.   private:
  65.     void Set(int statusCode);
  66.     int  StatusCode;
  67. };
  68.  
  69. //
  70. // Macros that control actual exception handling code used. Defining
  71. // NO_CPP_EXCEPTIONS will disable the use of C++ exceptions, otherwise
  72. // standard C++ exception handling code will be used.
  73. //
  74. #if defined(NO_CPP_EXCEPTIONS)
  75.   #define TRY                     // try block is executed normally
  76.   #define THROW(x)    abort()     // abort on any exception
  77.   #define THROWX(x)   abort()
  78.   #define RETHROW                 // only used in catch clauses, no code needed
  79.   #define CATCH(x)                // exception & code is arg to macro
  80. #else
  81.   #define TRY         try
  82.   #define THROW(x)    throw x
  83.   #define THROWX(x)   x.Throw()   // Classes derived from TXOwl can use this
  84.   #define RETHROW     throw
  85.   #define CATCH(x)    catch x
  86. #endif
  87.  
  88. #endif  // __OWL_EXCEPT_H
  89.