common_types.h

Go to the documentation of this file.
00001 /*
00002  *  Copyright (C) 2000-2001  The Exult Team
00003  *
00004  *  This program is free software; you can redistribute it and/or modify
00005  *  it under the terms of the GNU General Public License as published by
00006  *  the Free Software Foundation; either version 2 of the License, or
00007  *  (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 COMMON_TYPES_H
00020 #define COMMON_TYPES_H
00021 
00022 #ifdef HAVE_CONFIG_H
00023 #  include <config.h>
00024 #endif
00025 
00026 #include <string>
00027 
00028 #ifdef BEOS
00029 // BeOS headers already define these types
00030 #include <be/support/SupportDefs.h>
00031 typedef int8 sint8;
00032 typedef int16 sint16;
00033 typedef int32 sint32;
00034 
00035 #else
00036 
00037 #ifndef EX_TYPE_INT8
00038 #  define EX_TYPE_INT8 char /* guaranteed by ISO */
00039 #endif
00040 
00041 #ifndef EX_TYPE_INT16
00042 #  if (SIZEOF_SHORT == 2)
00043 #    define EX_TYPE_INT16 short
00044 #  elif (SIZEOF_INT == 2)
00045 #    define EX_TYPE_INT16 int
00046 #  else
00047 #    error "Please make sure a 16 bit type is provided by exult_types.h"
00048 #  endif
00049 #endif /* !EX_TYPE_INT16 */
00050 
00051 
00052 #ifndef EX_TYPE_INT32
00053 #  if (SIZEOF_INT == 4)
00054 #    define EX_TYPE_INT32 int
00055 #  elif (SIZEOF_LONG == 4)
00056 #    define EX_TYPE_INT32 long
00057 #  elif (SIZEOF_LONG_LONG == 4)
00058 #    define EX_TYPE_INT32 long long
00059 #  else
00060 #    error "Please make sure a 32 bit type is provided by exult_types.h"
00061 #  endif
00062 #endif /* !EX_TYPE_INT32 */
00063 
00064 
00065 typedef unsigned EX_TYPE_INT8 uint8;
00066 typedef unsigned EX_TYPE_INT16  uint16;
00067 typedef unsigned EX_TYPE_INT32  uint32;
00068 
00069 typedef signed EX_TYPE_INT8   sint8;
00070 typedef signed EX_TYPE_INT16  sint16;
00071 typedef signed EX_TYPE_INT32  sint32;
00072 
00073 
00074 #endif //BeOS
00075 
00076 /*
00077  * Empty string
00078  */
00079 extern const std::string c_empty_string;
00080 
00081 
00082 // Debug
00083 #ifdef DEBUG
00084 #  define COUT(x)   do { std::cout << x << std::endl; std::cout.flush(); } while (0)
00085 #  define CERR(x)   do { std::cerr << x << std::endl; std::cerr.flush(); } while (0)
00086 #else
00087 #  define COUT(x)   do { } while(0)
00088 #  define CERR(x)   do { } while(0)
00089 #endif
00090 
00091 // Two very useful macros that one should use instead of pure delete; they will additionally
00092 // set the old object pointer to 0, thus helping prevent double deletes (not that "delete 0"
00093 // is a no-op.
00094 #define FORGET_OBJECT(x) do { delete x; x = 0; } while(0)
00095 #define FORGET_ARRAY(x) do { delete [] x; x = 0; } while(0)
00096 
00097 
00098 #endif
00099 

Generated on Mon Jul 9 14:42:47 2007 for ExultEngine by  doxygen 1.5.1