types_nl.h
Go to the documentation of this file.00001
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034 #ifndef NL_TYPES_H
00035 #define NL_TYPES_H
00036
00037
00038 #define nl_time time
00039 #define nl_mktime mktime
00040 #define nl_gmtime gmtime
00041 #define nl_localtime localtime
00042 #define nl_difftime difftime
00043
00044
00045 #ifdef HAVE_NELCONFIG_H
00046 # include "nelconfig.h"
00047 #endif // HAVE_NELCONFIG_H
00048
00049 #ifdef FINAL_VERSION
00050
00051 # if FINAL_VERSION != 1 && FINAL_VERSION != 0
00052 # error "Bad value for FINAL_VERSION, it must be 0 or 1"
00053 # endif
00054 #else
00055
00056
00057 # define FINAL_VERSION 0
00058 #endif // FINAL_VERSION
00059
00060
00061
00062 #ifdef WIN32
00063 # define NL_OS_WINDOWS
00064 # define NL_LITTLE_ENDIAN
00065 # define NL_CPU_INTEL
00066 # ifndef _WIN32_WINNT
00067 # define _WIN32_WINNT 0x0500 // Minimal OS = Windows 2000 (NeL is not supported on Windows 95/98)
00068 # endif
00069 # if _MSC_VER >= 1500
00070 # define NL_COMP_VC9
00071 # include <string>
00072 # if defined(_HAS_TR1) && (_HAS_TR1 + 0) // VC9 TR1 feature pack
00073 # define NL_ISO_STDTR1_AVAILABLE
00074 # define NL_ISO_STDTR1_HEADER(header) <header>
00075 # endif
00076 # elif _MSC_VER >= 1400
00077 # define NL_COMP_VC8
00078 # undef nl_time
00079 # define nl_time _time32 // use the old 32 bit time function
00080 # undef nl_mktime
00081 # define nl_mktime _mktime32 // use the old 32 bit time function
00082 # undef nl_gmtime
00083 # define nl_gmtime _gmtime32 // use the old 32 bit time function
00084 # undef nl_localtime
00085 # define nl_localtime _localtime32 // use the old 32 bit time function
00086 # undef nl_difftime
00087 # define nl_difftime _difftime32 // use the old 32 bit time function
00088 # elif _MSC_VER >= 1310
00089 # define NL_COMP_VC71
00090 # elif _MSC_VER >= 1300
00091 # define NL_COMP_VC7
00092 # elif _MSC_VER >= 1200
00093 # define NL_COMP_VC6
00094 # define NL_COMP_NEED_PARAM_ON_METHOD
00095 # endif
00096 # ifdef _DEBUG
00097 # define NL_DEBUG
00098 # elif defined (NDEBUG)
00099 # define NL_RELEASE
00100 # else
00101 # error "Don't know the compilation mode"
00102 # endif
00103 # ifdef _WIN64
00104 # define NL_OS_WIN64
00105 # ifndef NL_NO_ASM
00106
00107 # define NL_NO_ASM
00108 # endif
00109 # endif
00110
00111 # define NOMINMAX
00112 #else
00113 # ifdef __APPLE__
00114 # define NL_OS_MAC
00115 # ifdef __BIG_ENDIAN__
00116 # define NL_BIG_ENDIAN
00117 # elif defined(__LITTLE_ENDIAN__)
00118 # define NL_LITTLE_ENDIAN
00119 # else
00120 # error "Cannot detect the endianness of this Mac"
00121 # endif
00122 # else
00123 # ifdef WORDS_BIGENDIAN
00124 # define NL_BIG_ENDIAN
00125 # else
00126 # define NL_LITTLE_ENDIAN
00127 # endif
00128 # endif
00129
00130 # define NL_OS_UNIX
00131 # define NL_COMP_GCC
00132 #endif
00133
00134
00135
00136
00137
00138
00139
00140 #if defined(NL_OS_WINDOWS) || (defined(__GNUC__) && ((__GNUC__ < 3) || (__GNUC__ == 3 && __GNUC_MINOR__ <= 3)))
00141 # define NL_ISO_SYNTAX 0
00142 # define NL_ISO_TEMPLATE_SPEC
00143 #else
00144 # define NL_ISO_SYNTAX 1
00145 # define NL_ISO_TEMPLATE_SPEC template <>
00146 #endif
00147
00148
00149 #if defined(__GNUC__) && ((__GNUC__ > 4) || (__GNUC__ == 4) && (__GNUC_MINOR__ > 1))
00150 # define NL_ISO_STDTR1_AVAILABLE
00151 # define NL_ISO_STDTR1_HEADER(header) <tr1/header>
00152 #endif
00153
00154
00155 #ifdef NL_OS_WINDOWS
00156 # pragma warning (disable : 4503) // STL: Decorated name length exceeded, name was truncated
00157 # pragma warning (disable : 4786) // STL: too long identifier
00158 # pragma warning (disable : 4290) // throw() not implemented warning
00159 # pragma warning (disable : 4250) // inherits via dominance (informational warning).
00160 # pragma warning (disable : 4390) // don't warn in empty block "if(exp) ;"
00161 # pragma warning (disable : 4996) // 'vsnprintf': This function or variable may be unsafe. Consider using vsnprintf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
00162
00163 # if defined(NL_COMP_VC8) || defined(NL_COMP_VC9)
00164 # pragma warning (disable : 4005) // don't warn on redefinitions caused by xp platform sdk
00165 # endif // NL_COMP_VC8 || NL_COMP_VC9
00166 #endif // NL_OS_WINDOWS
00167
00168
00169
00170
00171 #include <string>
00172 #include <exception>
00173
00174
00175
00176 #ifndef NL_NO_ASM // If NL_NO_ASM is externely defined, don't override it.
00177 # ifndef NL_CPU_INTEL // If not on an Intel compatible plateforme (BeOS, 0x86 Linux, Windows)
00178 # define NL_NO_ASM // Don't use extern ASM. Full C++ code.
00179 # endif // NL_CPU_INTEL
00180 #endif // NL_NO_ASM
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192 #undef NL_NO_DEBUG
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203
00263 #ifdef NL_OS_WINDOWS
00264
00265 typedef signed __int8 sint8;
00266 typedef unsigned __int8 uint8;
00267 typedef signed __int16 sint16;
00268 typedef unsigned __int16 uint16;
00269 typedef signed __int32 sint32;
00270 typedef unsigned __int32 uint32;
00271 typedef signed __int64 sint64;
00272 typedef unsigned __int64 uint64;
00273
00274 typedef int sint;
00275 typedef unsigned int uint;
00276
00277 #define NL_I64 "I64"
00278
00279 #ifndef NL_ISO_STDTR1_AVAILABLE
00280 # include <hash_map>
00281 # include <hash_set>
00282 # if defined(NL_COMP_VC7) || defined(NL_COMP_VC71) || defined(NL_COMP_VC8) || defined(NL_COMP_VC9) // VC7 through 9
00283 # define CHashMap stdext::hash_map
00284 # define CHashSet stdext::hash_set
00285 # define CHashMultiMap stdext::hash_multimap
00286 # else // MSVC6
00287 # define CHashMap ::std::hash_map
00288 # define CHashSet ::std::hash_set
00289 # define CHashMultiMap ::std::hash_multimap
00290 # endif
00291 #endif // NL_ISO_STDTR1_AVAILABLE
00292
00293 #elif defined (NL_OS_UNIX)
00294
00295 #include <sys/types.h>
00296 #include <stdint.h>
00297 #include <climits>
00298
00299 typedef int8_t sint8;
00300 typedef u_int8_t uint8;
00301 typedef int16_t sint16;
00302 typedef u_int16_t uint16;
00303 typedef int32_t sint32;
00304 typedef u_int32_t uint32;
00305 typedef long long int sint64;
00306 typedef unsigned long long int uint64;
00307
00308 typedef int sint;
00309 typedef unsigned int uint;
00310
00311 #define NL_I64 "ll"
00312
00313 #if defined(NL_COMP_GCC) && !defined(NL_ISO_STDTR1_AVAILABLE) // GCC4
00314 # include <ext/hash_map>
00315 # include <ext/hash_set>
00316 # define CHashMap ::__gnu_cxx::hash_map
00317 # define CHashSet ::__gnu_cxx::hash_set
00318 # define CHashMultiMap ::__gnu_cxx::hash_multimap
00319
00320 namespace __gnu_cxx {
00321
00322 template<> struct hash<std::string>
00323 {
00324 size_t operator()(const std::string &s) const
00325 {
00326 return __stl_hash_string(s.c_str());
00327 }
00328 };
00329
00330 template<> struct hash<uint64>
00331 {
00332 size_t operator()(const uint64 x) const
00333 {
00334 return x;
00335 }
00336 };
00337
00338 }
00339
00340 #endif // NL_COMP_GCC && !NL_ISO_STDTR1_AVAILABLE
00341
00342 #endif // NL_OS_UNIX
00343
00344
00345 #ifdef NL_ISO_STDTR1_AVAILABLE
00346 # include NL_ISO_STDTR1_HEADER(unordered_map)
00347 # include NL_ISO_STDTR1_HEADER(unordered_set)
00348 # define CHashMap std::tr1::unordered_map
00349 # define CHashSet std::tr1::unordered_set
00350 # define CHashMultiMap std::tr1::unordered_multimap
00351 #endif
00352
00357 typedef uint16 ucchar;
00358
00359
00360
00361 #ifdef NL_OS_WINDOWS
00362 # if defined(NL_COMP_VC8) || defined(NL_COMP_VC9)
00363 # define INT64_CONSTANT(c) (c##LL)
00364 # define SINT64_CONSTANT(c) (c##LL)
00365 # define UINT64_CONSTANT(c) (c##LL)
00366 # else
00367 # define INT64_CONSTANT(c) (c)
00368 # define SINT64_CONSTANT(c) (c)
00369 # define UINT64_CONSTANT(c) (c)
00370 # endif
00371 #else
00372 # define INT64_CONSTANT(c) (c##LL)
00373 # define SINT64_CONSTANT(c) (c##LL)
00374 # define UINT64_CONSTANT(c) (c##ULL)
00375 #endif
00376
00377
00378 #ifdef NL_COMP_NEED_PARAM_ON_METHOD
00379 # define NL_TMPL_PARAM_ON_METHOD_1(p1) <p1>
00380 # define NL_TMPL_PARAM_ON_METHOD_2(p1, p2) <p1, p2>
00381 #else
00382 # define NL_TMPL_PARAM_ON_METHOD_1(p1)
00383 # define NL_TMPL_PARAM_ON_METHOD_2(p1, p2)
00384 #endif
00385
00386 #if !defined(MAX_PATH) && !defined(NL_OS_WINDOWS)
00387 # define MAX_PATH 255
00388 #endif
00389
00390 #ifdef NL_DEBUG
00391 const std::string nlMode("NL_DEBUG");
00392 #else
00393 const std::string nlMode("NL_RELEASE");
00394 #endif
00395
00396
00397 #if defined (NL_DEBUG) && defined (NL_RELEASE)
00398 # error "NeL cannot be configured for debug and release in the same time"
00399 #endif
00400 #if !defined (NL_DEBUG) && !defined (NL_RELEASE)
00401 # error "NeL must be configured for debug or release"
00402 #endif
00403 #ifdef NL_RELEASE_DEBUG
00404 # error "NL_RELEASE_DEBUG doesn't exist anymore, please remove it"
00405 #endif
00406 #ifdef NL_DEBUG_FAST
00407 # error "NL_DEBUG_FAST doesn't exist anymore, please remove it"
00408 #endif
00409
00410 #endif // NL_TYPES_H