00001 00012 /* 00013 00014 Copyright (c) 2007, Tim Burrell 00015 Licensed under the Apache License, Version 2.0 (the "License"); 00016 you may not use this file except in compliance with the License. 00017 You may obtain a copy of the License at 00018 00019 http://www.apache.org/licenses/LICENSE-2.0 00020 00021 Unless required by applicable law or agreed to in writing, software 00022 distributed under the License is distributed on an "AS IS" BASIS, 00023 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00024 See the License for the specific language governing permissions and 00025 limitations under the License. 00026 00027 */ 00028 00029 #ifndef __Exception_h 00030 #define __Exception_h 00031 00032 #if HAVE_CONFIG_H 00033 #include "config.h" 00034 #endif 00035 00036 #include <cstdlib> 00037 #include <string> 00038 00040 // Namespace 00042 00043 namespace H { 00044 00046 // Typedef, enum's 00048 00054 typedef enum { 00055 EXCEPTION_INFO, 00056 EXCEPTION_WARNING, 00057 EXCEPTION_NORMAL, 00058 EXCEPTION_FATAL 00059 } ExceptionType; 00060 00062 // Class Definition 00064 00072 class Exception : public std::exception { 00073 public: 00075 virtual const ExceptionType getExceptionType() const { return mType; }; 00076 00078 virtual const std::string & getExceptionMessage() const { return mMessage; }; 00079 00081 virtual const char * what() { return mMessage.c_str(); }; 00082 00084 virtual const char * message() { return mMessage.c_str(); }; 00085 00087 virtual operator const char* () const { return mMessage.c_str(); }; 00088 00090 Exception(const std::string & Message, ExceptionType Type = EXCEPTION_NORMAL); 00091 00093 Exception(const std::string & Message, const std::string & File, const std::string & Function, int LineNumber, ExceptionType Type = EXCEPTION_NORMAL); 00094 00096 virtual ~Exception() throw() ; 00097 00098 protected: 00099 std::string mMessage; 00100 ExceptionType mType; 00101 }; 00102 00104 00105 } 00106 00107 #endif // __Exception_h