Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Examples

Exception.hpp

00001 #if !defined (__EXCEPTION_HPP) 00002 #define __EXCEPTION_HPP 00003 00004 /* 00005 CoreLinux++ 00006 Copyright (C) 1999 CoreLinux Consortium 00007 00008 The CoreLinux++ Library is free software; you can redistribute it and/or 00009 modify it under the terms of the GNU Library General Public License as 00010 published by the Free Software Foundation; either version 2 of the 00011 License, or (at your option) any later version. 00012 00013 The CoreLinux++ Library Library is distributed in the hope that it will 00014 be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00016 Library General Public License for more details. 00017 00018 You should have received a copy of the GNU Library General Public 00019 License along with the GNU C Library; see the file COPYING.LIB. If not, 00020 write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 00021 Boston, MA 02111-1307, USA. 00022 */ 00023 00024 #if !defined IN_COMMON_HPP 00025 #error except.hpp is included by common.hpp only. 00026 #endif 00027 00028 #include <string> 00029 // 00030 // Base exception class 00031 // 00032 00033 00034 namespace corelinux 00035 { 00036 00037 00038 DECLARE_CLASS( Exception ); 00039 00040 // Define a reference to line number 00041 00042 DECLARE_TYPE( Dword, LineNum ); 00043 00044 00051 class Exception 00052 { 00053 00054 public: 00055 00056 00058 00059 enum Severity 00060 { 00061 CONTINUABLE = 1, 00062 THREADFATAL, 00063 PROCESSFATAL, 00064 THREADTERMINATE, 00065 PROCESSTERMINATE 00066 }; 00067 00068 00078 Exception 00079 ( 00080 CharCptr why, 00081 CharCptr file, 00082 LineNum line, 00083 Severity severity = Exception::CONTINUABLE, 00084 bool outOfMemory = false 00085 ); 00086 00092 Exception( ExceptionCref crOther ); 00093 00095 00096 virtual ~Exception(void); 00097 00098 // 00099 // Operator overloads 00100 // 00101 00108 ExceptionRef operator = ( ExceptionCref otherRef ); 00109 00116 bool operator==( ExceptionCref otherRef ); 00117 00118 // 00119 // Accessor methods 00120 // 00121 00128 const std::string & getFile( void ) const; 00129 00136 LineNumCref getLine( void ) const; 00137 00143 const std::string & getWhy( void ) const; 00144 00150 const Severity & getSeverity( void ) const; 00151 00157 const std::string & getUnwind( void ) const; 00158 00164 bool isOutOfMemory( void ) const 00165 { return theOutOfMemoryFlag;} 00166 00167 // 00168 // Mutator methods 00169 // 00170 00177 void addUnwindInfo( CharCptr unwindInfo ); 00178 00180 00181 void setThreadFatalSeverity( void ); 00182 00184 00185 void setProcessFatalSeverity( void ); 00186 00193 void setThreadTerminateSeverity( void ); 00194 00200 void setProcessTerminateSeverity( void ); 00201 00202 protected: 00203 00209 Exception( void ); 00210 00215 Exception 00216 ( 00217 CharCptr file, 00218 LineNum line, 00219 Severity severity = Exception::CONTINUABLE, 00220 bool outOfMemory = false 00221 ); 00222 00224 00225 void setWhy( const std::string & ); 00226 00228 00229 void setWhy( CharCptr ); 00230 00231 private: 00232 00233 00234 private: 00235 00236 // Reason why the exception is being thrown. 00237 00238 std::string theReason; 00239 00240 // File that threw the exception. 00241 00242 std::string theFile; 00243 00244 // Severity of the exception. 00245 00246 Severity theSeverity; 00247 00248 // Unwind information added as exception is unwound from 00249 // stack. 00250 00251 std::string theUnwindInfo; 00252 00253 // Line number in the file throwing the exception. 00254 00255 LineNum theLine; 00256 00257 // Flag that indicates if there is a low memory situation. 00258 00259 bool theOutOfMemoryFlag; 00260 }; 00261 00262 } 00263 00264 00265 #endif // !defined __EXCEPTION_HPP 00266 00267 /* 00268 Common rcs information do not modify 00269 $Author: frankc $ 00270 $Revision: 1.2 $ 00271 $Date: 2000/07/28 01:37:09 $ 00272 $Locker: $ 00273 */ 00274 00275

This is the CoreLinux++ reference manual
Provided by The CoreLinux Consortium