📄 exception.cpp
字号:
#include "cppunit/Exception.h"namespace CppUnit {#ifdef CPPUNIT_ENABLE_SOURCELINE_DEPRECATED/*! * \deprecated Use SourceLine::isValid() instead. */const std::string Exception::UNKNOWNFILENAME = "<unknown>";/*! * \deprecated Use SourceLine::isValid() instead. */const long Exception::UNKNOWNLINENUMBER = -1;#endif/// Construct the exceptionException::Exception( const Exception &other ) : std::exception( other ){ m_message = other.m_message; m_sourceLine = other.m_sourceLine;} /*! * \deprecated Use other constructor instead. */Exception::Exception( std::string message, SourceLine sourceLine ) : m_message( message ), m_sourceLine( sourceLine ){}#ifdef CPPUNIT_ENABLE_SOURCELINE_DEPRECATED/*! * \deprecated Use other constructor instead. */Exception::Exception( std::string message, long lineNumber, std::string fileName ) : m_message( message ), m_sourceLine( fileName, lineNumber ){}#endif/// Destruct the exceptionException::~Exception () throw(){}/// Perform an assignmentException& Exception::operator =( const Exception& other ){ // Don't call superclass operator =(). VC++ STL implementation// has a bug. It calls the destructor and copy constructor of // std::exception() which reset the virtual table to std::exception.// SuperClass::operator =(other); if ( &other != this ) { m_message = other.m_message; m_sourceLine = other.m_sourceLine; } return *this; }/// Return descriptive messageconst char*Exception::what() const throw(){ return m_message.c_str (); }/// Location where the error occuredSourceLine Exception::sourceLine() const{ return m_sourceLine;}#ifdef CPPUNIT_ENABLE_SOURCELINE_DEPRECATED/// The line on which the error occurredlong Exception::lineNumber() const{ return m_sourceLine.isValid() ? m_sourceLine.lineNumber() : UNKNOWNLINENUMBER; }/// The file in which the error occurredstd::string Exception::fileName() const{ return m_sourceLine.isValid() ? m_sourceLine.fileName() : UNKNOWNFILENAME;}#endifException *Exception::clone() const{ return new Exception( *this );}bool Exception::isInstanceOf( const Type &exceptionType ) const{ return exceptionType == type();}Exception::TypeException::type(){ return Type( "CppUnit::Exception" );}} // namespace CppUnit
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -