Main Page | Namespace List | Class Hierarchy | Class List | File List | Class Members | File Members

exception.h

Go to the documentation of this file.
00001 
00002 // Name:        wx/exception.h
00003 // Purpose:     
00004 // Author:      Joe Yates
00005 // Created:     2004-11-17
00006 // Copyright:   (c) Joe Yates
00007 // License:     BSD license (see the file 'LICENSE.txt')
00009 
00010 #ifndef __wx_exception_h__
00011 #define __wx_exception_h__
00012 
00013 #include <wx/wxprec.h>
00014 #ifndef WX_PRECOMP
00015   #include "wx/wx.h"
00016 #endif
00017 
00018 namespace wx
00019 {
00020 
00021 #ifdef _MSC_VER
00022 // See MSDN ID: Q119394
00023 #define WorkaroundVa_start(ap,v) \
00024   { \
00025   int var= _INTSIZEOF(v); \
00026   __asm lea eax,v \
00027   __asm add eax,var \
00028   __asm mov ap,eax \
00029   }
00030 #endif // def _MSC_VER
00031 
00032 class Exception
00033   {
00034   // friends, classes, enums and types
00035 
00036   // Constructors/destructors
00037   public:
00038     Exception() :
00039       m_sError(wxT("")),
00040       m_szFile(NULL),
00041       m_nLine(-1)
00042       {
00043       }
00044 
00045     Exception(const Exception& e)
00046       {
00047       m_sError = e.m_sError;
00048       m_szFile = e.m_szFile;
00049       m_nLine = e.m_nLine;
00050       }
00051 
00052     Exception(const wxString& sError, ...) :
00053       m_szFile(NULL),
00054       m_nLine(-1)
00055       {
00056       va_list argptr;
00057 #ifdef _MSC_VER
00058       WorkaroundVa_start(argptr, sError);
00059 #else
00060       va_start(argptr, sError);
00061 #endif // def _MSC_VER
00062       m_sError.PrintfV(sError, argptr);
00063       va_end(argptr);
00064       }
00065 
00066     Exception(const char * szFile, int nLine, const wxString& sError, ...) :
00067       m_szFile(szFile),
00068       m_nLine(nLine)
00069       {
00070       va_list argptr;
00071 #ifdef _MSC_VER
00072       WorkaroundVa_start(argptr, sError);
00073 #else
00074       va_start(argptr, sError);
00075 #endif // def _MSC_VER
00076       m_sError.PrintfV(sError, argptr);
00077       va_end(argptr);
00078       }
00079 
00080     Exception(const Exception& e, const wxString& sError, ...)
00081       {
00082       va_list argptr;
00083 #ifdef _MSC_VER
00084       WorkaroundVa_start(argptr, sError);
00085 #else
00086       va_start(argptr, sError);
00087 #endif // def _MSC_VER
00088       m_sError.PrintfV(sError, argptr);
00089       va_end(argptr);
00090       
00091       m_sError << wxT("\n") + e.GetString();
00092       }
00093 
00094     virtual Exception::~Exception()
00095       {}
00096 
00097     void PrintfV(const wxString& sError, va_list argptr)
00098       {
00099       m_sError.PrintfV(sError, argptr);
00100       }
00101 
00102   // Operators
00103   public:
00104     virtual operator wxString()
00105       { return GetString(); }
00106     virtual const char * GetFile()
00107       { return m_szFile; }
00108     virtual const int GetLine()
00109       { return m_nLine; }
00110 
00111   // Methods
00112   public:
00113     const wxString& GetString() const
00114       {
00115       return m_sError;
00116       }
00117 
00118   // Members
00119   protected:
00120     wxString      m_sError;
00121     const char *  m_szFile;
00122     int           m_nLine;
00123   };
00124 
00125 } // namespace wx
00126 
00127 #endif // ndef __wx_exception_h__

Generated on Wed Jan 25 08:13:08 2006 for Sherpa wxWidgets Classes by doxygen 1.3.6