home *** CD-ROM | disk | FTP | other *** search
/ Borland Programmer's Resource / Borland_Programmers_Resource_CD_1995.iso / code / kdbf / kdbfex.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-05-19  |  1.3 KB  |  55 lines

  1. // except.h
  2. #if !defined(__KDBFEX_H)
  3. #define __KDBFEX_H
  4.  
  5. #include <cstring.h>
  6.  
  7. class TXFBase : public xmsg {
  8.   public:
  9.     TXFBase(const string& msg);
  10.     TXFBase(const TXFBase& src);
  11.     virtual ~TXFBase();
  12.  
  13.     virtual TXFBase* Clone();
  14.     virtual void Throw();
  15.  
  16.     static int InstanceCount;
  17. };
  18.  
  19. class TXKdbf : public TXFBase {
  20.   public:
  21.     TXKdbf(const string& msg, DBIResult errVal = DBIERR_NONE);
  22.     TXKdbf(DBIResult errVal);
  23.    ~TXKdbf();
  24.  
  25.     TXKdbf* Clone();
  26.     void Throw();
  27.     unsigned GetErrorCode() const {return rslt;}
  28.     TXKdbf& operator =(DBIResult rslt) {Set(rslt); return *this;}
  29.     operator int() const {return rslt;}
  30.  
  31.   public:
  32.     DBIResult rslt;
  33.  
  34.   protected:
  35.     void Set(DBIResult errVal) { rslt = errVal; }
  36. };
  37.  
  38. //
  39. //
  40. #if defined(_KDBF_EXCEPTIONS)
  41.   #define TRY         try
  42.   #define THROW(x)    throw x
  43.   #define THROWX(x)   x.Throw()   // Classes derived from TXKdbf can use this
  44.   #define RETHROW     throw
  45.   #define CATCH(x)    catch x
  46. #else
  47.   #define TRY                     // try block is executed normally
  48.   #define THROW(x)    abort()     // abort on any exception
  49.   #define THROWX(x)   abort()
  50.   #define RETHROW     return lastError; // only used in catch clauses
  51.   #define CATCH(x)                // exception & code is arg to macro
  52. #endif
  53.  
  54. #endif  // __KDBFEX_H
  55.