CppUnit project page FAQ CppUnit home page

Exception.h
Go to the documentation of this file.
1 #ifndef CPPUNIT_EXCEPTION_H
2 #define CPPUNIT_EXCEPTION_H
3 
4 #include <cppunit/Portability.h>
5 #include <cppunit/Message.h>
6 #include <cppunit/SourceLine.h>
7 #include <exception>
8 
9 #if CPPUNIT_NEED_DLL_DECL
10 #pragma warning( push )
11 #pragma warning( disable: 4251 ) // X needs to have dll-interface to be used by clients of class Z
12 #endif
13 
15 
16 
23 class CPPUNIT_API Exception : public std::exception
24 {
25 public:
30  Exception( const Message &message = Message(),
31  const SourceLine &sourceLine = SourceLine() );
32 
33 #ifdef CPPUNIT_ENABLE_SOURCELINE_DEPRECATED
34 
37  Exception( std::string message,
38  long lineNumber,
39  std::string fileName );
40 #endif
41 
45  Exception( const Exception &other );
46 
48  virtual ~Exception() throw();
49 
51  Exception &operator =( const Exception &other );
52 
54  const char *what() const throw();
55 
57  SourceLine sourceLine() const;
58 
60  Message message() const;
61 
63  void setMessage( const Message &message );
64 
65 #ifdef CPPUNIT_ENABLE_SOURCELINE_DEPRECATED
66 
67  long lineNumber() const;
68 
70  std::string fileName() const;
71 
72  static const std::string UNKNOWNFILENAME;
73  static const long UNKNOWNLINENUMBER;
74 #endif
75 
77  virtual Exception *clone() const;
78 
79 protected:
80  // VC++ does not recognize call to parent class when prefixed
81  // with a namespace. This is a workaround.
82  typedef std::exception SuperClass;
83 
86  std::string m_whatMessage;
87 };
88 
89 
91 
92 #if CPPUNIT_NEED_DLL_DECL
93 #pragma warning(pop)
94 #endif
95 
96 #endif // CPPUNIT_EXCEPTION_H
97 

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