00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 #ifndef PG_DEF_H_
00033 #define PG_DEF_H_
00034
00035
00042
00043
00044
00045 #ifndef PG_API
00046 #ifdef _MSC_VER
00047 #ifdef POGOLYN_EXPORTS
00048 #define PG_API __declspec(dllexport)
00049 #else
00050 #define PG_API __declspec(dllimport)
00051 #endif
00052 #else
00053 #define PG_API
00054 #endif
00055 #endif
00056
00057
00058 #ifdef _MSC_VER
00059 #pragma warning(disable:4251)
00060 #endif
00061
00062
00063 #undef min
00064 #undef max
00065
00066
00067 #ifndef NULL
00068 #define NULL 0
00069 #endif
00070
00071
00072 #ifdef __GNUC__
00073 typedef __SIZE_TYPE__ size_t;
00074 #endif
00075
00076
00081 namespace pgBasicType
00082 {
00083 typedef signed char s8;
00084 typedef signed short s16;
00085 typedef signed int s32;
00086
00087 typedef unsigned char u8;
00088 typedef unsigned short u16;
00089 typedef unsigned int u32;
00090
00091 typedef float r32;
00092 typedef double r64;
00093
00094 #if defined(__GNUC__)
00095 typedef signed long long s64;
00096 typedef unsigned long long u64;
00097 #elif defined(_MSC_VER)
00098 typedef signed __int64 s64;
00099 typedef unsigned __int64 u64;
00100 #else
00101 #error
00102 #endif
00103 }
00104
00105 using namespace pgBasicType;
00106
00107
00112 const u32 POGOLYN_VERSION = 80;
00113
00114
00119 class pgException
00120 {
00121 public:
00128 pgException(const char* exception, const char* file, u32 line)
00129 {
00130 m_exception = exception;
00131 m_file = file;
00132 m_line = line;
00133 }
00134
00139 const char* getException() const
00140 {
00141 return m_exception;
00142 }
00143
00148 const char* getFile() const
00149 {
00150 return m_file;
00151 }
00152
00157 u32 getLine() const
00158 {
00159 return m_line;
00160 }
00161
00162 private:
00163 const char* m_exception;
00164 const char* m_file;
00165 u32 m_line;
00166 };
00167
00168
00169 #ifdef PG_NO_THROW_EXCEPTION
00170
00171 PG_API void pgSubstituteThrow(const char* exception, const char* file, u32 line);
00172
00173 #define pgDefineException(e)
00174 #define pgTry if (true)
00175 #define pgThrow(e) pgSubstituteThrow(#e, __FILE__, __LINE__)
00176 #define pgCatch(...) if (false)
00177
00178 #else
00179
00185 #define pgDefineException(e) \
00186 class e : public pgException \
00187 { \
00188 public: \
00189 e(const char* exception, const char* file, u32 line) : pgException(exception, file, line) {} \
00190 }
00191
00192
00197 #define pgTry try
00198
00199
00205 #define pgThrow(e) throw e(#e, __FILE__, __LINE__)
00206
00207
00213 #define pgCatch(...) catch (__VA_ARGS__)
00214
00215 #endif // PG_NO_THROW_EXCEPTION
00216
00217
00218 #endif // !PG_DEF_H_