CppUnit project page FAQ CppUnit home page

Exception.h
Go to the documentation of this file.
00001 #ifndef CPPUNIT_EXCEPTION_H
00002 #define CPPUNIT_EXCEPTION_H
00003 
00004 #include <cppunit/Portability.h>
00005 #include <cppunit/Message.h>
00006 #include <cppunit/SourceLine.h>
00007 #include <exception>
00008 
00009 #if CPPUNIT_NEED_DLL_DECL
00010 #pragma warning( push )
00011 #pragma warning( disable: 4251 )  // X needs to have dll-interface to be used by clients of class Z
00012 #endif 
00013 
00014 CPPUNIT_NS_BEGIN
00015 
00016 
00023 class CPPUNIT_API Exception : public std::exception
00024 {
00025 public:
00030   Exception( const Message &message = Message(), 
00031              const SourceLine &sourceLine = SourceLine() );
00032 
00033 #ifdef CPPUNIT_ENABLE_SOURCELINE_DEPRECATED
00034 
00037   Exception( std::string  message, 
00038              long lineNumber, 
00039              std::string fileName );
00040 #endif
00041 
00045   Exception( const Exception &other );
00046 
00048   virtual ~Exception() throw();
00049 
00051   Exception &operator =( const Exception &other );
00052 
00054   const char *what() const throw();
00055 
00057   SourceLine sourceLine() const;
00058 
00060   Message message() const;
00061 
00063   void setMessage( const Message &message );
00064 
00065 #ifdef CPPUNIT_ENABLE_SOURCELINE_DEPRECATED
00066 
00067   long lineNumber() const;
00068 
00070   std::string fileName() const;
00071 
00072   static const std::string UNKNOWNFILENAME;
00073   static const long UNKNOWNLINENUMBER;
00074 #endif
00075 
00077   virtual Exception *clone() const;
00078 
00079 protected:
00080   // VC++ does not recognize call to parent class when prefixed
00081   // with a namespace. This is a workaround.
00082   typedef std::exception SuperClass;
00083 
00084   Message m_message;
00085   SourceLine m_sourceLine;
00086   std::string m_whatMessage;
00087 };
00088 
00089 
00090 CPPUNIT_NS_END
00091 
00092 #if CPPUNIT_NEED_DLL_DECL
00093 #pragma warning(pop)
00094 #endif
00095 
00096 #endif // CPPUNIT_EXCEPTION_H
00097 

SourceForge Logo hosts this site. Send comments to:
CppUnit Developers