1 /* "CodeWorker": a scripting language for parsing and generating text. 2 3 Copyright (C) 1996-1997, 1999-2002 C�dric Lemaire 4 5 This library is free software; you can redistribute it and/or 6 modify it under the terms of the GNU Lesser General Public 7 License as published by the Free Software Foundation; either 8 version 2.1 of the License, or (at your option) any later version. 9 10 This library is distributed in the hope that it will be useful, 11 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 Lesser General Public License for more details. 14 15 You should have received a copy of the GNU Lesser General Public 16 License along with this library; if not, write to the Free Software 17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 19 To contact the author: codeworker@free.fr 20 */ 21 22 #ifndef _UtlException_h_ 23 #define _UtlException_h_ 24 25 #include <exception> 26 #include <string> 27 #include <iostream> 28 29 namespace CodeWorker { 30 31 #ifndef THROW_UTLEXCEPTION 32 #define THROW_UTLEXCEPTION throw UtlException 33 #endif 34 35 #ifndef THROW_UTLEXCEPTION2 36 #define THROW_UTLEXCEPTION2 throw UtlException 37 #endif 38 39 #ifndef THROW_UTLEXCEPTION_INTERFACE 40 #define THROW_UTLEXCEPTION_INTERFACE throw UtlException 41 #endif 42 43 #ifndef THROW_UTLEXCEPTION_STATIC 44 #define THROW_UTLEXCEPTION_STATIC throw UtlException 45 #endif 46 47 class ScpStream; 48 49 class UtlException : public std::exception { 50 private: 51 std::string _sTraceStack; 52 std::string _sMessage; 53 bool _bFinalMessage; 54 55 public: 56 UtlException(const UtlException& exception); 57 UtlException(std::istream& stream, const std::string& sMessage); 58 UtlException(std::istream& stream, const char* sMessage); 59 UtlException(std::istream& stream, const std::string& sTraceStack, const std::string& sMessage); 60 UtlException(const ScpStream& stream, const std::string& sMessage); 61 UtlException(const ScpStream& stream, const char* sMessage); 62 UtlException(const ScpStream& stream, const std::string& sTraceStack, const std::string& sMessage); 63 UtlException(const std::string& sMessage); 64 UtlException(const char* sMessage); 65 UtlException(const std::string& sTraceStack, const std::string& sMessage, bool bFinalMessage = false); 66 virtual ~UtlException() throw(); 67 getMessage()68 inline const std::string& getMessage() const { return _sMessage; } getTraceStack()69 inline const std::string& getTraceStack() const { return _sTraceStack; } isFinalMessage()70 inline bool isFinalMessage() const { return _bFinalMessage; } 71 virtual const char* what() const throw(); 72 73 private: 74 UtlException(); 75 UtlException& operator = (const UtlException& exception); 76 }; 77 78 79 class UtlExitException : public std::exception { 80 private: 81 int _iCode; 82 83 public: UtlExitException(int iCode)84 UtlExitException(int iCode) : _iCode(iCode) {} 85 getCode()86 inline int getCode() const { return _iCode; } setCode(int iCode)87 inline void setCode(int iCode) { _iCode = iCode; } 88 }; 89 } 90 91 #endif 92