CppUnit project page FAQ CppUnit home page

Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | Namespace Members | Compound Members | File Members | Related Pages

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/SourceLine.h>
00006 #include <exception>
00007 #include <string>
00008 
00009 namespace CppUnit {
00010 
00017 class CPPUNIT_API Exception : public std::exception
00018 {
00019 public:
00020 
00021     class Type
00022     {
00023     public:
00024         Type( std::string type ) : m_type ( type ) {}
00025 
00026         bool operator ==( const Type &other ) const
00027         {
00028             return m_type == other.m_type;
00029         }
00030     private:
00031         const std::string m_type;
00032     };
00033 
00034 
00035     Exception( std::string  message = "", 
00036                SourceLine sourceLine = SourceLine() );
00037 
00038 #ifdef CPPUNIT_ENABLE_SOURCELINE_DEPRECATED
00039     Exception( std::string  message, 
00040                long lineNumber, 
00041                std::string fileName );
00042 #endif
00043 
00044     Exception (const Exception& other);
00045 
00046     virtual ~Exception () throw();
00047 
00048     Exception& operator= (const Exception& other);
00049 
00050     const char *what() const throw ();
00051 
00052     SourceLine sourceLine() const;
00053 
00054 #ifdef CPPUNIT_ENABLE_SOURCELINE_DEPRECATED
00055     long lineNumber() const;
00056     std::string fileName() const;
00057 
00058     static const std::string UNKNOWNFILENAME;
00059     static const long UNKNOWNLINENUMBER;
00060 #endif
00061 
00062     virtual Exception *clone() const;
00063     
00064     virtual bool isInstanceOf( const Type &type ) const;
00065 
00066     static Type type();
00067 
00068 private:
00069     // VC++ does not recognize call to parent class when prefixed
00070     // with a namespace. This is a workaround.
00071     typedef std::exception SuperClass;
00072 
00073     std::string m_message;
00074     SourceLine m_sourceLine;
00075 };
00076 
00077 
00078 } // namespace CppUnit
00079 
00080 #endif // CPPUNIT_EXCEPTION_H
00081 

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