rtxCppException.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2003-2008 Objective Systems, Inc.
00003  *
00004  * This software is furnished under a license and may be used and copied
00005  * only in accordance with the terms of such license and with the
00006  * inclusion of the above copyright notice. This software or any other
00007  * copies thereof may not be provided or otherwise made available to any
00008  * other person. No title to and ownership of the software is hereby
00009  * transferred.
00010  *
00011  * The information in this software is subject to change without notice
00012  * and should not be construed as a commitment by Objective Systems, Inc.
00013  *
00014  * PROPRIETARY NOTICE
00015  *
00016  * This software is an unpublished work subject to a confidentiality agreement
00017  * and is protected by copyright and trade secret law.  Unauthorized copying,
00018  * redistribution or other use of this work is prohibited.
00019  *
00020  * The above notice of copyright on this source code product does not indicate
00021  * any actual or intended publication of such source code.
00022  *
00023  *****************************************************************************/
00028 #ifndef _RTXCPPEXCEPTION_H_
00029 #define _RTXCPPEXCEPTION_H_
00030 
00031 #include "rtxsrc/rtxCommon.h"
00032 #include "rtxsrc/OSRTContext.h"
00033 
00034 #ifndef _NO_EXCEPTIONS
00035 #define OSTRY try
00036 #define OSRTLTHROW1(stat) throw OSRTLException(stat)
00037 #define OSRTLTHROW2(ctxt,stat) throw OSRTLException(ctxt,stat)
00038 #define OSTHROW(ex) throw (ex)
00039 #define OSCATCH(exType,ex,body) catch (exType ex) { body; }
00040 
00041 #define OSSAXTHROW throw OSSAXException ()
00042 
00043 #define OSSAXTHROWSTR(ctxt,str) \
00044 throw OSSAXException (ctxt,str,RTERR_XMLPARSE,(const OSUTF8CHAR*)__FILE__, __LINE__)
00045 
00046 #define OSSAXTHROWSTATUS(ctxt,stat) \
00047 throw OSSAXException (ctxt,LOG_RTERR(ctxt->getPtr(),stat),(const OSUTF8CHAR*)__FILE__, __LINE__)
00048 
00049 #else 
00050 #define OSTRY
00051 #define OSRTLTHROW1(stat) do { \
00052 fprintf (stderr, "Fatal Error in %s at %i, stat = %i\n", __FILE__, __LINE__, stat); \
00053 exit (-1); \
00054 } while(0)
00055 #define OSRTLTHROW2(ctxt,stat) do { \
00056 rtxErrPrint (ctxt); \
00057 fprintf (stderr, "Fatal Error in %s at %i, stat = %i\n", __FILE__, __LINE__, stat); \
00058 exit (-1); \
00059 } while(0)
00060 
00061 #define OSTHROW(ex) do { \
00062 fprintf (stderr, "Fatal Error in %s at %i\n", __FILE__, __LINE__); \
00063 exit (-1); \
00064 } while (0)
00065 #define OSCATCH(exType,ex,body)
00066 
00067 #define OSSAXTHROW { \
00068 fprintf (stderr, "Fatal Error, OSSAXException is thrown, in %s at %i\n", \
00069 __FILE__, __LINE__); \
00070 exit (-1); \
00071 }
00072 #define OSSAXTHROWSTR(ctxt,str) { \
00073 fprintf (stderr, "Fatal Error, OSSAXException(%s) is thrown, in %s at %i\n", \
00074 str, __FILE__, __LINE__); \
00075 exit (-1); \
00076 }
00077 
00078 #define OSSAXTHROWSTATUS(ctxt,stat) { \
00079 fprintf (stderr, "Fatal Error, OSSAXException(status = %i) is thrown, in %s at %i\n", \
00080 stat, __FILE__, __LINE__); \
00081 exit (-1); \
00082 }
00083 #endif
00084 
00088 class EXTRTCLASS OSRTLException {
00089  protected:
00090    OSRTCtxtPtr mpContext;
00091 
00096    int mStatus;
00097 
00098    inline OSRTLException () : mStatus(0) {}
00099 
00100  public:
00107    inline OSRTLException (int stat) : mStatus(stat) {}
00108 
00116    inline OSRTLException (OSRTContext* pContext, int stat) : 
00117       mpContext (pContext), mStatus(stat) {}
00118 
00124    inline OSRTLException (const OSRTLException& o) : 
00125       mpContext (o.mpContext), mStatus(o.mStatus) {}
00126 
00131    inline ~OSRTLException () {}
00132 
00136    inline int getStatus () const { return (mStatus); }
00137 
00141    inline void printErrorInfo () {}
00142 } ;
00143 
00147 class EXTRTCLASS OSStreamException : public OSRTLException {
00148  public:
00150    inline OSStreamException (int stat) : OSRTLException(stat) {}
00151 
00153    inline OSStreamException (OSRTContext* pContext, int stat) : 
00154       OSRTLException(pContext, stat) {}
00155 
00157    inline OSStreamException (const OSStreamException& o) : 
00158       OSRTLException(o) {}
00159 } ;
00160 
00161 class EXTRTCLASS OSSAXException : public OSRTLException
00162 {
00163  public:
00167    inline OSSAXException() {}
00168 
00174    inline OSSAXException(OSRTContext* pContext, const OSUTF8CHAR* const msg) {}
00175 
00186    inline OSSAXException(OSRTContext* pContext, const OSUTF8CHAR* const msg, 
00187       int stat_, const OSUTF8CHAR* const file_, int line_) {}
00188 
00198    inline OSSAXException(OSRTContext* pContext, int stat_, 
00199                   const OSUTF8CHAR* file_, int line_) {}
00200 
00206    inline OSSAXException(const OSSAXException& toCopy) : 
00207       OSRTLException (toCopy) {}
00208 
00210    inline ~OSSAXException() {}
00211 
00212    inline const OSUTF8CHAR* getMessage() { return (const OSUTF8CHAR*)""; }
00213 
00214    inline const OSUTF8CHAR* getSrcFileName () { return (const OSUTF8CHAR*)""; }
00215    inline int getSrcLineNum() { return -1; }
00216 
00217    inline void printErrorInfo () {}
00218 
00219 protected :
00220    const OSUTF8CHAR* mpMsg;
00221    const OSUTF8CHAR* mpFile;
00222    int               line;
00223 };
00224 
00225 #endif