00001 /// \file CATResult.h 00002 /// \brief CAT Result definitions and utilities 00003 /// \ingroup CAT 00004 /// 00005 /// Copyright (c) 2007-2008 by Michael Ellison. 00006 /// See COPYING.txt for the \ref gaslicense License (MIT License). 00007 /// 00008 // $Author: mikeellison $ 00009 // $Date: 2008-01-12 11:38:12 -0600 (Sat, 12 Jan 2008) $ 00010 // $Revision: $ 00011 // $NoKeywords: $ 00012 00013 #ifndef _CATResult_H_ 00014 #define _CATResult_H_ 00015 00016 #include "CATTypes.h" 00017 /// General 32-bit result code for use in the CAT library. 00018 /// High-bit set indicates error. 0 is success. Others are status codes, 00019 /// but treated as successful by the CATSUCCEEDED macro. 00020 /// 00021 /// We may want to retype this as a class later for an richer error handling 00022 /// system. 00023 typedef CATUInt32 CATResult; 00024 00025 #define CATFAILED(x) ( ((x) & 0x80000000) != 0 ) ///< Macro, returns true if result fails 00026 #define CATSUCCEEDED(x) ( ((x) & 0x80000000) == 0 ) ///< Macro, returns true if result succeeds 00027 00028 // For now, we're just using raw error codes. Eventually, we'll probably want a richer 00029 // error/string handling class. These macros should make the transition a bit more friendly if 00030 // we start using them now, then implement the additional features later. 00031 // 00032 // For example, CATRESULTFILE() might later be used to call an object's constructor to create 00033 // a CATRESULT() object containing the result, the filename, and the file/line of the source 00034 // that created it. 00035 00036 #define CATRESULT(x) (x) 00037 #define CATRESULTFILE(x,filename) (x) 00038 #define CATRESULTFILEDESC(x,filename,desc) (x) 00039 #define CATRESULTDESC(x,desc) (x) 00040 00041 00042 /// \ingroup CAT 00043 /// \todo 00044 /// Eventually, the CATResult codes need to be broken out into tables 00045 /// that are generated, with the associated strings loaded at runtime based 00046 /// on language. 00047 /// 00048 /// Enumeration of error and status codes to be used as CATResult's. 00049 enum 00050 { 00051 CAT_SUCCESS = 0, ///< Success 00052 //------------------------------------------------------------------------ 00053 // Status codes 00054 CAT_STATUS = 0x60008000, ///< Start of non-error statuses 00055 CAT_STAT_CORE_LAST = 0x60008FFF, ///< Last of status codes for lib 00056 CAT_STAT_APP = 0x60009000, ///< First App status code 00057 CAT_STAT_APP_LAST = 0x60009FFF, ///< Last reserved App status code 00058 00059 //------------------------------------------------------------------------ 00060 00061 00062 //------------------------------------------------------------------------ 00063 // String IDs (non-status related) 00064 CAT_STRING = 0x6000C000, ///< Start of string ids 00065 CAT_STR_CORE_LAST = 0x6000CFFF, ///< Last of allocated strings in core 00066 CAT_STR_APP = 0x6000D000, ///< First App string code 00067 CAT_STR_APP_LAST = 0x6000DFFF, ///< Last reserved app string code 00068 00069 //------------------------------------------------------------------------ 00070 00071 00072 //------------------------------------------------------------------------ 00073 // Error codes 00074 CAT_ERROR = 0xE0008000, ///< Start of error codes 00075 CAT_ERR_CORE_LAST = 0xE0008FFF, ///< Last in core errors 00076 CAT_ERR_APP = 0xE0009000, ///< First App error code 00077 CAT_ERR_APP_LAST = 0xE0009FFF, ///< Last App error code 00078 00079 //------------------------------------------------------------------------ 00080 }; 00081 00082 00083 00084 #endif // _CATResult_H_