Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | Namespace Members | Compound Members | File Members | Related Pages | Examples

pexception.h

Go to the documentation of this file.
00001 /*
00002  *   P::Classes - Portable C++ Application Framework
00003  *   Copyright (C) 2000-2003  Christian Prochnow <cproch@seculogix.de>
00004  *
00005  *   This library is free software; you can redistribute it and/or
00006  *   modify it under the terms of the GNU Lesser General Public
00007  *   License as published by the Free Software Foundation; either
00008  *   version 2 of the License, or (at your option) any later version.
00009  *
00010  *   This library is distributed in the hope that it will be useful,
00011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013  *   Lesser General Public License for more details.
00014  *
00015  *   You should have received a copy of the GNU Lesser General Public
00016  *   License along with this library; if not, write to the Free Software
00017  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00018  */
00019 
00020 #ifndef _pexception_h_
00021 #define _pexception_h_
00022 
00023 #include <pclasses/pexport.h>
00024 #include <pclasses/psourceinfo.h>
00025 #include <string>
00026 
00027 namespace P {
00028 
00030 
00038 class PCORE_EXPORT BaseError {
00039   public:
00041 
00046     inline BaseError(const char* _what, const SourceInfo& _si) throw()
00047       : m_what(_what), m_sourceInfo(_si) {}
00048 
00050     inline virtual ~BaseError() throw() {}
00051 
00053 
00057     inline const char* what() const throw()
00058     { return m_what; }
00059 
00061 
00065     inline virtual BaseError* clone() const
00066     { return new BaseError(*this); }
00067 
00069 
00074     inline const SourceInfo& sourceInfo() const throw()
00075     { return m_sourceInfo; }
00076 
00078     BaseError& operator=(const BaseError& e);
00079 
00080   private:
00081     const char* m_what;
00082     SourceInfo  m_sourceInfo;
00083 };
00084 
00086 
00093 class PCORE_EXPORT LogicError: public BaseError {
00094   public:
00095     inline LogicError(const char* _what, const SourceInfo& _si) throw()
00096       : BaseError(_what,_si) {}
00097 
00098     inline BaseError* clone() const
00099     { return new LogicError(*this); }
00100 };
00101 
00103 
00107 class PCORE_EXPORT RuntimeError: public BaseError {
00108   public:
00109     inline RuntimeError(const char* _what, const SourceInfo& _si) throw()
00110       : BaseError(_what,_si) {}
00111 
00112     inline BaseError* clone() const
00113     { return new RuntimeError(*this); }
00114 };
00115 
00117 /*class InvalidArgument: public LogicError {
00118   public:
00119     inline InvalidArgument(const SourceInfo& _si) throw()
00120       : LogicError("Invalid argument",_si) {}
00121 };
00122 
00124 class NullPointerError: public LogicError {
00125   public:
00126     inline NullPointerError(const SourceInfo& _si) throw()
00127       : LogicError("Unexpected NULL-pointer",_si) {}
00128 };
00129 */
00130 
00132 
00136 class PCORE_EXPORT OutOfRangeError: public LogicError {
00137   public:
00138     inline OutOfRangeError(const SourceInfo& _si) throw()
00139       : LogicError("Out of range",_si) {}
00140 
00141     inline BaseError* clone() const
00142     { return new OutOfRangeError(*this); }
00143 };
00144 
00146 
00150 class PCORE_EXPORT OverflowError: public RuntimeError {
00151   public:
00152     inline OverflowError(const SourceInfo& _si) throw()
00153       : RuntimeError("Overflow",_si) {}
00154 
00155     inline BaseError* clone() const
00156     { return new OverflowError(*this); }
00157 };
00158 
00160 
00166 class PCORE_EXPORT SystemError: public RuntimeError {
00167   public:
00168     typedef long oserr_t;
00169 
00170     inline SystemError(oserr_t errnum, const char* _what, const SourceInfo& _si) throw()
00171       : RuntimeError(_what,_si), m_errnum(errnum) {}
00172 
00173     inline BaseError* clone() const
00174     { return new SystemError(*this); }
00175 
00177 
00181     inline oserr_t errnum() const throw()
00182     { return m_errnum; }
00183 
00185 
00190     std::string text() const throw();
00191 
00192   private:
00193     oserr_t m_errnum;
00194 };
00195 
00197 
00201 class PCORE_EXPORT SyncError: public SystemError {
00202   public:
00203     inline SyncError(oserr_t errnum, const char* _what, const SourceInfo& _si) throw()
00204       : SystemError(errnum, _what, _si) {}
00205 
00206     inline BaseError* clone() const
00207     { return new SyncError(*this); }
00208 
00209 };
00210 
00212 
00216 class PCORE_EXPORT IOError: public SystemError {
00217   public:
00218     inline IOError(oserr_t errnum, const char* _what, const SourceInfo& _si) throw()
00219       : SystemError(errnum, _what, _si) {}
00220 
00221     inline BaseError* clone() const
00222     { return new IOError(*this); }
00223 
00224 };
00225 
00226 }
00227 
00228 #endif

Generated on Fri Mar 12 21:08:31 2004 for P::Classes by doxygen 1.3.3