MyGUI
3.2.0
|
00001 00006 /* 00007 This file is part of MyGUI. 00008 00009 MyGUI is free software: you can redistribute it and/or modify 00010 it under the terms of the GNU Lesser General Public License as published by 00011 the Free Software Foundation, either version 3 of the License, or 00012 (at your option) any later version. 00013 00014 MyGUI is distributed in the hope that it will be useful, 00015 but WITHOUT ANY WARRANTY; without even the implied warranty of 00016 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00017 GNU Lesser General Public License for more details. 00018 00019 You should have received a copy of the GNU Lesser General Public License 00020 along with MyGUI. If not, see <http://www.gnu.org/licenses/>. 00021 */ 00022 #include "MyGUI_Precompiled.h" 00023 #include "MyGUI_Exception.h" 00024 #include "MyGUI_StringUtility.h" 00025 00026 namespace MyGUI 00027 { 00028 00029 Exception::Exception(const std::string& _description, const std::string& _source, const char* _file, long _line ) : 00030 mDescription(_description), 00031 mSource(_source), 00032 mFile(_file), 00033 mLine(_line) 00034 { 00035 } 00036 00037 Exception::Exception(const Exception& _rhs) : 00038 mDescription(_rhs.mDescription), 00039 mSource(_rhs.mSource), 00040 mFile(_rhs.mFile), 00041 mLine(_rhs.mLine), 00042 mFullDesc(_rhs.mFullDesc) 00043 { 00044 } 00045 00046 Exception::~Exception() throw() 00047 { 00048 } 00049 00050 Exception& Exception::operator = (const Exception& _rhs) 00051 { 00052 mDescription = _rhs.mDescription; 00053 mSource = _rhs.mSource; 00054 mFile = _rhs.mFile; 00055 mLine = _rhs.mLine; 00056 mFullDesc = _rhs.mFullDesc; 00057 return *this; 00058 } 00059 00060 const std::string& Exception::getFullDescription() const 00061 { 00062 if (mFullDesc.empty()) 00063 { 00064 if ( mLine > 0 ) 00065 { 00066 mFullDesc = utility::toString("MyGUI EXCEPTION : ", mDescription, " in ", mSource, " at ", mFile, " (line ", mLine, ")"); 00067 } 00068 else 00069 { 00070 mFullDesc = utility::toString("MyGUI EXCEPTION : ", mDescription, " in ", mSource); 00071 } 00072 } 00073 00074 return mFullDesc; 00075 } 00076 00077 const std::string& Exception::getSource() const 00078 { 00079 return mSource; 00080 } 00081 00082 const std::string& Exception::getFile() const 00083 { 00084 return mFile; 00085 } 00086 00087 long Exception::getLine() const 00088 { 00089 return mLine; 00090 } 00091 00092 const std::string& Exception::getDescription() const 00093 { 00094 return mDescription; 00095 } 00096 00097 // Override std::exception::what 00098 const char* Exception::what() const throw() 00099 { 00100 return getFullDescription().c_str(); 00101 } 00102 00103 } // namespace MyGUI