00001 //----------------------------------------------------------------------------------- 00002 // 00003 // Pro-Vocation Light Engine (PVLE) 00004 // Copyright (C) 2007-2009 Sukender, KinoX & Buzib 00005 // For more information, contact us : sukender@free.fr 00006 // 00007 // This program is free software; you can redistribute it and/or modify 00008 // it under the terms of the GNU General Public License as published by 00009 // the Free Software Foundation; either version 3 of the License, or 00010 // (at your option) any later version. 00011 // 00012 // For any use that is not compatible with the terms of the GNU 00013 // General Public License, please contact the authors for alternative 00014 // licensing options. 00015 // 00016 // This program is distributed in the hope that it will be useful, 00017 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00018 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00019 // GNU General Public License for more details. 00020 // 00021 // You should have received a copy of the GNU General Public License along 00022 // with this program; if not, write to the Free Software Foundation, Inc., 00023 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 00024 // 00025 //----------------------------------------------------------------------------------- 00026 00027 #ifndef UTIL_H 00028 #define UTIL_H 00029 00033 00034 typedef unsigned long ULONG; 00035 typedef unsigned int UINT; 00036 typedef unsigned short USHORT; 00037 typedef unsigned char UCHAR; 00038 00039 #include <PVLE/Export.h> 00040 00041 #ifdef _DEBUG 00042 PVLE_EXPORT void NOP_function(); 00043 #define NOP ((void)(NOP_function(), 0)) 00044 00045 // Other definition of NOP : Ugly but faster. 00046 //extern int _NoP_VaRiAbLe_; 00047 //#define NOP ((void)(_NoP_VaRiAbLe_=0)) ///< A "No-operation" macro, used to put a breakpoint in debug. 00048 #else 00049 #define NOP ((void)0) 00050 #endif 00051 00052 00054 template<typename TNum1, typename TNum2> 00055 inline TNum1 copySign(TNum1 number, TNum2 sign) { return ( (sign<0) != (number<0) ) ? -number : number; } 00056 00058 template <class T1, class T2> 00059 struct TrivialPair { T1 first; T2 second; }; 00060 00061 00062 00063 //#ifdef WIN32 00064 // #ifndef WIN32_LEAN_AND_MEAN 00065 // #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers 00066 // #endif 00067 // #include <windows.h> 00068 // //#include <shellapi.h> 00069 //#endif 00070 00071 //#ifdef LINUX 00072 // #define stricmp(a, b) strcasecmp(a, b) 00073 //#endif 00074 00075 #ifdef WIN32 00076 # if defined(_MSC_VER) && (_MSC_VER>=1400) // VC8 00077 # define setenv(a, b) _putenv_s(a, b) // <stdlib.h> 00078 # else 00079 # define setenv(a, b) _putenv((std::string(a) + "=" + std::string(b)).c_str()) // Workaround for VC <8 00080 # endif 00081 #endif 00082 00083 00085 #define format_str(fmtString, args) ::boost::str(::boost::format(fmtString) % args) 00086 00087 00088 // Always useful and very lightweight includes: 00089 #include <PVLE/Util/TracedException.h> 00090 #include <PVLE/Util/Assert.h> 00091 #include <boost/foreach.hpp> // This include is less lightweight but soooooooo useful that it should be everywhere! 00092 00093 #endif // UTIL_H