Errors.h

Go to the documentation of this file.
00001 /*
00002 Copyright (C) 2002 The Pentagram Team
00003 
00004 This program is free software; you can redistribute it and/or
00005 modify it under the terms of the GNU General Public License
00006 as published by the Free Software Foundation; either version 2
00007 of the License, or (at your option) any later version.
00008 
00009 This program is distributed in the hope that it will be useful,
00010 but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012 GNU General Public License for more details.
00013 
00014 You should have received a copy of the GNU General Public License
00015 along with this program; if not, write to the Free Software
00016 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00017 */
00018 
00019 #ifndef ERRORS_H_INCLUDED
00020 #define ERRORS_H_INCLUDED
00021 
00022 
00024 //                            //
00025 // Pentagram Base Error Codes //
00026 //                            //
00028 
00029 // Base Error Code type
00030 struct ECode
00031 {
00032         sint32  error;
00033 
00034         ECode() : error(0) { }
00035         ECode(sint32 _e) : error(_e) { }
00036 
00037         bool failed() const { return error != 0; }
00038         bool succeded() const { return error == 0; }
00039 
00040         ECode &operator = (sint32 &_e)
00041         {
00042                 error = _e;
00043                 return (*this);
00044         }
00045 
00046         ECode &operator = (ECode &_e)
00047         {
00048                 error = _e.error;
00049                 return (*this);
00050         }
00051 
00052         bool operator != (sint32 &_e)
00053         {
00054                 return error != _e;
00055         }
00056 
00057         friend bool operator != (sint32 &_e, ECode &_e2)
00058         {
00059                 return _e2.error != _e;
00060         }
00061 
00062         bool operator == (sint32 &_e)
00063         {
00064                 return error == _e;
00065         }
00066 
00067         friend bool operator == (sint32 &_e, ECode &_e2)
00068         {
00069                 return _e2.error == _e;
00070         }
00071 };
00072 
00073 
00074 //
00075 // Helper Macros
00076 //
00077 
00078 // Checks to see if a return code is an error
00079 #define P_FAILED(e) ((e)!=0)
00080 
00081 // Checks to see if an error code indicates success
00082 #define P_SUCCEDED(e) ((e)==0)
00083 
00084 
00085 // 
00086 // Error Code Bases
00087 //
00088 
00089 // Kernel Error Code Base
00090 #define KERNEL_ERROR_BASE                                       (-0x10000)
00091 
00092 // Usecode Error Code Base
00093 #define UESCODE_ERROR_BASE                                      (-0x20000)
00094 
00095 // FileSystem Error Code Base
00096 #define FILESYS_ERROR_BASE                                      (-0x30000)
00097 
00098 // Graphics Error Code Base
00099 #define GRAPHICS_ERROR_BASE                                     (-0x40000)
00100 
00101 // Gump Error Code Base
00102 #define GUMPS_ERROR_BASE                                        (-0x50000)
00103 
00104 // Convert Error Code Base
00105 #define CONVERT_ERROR_BASE                                      (-0x60000)
00106 
00107 // World Error Code Base
00108 #define WORLD_ERROR_BASE                                        (-0x70000)
00109 
00110 // Audio Error Code Base
00111 #define AUDIO_ERROR_BASE                                        (-0x80000)
00112 
00113 // Misc Error Code Base
00114 #define MISC_ERROR_BASE                                         (-0x90000)
00115 
00116 
00117 // 
00118 // Basic Error Codes
00119 //
00120 
00121 // No Error
00122 #define P_NO_ERROR                                                      (0)
00123 
00124 // Generic Error
00125 #define P_GENERIC_ERROR                                         (-1)
00126 
00127 // Undefined Error
00128 #define P_UNDEFINED_ERROR                                       (-2)
00129 
00130 // Memory Allocation Error
00131 #define P_MEMORY_ALLOC_ERRO                                     (-3)
00132 
00133 
00134 #endif // ERRORS_H_INCLUDED
00135 

Generated on Fri Jul 27 22:27:14 2007 for pentagram by  doxygen 1.4.7