Changeset 1755 for code/trunk/src/util
- Timestamp:
- Sep 10, 2008, 1:37:36 AM (16 years ago)
- Location:
- code/trunk
- Files:
-
- 2 deleted
- 7 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
- Property svn:mergeinfo changed
/code/branches/gui (added) merged: 1636,1638,1640-1647,1649-1654,1656,1659-1665,1670,1672-1674,1686,1688-1692,1694-1697,1704 /code/branches/input (added) merged: 1629-1630
- Property svn:mergeinfo changed
-
code/trunk/src/util/CMakeLists.txt
r1751 r1755 1 1 SET(UTIL_SRC_FILES 2 ArgReader.cc3 2 Clipboard.cc 4 3 Error.cc -
code/trunk/src/util/CRC32.h
r1751 r1755 30 30 #define _Util_CRC_H__ 31 31 32 #include "UtilPrereqs.h" 32 33 #include <iostream> 34 #include "Integers.h" 33 35 34 36 #define UTIL_CRC32POLY 0x04C11DB7 /* CRC-32 Polynom */ 35 37 36 void calcCRCBit(uint32_t &crc32, int bit);38 _UtilExport void calcCRCBit(uint32_t &crc32, int bit); 37 39 38 uint32_t calcCRC(unsigned char *data, unsigned int dataLength);40 _UtilExport uint32_t calcCRC(unsigned char *data, unsigned int dataLength); 39 41 40 42 -
code/trunk/src/util/Convert.h
r1747 r1755 643 643 }; 644 644 645 646 /////////////////////////// 647 // Static type detection // 648 /////////////////////////// 649 650 /** 651 Template class that determines whether type T converts implicitly to type U. 652 @note 653 This allows to detect type conversion at compile time. 654 From 'Modern C++ Design' (Alexandrescu 2001). 655 */ 656 template <class T, class U> 657 class StaticConversion 658 { 659 class Small { char dummy[1]; }; 660 class Big { char dummy[1024]; }; 661 static Small Test(U); 662 static Big Test(...); 663 static T MakeT(); 664 public: 665 enum { exists = sizeof(Test(MakeT())) == sizeof(Small) }; 666 }; 667 645 668 #if ORXONOX_COMPILER == ORXONOX_COMPILER_MSVC 646 669 #pragma warning(pop) -
code/trunk/src/util/OrxonoxPlatform.h
r1505 r1755 25 25 * Reto Grieder 26 26 * 27 * Original code: OgrePlatform.h, licensed under the LGPL. The code 28 * has changed quite a bit however. 29 * 27 30 */ 28 31 29 32 /** 30 33 @file 31 @brief Various constants for compiler, architecture and platform. It's a mere32 copy of the file found in the Ogre source code (OgrePlatform.h).34 @brief 35 Various constants for compiler, architecture and platform. 33 36 */ 34 37 … … 36 39 #define _OrxonoxPlatform_H__ 37 40 38 /* Initial platform/compiler-related stuff to set. 39 */ 41 /* Initial platform/compiler-related stuff to set. */ 42 40 43 #define ORXONOX_PLATFORM_WIN32 1 41 44 #define ORXONOX_PLATFORM_LINUX 2 … … 52 55 #define ORXONOX_ARCHITECTURE_64 2 53 56 54 /* Finds the compiler type and version. 55 */ 57 58 /* Finds the compiler type and version. */ 59 56 60 #if defined( _MSC_VER ) 57 61 # define ORXONOX_COMPILER ORXONOX_COMPILER_MSVC … … 73 77 #endif 74 78 79 75 80 /* See if we can use __forceinline or if we need to use __inline instead */ 76 81 #if ORXONOX_COMPILER == ORXONOX_COMPILER_MSVC … … 87 92 88 93 /* Finds the current platform */ 89 90 94 #if defined( __WIN32__ ) || defined( _WIN32 ) 91 95 # define ORXONOX_PLATFORM ORXONOX_PLATFORM_WIN32 92 93 96 #elif defined( __APPLE_CC__) 94 97 # define ORXONOX_PLATFORM ORXONOX_PLATFORM_APPLE 95 96 98 #else 97 99 # define ORXONOX_PLATFORM ORXONOX_PLATFORM_LINUX 98 100 #endif 99 101 100 102 /* Find the arch type */ 101 103 #if defined(__x86_64__) || defined(_M_X64) || defined(__powerpc64__) || defined(__alpha__) || defined(__ia64__) || defined(__s390__) || defined(__s390x__) 102 104 # define ORXONOX_ARCH_TYPE ORXONOX_ARCHITECTURE_64 … … 105 107 #endif 106 108 107 // For generating compiler warnings - should work on any compiler 108 // As a side note, if you start your message with 'Warning: ', the MSVC 109 // IDE actually does catch a warning :) 110 // FIXME: Try this on linux box. Doesn't work with msvc 111 //#define ORXONOX_QUOTE_INPLACE(x) # x 112 //#define ORXONOX_QUOTE(x) ORXONOX_QUOTE_INPLACE(x) 113 //#define ORXONOX_WARN( x ) message( __FILE__ "(" QUOTE( __LINE__ ) ") : " x "\n" ) 114 115 //---------------------------------------------------------------------------- 116 // Windows Settings 109 /* Try to define function information */ 110 #ifndef __FUNCTIONNAME__ 111 # if ORXONOX_COMPILER == ORXONOX_COMPILER_BORL 112 # define __FUNCTIONNAME__ __FUNC__ 113 # elif ORXONOX_COMPILER == ORXONOX_COMPILER_GNUC 114 # define __FUNCTIONNAME__ __PRETTY_FUNCTION__ 115 # elif ORXONOX_COMPILER == ORXONOX_COMPILER_MSVC 116 # define __FUNCTIONNAME__ __FUNCTION__ 117 # else 118 # define __FUNCTIONNAME__ 119 # endif 120 #endif 121 122 /* Determine whether we're building in debug mode */ 123 #if defined(_DEBUG) || defined(DEBUG) 124 # define ORXONOX_DEBUG_MODE 1 125 #else 126 # define ORXONOX_DEBUG_MODE 0 127 #endif 128 129 /* Define configurable floating point type */ 130 namespace orxonox 131 { 132 #ifdef ORXONOX_DOUBLE_PRECISION 133 typedef double Real; 134 #else 135 typedef float Real; 136 #endif 137 } 138 139 140 141 /*--------------------------------- 142 * Windows Settings 143 *-------------------------------*/ 117 144 #if ORXONOX_PLATFORM == ORXONOX_PLATFORM_WIN32 118 119 // Win32 compilers use _DEBUG for specifying debug builds. 120 # ifdef _DEBUG 121 # define ORXONOX_DEBUG_MODE 1 122 # else 123 # define ORXONOX_DEBUG_MODE 0 124 # endif 125 126 // Disable unicode support on MingW at the moment, poorly supported in stdlibc++ 127 // STLPORT fixes this though so allow if found 128 // MinGW C++ Toolkit supports unicode and sets the define __MINGW32_TOOLKIT_UNICODE__ in _mingw.h 145 /* Disable unicode support on MingW at the moment, poorly supported in stdlibc++ 146 * STLPORT fixes this though so allow if found 147 * MinGW C++ Toolkit supports unicode and sets the define __MINGW32_TOOLKIT_UNICODE__ in _mingw.h */ 129 148 # if defined( __MINGW32__ ) && !defined(_STLPORT_VERSION) 130 149 # include<_mingw.h> … … 137 156 # define ORXONOX_UNICODE_SUPPORT 1 138 157 # endif 139 140 158 #endif /* Platform Win32 */ 141 //---------------------------------------------------------------------------- 142 143 //---------------------------------------------------------------------------- 144 // Linux/Apple Settings 159 160 161 /*--------------------------------- 162 * Linux/Apple Settings 163 *-------------------------------*/ 145 164 #if ORXONOX_PLATFORM == ORXONOX_PLATFORM_LINUX || ORXONOX_PLATFORM == ORXONOX_PLATFORM_APPLE 146 165 147 148 // A quick define to overcome different names for the same function 166 /* A quick define to overcome different names for the same function */ 149 167 # define stricmp strcasecmp 150 168 151 // Unlike the Win32 compilers, Linux compilers seem to use DEBUG for when 152 // specifying a debug build. 153 // (??? this is wrong, on Linux debug builds aren't marked in any way unless 154 // you mark it yourself any way you like it -- zap ???) 155 # ifdef DEBUG 156 # define ORXONOX_DEBUG_MODE 1 157 # else 158 # define ORXONOX_DEBUG_MODE 0 159 # endif 160 161 /* FIXME: Check what this actually is and whether we need it or not 169 /* TODO: Check what this actually is and whether we need it or not */ 170 #if 0 162 171 # if ORXONOX_PLATFORM == ORXONOX_PLATFORM_APPLE 163 172 # define ORXONOX_PLATFORM_LIB "OrxonoxPlatform.bundle" 164 173 # else 165 / / ORXONOX_PLATFORM_LINUX174 /* ORXONOX_PLATFORM_LINUX */ 166 175 # define ORXONOX_PLATFORM_LIB "libOrxonoxPlatform.so" 167 176 # endif 168 */ 169 170 / /Always enable unicode support for the moment171 // Perhaps disable in old versions of gcc if necessary 177 #endif 178 179 /* Always enable unicode support for the moment 180 * Perhaps disable in old versions of gcc if necessary */ 172 181 # define ORXONOX_UNICODE_SUPPORT 1 173 182 174 183 #endif /* Patform Linux/Apple */ 175 184 176 //For apple, we always have a custom config.h file 185 186 /*--------------------------------- 187 * Apple Settings 188 *-------------------------------*/ 189 /* For apple, we always have a custom config.h file */ 177 190 #if ORXONOX_PLATFORM == ORXONOX_PLATFORM_APPLE 178 191 # include "config.h" 179 192 #endif 180 193 181 //---------------------------------------------------------------------------- 182 183 //---------------------------------------------------------------------------- 184 // Endian Settings 185 // check for BIG_ENDIAN config flag, set ORXONOX_ENDIAN correctly 186 #ifdef ORXONOX_CONFIG_BIG_ENDIAN 187 # define ORXONOX_ENDIAN ORXONOX_ENDIAN_BIG 188 #else 189 # define ORXONOX_ENDIAN ORXONOX_ENDIAN_LITTLE 190 #endif 191 192 //----------------------------------------------------------------------- 193 // fixed width integers 194 //----------------------------------------------------------------------- 194 195 /*--------------------------------- 196 * Visual Studio Settings 197 *-------------------------------*/ 195 198 #if ORXONOX_COMPILER == ORXONOX_COMPILER_MSVC 196 typedef __int8 int8_t; 197 typedef __int16 int16_t; 198 typedef __int32 int32_t; 199 typedef __int64 int64_t; 200 typedef unsigned __int8 uint8_t; 201 typedef unsigned __int16 uint16_t; 202 typedef unsigned __int32 uint32_t; 203 typedef unsigned __int64 uint64_t; 204 #else 205 # include "inttypes.h" 206 #endif 207 208 namespace orxonox { 209 #ifdef ORXONOX_DOUBLE_PRECISION 210 typedef double Real; 211 #else 212 typedef float Real; 213 #endif 214 } 215 216 217 #if ORXONOX_COMPILER == ORXONOX_COMPILER_MSVC 218 // Turn off warnings generated by long std templates 219 // This warns about truncation to 255 characters in debug/browse info 220 //# pragma warning (disable : 4786) 221 222 // Turn off warnings generated by long std templates 223 // This warns about truncation to 255 characters in debug/browse info 224 //# pragma warning (disable : 4503) 225 226 // disable: conversion from 'double' to 'float', possible loss of data 227 // disable: conversion from 'ogg_int64_t' to 'long', possible loss of data 228 // This has been dealt with in base_properties of the solution since the 229 // warning primarily occurs in library header files (which are mostly 230 // included before OrxonoxPlatform.h is) 231 //# pragma warning (disable : 4244) 232 233 // disable: "conversion from 'size_t' to 'unsigned int', possible loss of data 234 //# pragma warning (disable : 4267) 235 236 // disable: "truncation from 'double' to 'float' 237 //# pragma warning (disable : 4305) 238 239 // set to level 4: "<type> needs to have dll-interface to be used by clients' 240 // Happens on STL member variables which are not public therefore is ok 199 /* Turn off warnings generated by long std templates 200 * This warns about truncation to 255 characters in debug/browse info */ 201 /*# pragma warning (disable : 4786)*/ 202 203 /* Turn off warnings generated by long std templates 204 * This warns about truncation to 255 characters in debug/browse info */ 205 /*# pragma warning (disable : 4503)*/ 206 207 /* disable: conversion from 'double' to 'float', possible loss of data 208 * disable: conversion from 'ogg_int64_t' to 'long', possible loss of data 209 * This has been dealt with in base_properties of the solution since the 210 * warning primarily occurs in library header files (which are mostly 211 * included before OrxonoxPlatform.h is) */ 212 /*# pragma warning (disable : 4244)*/ 213 214 /* disable: "conversion from 'size_t' to 'unsigned int', possible loss of data */ 215 /*# pragma warning (disable : 4267)*/ 216 217 /* disable: "truncation from 'double' to 'float' */ 218 /*# pragma warning (disable : 4305)*/ 219 220 /* set to level 4: "<type> needs to have dll-interface to be used by clients' 221 * Happens on STL member variables which are not public therefore is ok */ 241 222 # pragma warning (disable : 4251) 242 223 243 / /disable: 'MultiTypeString' : multiple assignment operators specified244 // Used in MultiType and works fine so far 245 / /# pragma warning (disable : 4522)246 247 / /disable: "non dll-interface class used as base for dll-interface class"248 //Happens when deriving from Singleton because bug in compiler ignores249 // template export 250 / /# pragma warning (disable : 4275)251 252 / /disable: "C++ Exception Specification ignored"253 //This is because MSVC 6 did not implement all the C++ exception254 // specifications in the ANSI C++ draft. 255 / /# pragma warning( disable : 4290 )256 257 / /disable: "no suitable definition provided for explicit template258 //instantiation request" Occurs in VC7 for no justifiable reason on all259 // #includes of Singleton 260 / /# pragma warning( disable: 4661)261 262 / /disable: deprecation warnings when using CRT calls in VC8263 //These show up on all C runtime lib code in VC8, disable since they clutter264 //the warnings with things we may not be able to do anything about (e.g.265 //generated code from nvparse etc). I doubt very much that these calls266 // will ever be actually removed from VC anyway, it would break too much code. 267 / /# pragma warning( disable: 4996)268 269 / /disable: "conditional expression constant", always occurs on270 // ORXONOX_MUTEX_CONDITIONAL when no threading enabled 271 / /# pragma warning (disable : 201)272 273 274 / / Define the english written operators like and, or, xor224 /* disable: 'MultiTypeString' : multiple assignment operators specified 225 * Used in MultiType and works fine so far */ 226 /*# pragma warning (disable : 4522)*/ 227 228 /* disable: "non dll-interface class used as base for dll-interface class" 229 * Happens when deriving from Singleton because bug in compiler ignores 230 * template export */ 231 /*# pragma warning (disable : 4275)*/ 232 233 /* disable: "C++ Exception Specification ignored" 234 * This is because MSVC 6 did not implement all the C++ exception 235 * specifications in the ANSI C++ draft. */ 236 /*# pragma warning( disable : 4290 )*/ 237 238 /* disable: "no suitable definition provided for explicit template 239 * instantiation request" Occurs in VC7 for no justifiable reason on all 240 * #includes of Singleton */ 241 /*# pragma warning( disable: 4661)*/ 242 243 /* disable: deprecation warnings when using CRT calls in VC8 244 * These show up on all C runtime lib code in VC8, disable since they clutter 245 * the warnings with things we may not be able to do anything about (e.g. 246 * generated code from nvparse etc). I doubt very much that these calls 247 * will ever be actually removed from VC anyway, it would break too much code. */ 248 /*# pragma warning( disable: 4996)*/ 249 250 /* disable: "conditional expression constant", always occurs on 251 * ORXONOX_MUTEX_CONDITIONAL when no threading enabled */ 252 /*# pragma warning (disable : 201)*/ 253 254 255 /* Define the english written operators like and, or, xor */ 275 256 #include <iso646.h> 276 257 258 /* include visual leak detector to search for memory leaks */ 259 /* #include <vld.h> */ 260 277 261 #endif /* ORXONOX_COMPILER == ORXONOX_COMPILER_MSVC */ 278 262 279 // include visual leak detector to search for memory leaks280 //#include <vld.h>281 282 263 #endif /* _OrxonoxPlatform_H__ */ -
code/trunk/src/util/Sleep.h
r1505 r1755 28 28 29 29 /** 30 @file Sleep.h 31 @brief Macros for using sleep() and usleep() under windows 30 @file 31 @brief 32 Functions for using sleep() and usleep() under windows. 32 33 */ 33 34 34 #include "UtilPrereqs.h" 35 #ifndef _Sleep_H__ 36 #define _Sleep_H__ 37 38 #include "OrxonoxPlatform.h" 35 39 36 40 #if ORXONOX_PLATFORM == ORXONOX_PLATFORM_WIN32 37 # ifndef WIN32_LEAN_AND_MEAN 38 # define WIN32_LEAN_AND_MEAN 39 # endif 40 # include <windows.h> 41 42 #ifndef WIN32_LEAN_AND_MEAN 43 # define WIN32_LEAN_AND_MEAN 44 #endif 45 #include <windows.h> 46 41 47 inline void usleep(DWORD dwMicroseconds) 42 48 { 43 49 Sleep(dwMicroseconds / 1000); 44 50 } 51 45 52 inline void msleep(DWORD dwMilliseconds) 46 53 { 47 54 Sleep(dwMilliseconds); 48 55 } 56 49 57 inline void sleep(DWORD dwSeconds) 50 58 { 51 59 Sleep(dwSeconds * 1000); 52 60 } 53 #else 54 # include <unistd.h> 61 62 #else /* Linux/Apple */ 63 64 #include <unistd.h> 65 55 66 inline void msleep(unsigned long msec) 56 67 { 57 68 usleep(msec * 1000); 58 69 } 70 59 71 #endif 72 73 #endif /* _Sleep_H__ */ -
code/trunk/src/util/SubString.h
r1505 r1755 131 131 /** @brief Returns the i'th string from the subset of Strings @param i the i'th String */ 132 132 inline const std::string& getString(unsigned int i) const { return (*this)[i]; }; 133 /** @brief Returns all Strings as std::vector */ 134 inline const std::vector<std::string>& getAllStrings() const { return this->strings; } 133 135 /** @brief Returns true if the token is in safemode. @param i the i'th token */ 134 136 inline bool isInSafemode(unsigned int i) const { return this->bInSafemode[i]; }
Note: See TracChangeset
for help on using the changeset viewer.