ResidualVM logo ResidualVM website - Forums - Contact us BuildBot - Doxygen - Wiki curved edge

common/util.h

Go to the documentation of this file.
00001 /* ScummVM - Graphic Adventure Engine
00002  *
00003  * ScummVM is the legal property of its developers, whose names
00004  * are too numerous to list here. Please refer to the COPYRIGHT
00005  * file distributed with this source distribution.
00006  *
00007  * This program is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU General Public License
00009  * as published by the Free Software Foundation; either version 2
00010  * of the License, or (at your option) any later version.
00011  *
00012  * This program is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU General Public License
00018  * along with this program; if not, write to the Free Software
00019  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00020  *
00021  */
00022 
00023 #ifndef COMMON_UTIL_H
00024 #define COMMON_UTIL_H
00025 
00026 #include "common/scummsys.h"
00027 #include "common/str.h"
00028 
00033 #define IS_ALIGNED(value, alignment) \
00034           ((((size_t)value) & ((alignment) - 1)) == 0)
00035 
00036 #ifdef ABS
00037 #undef ABS
00038 #endif
00039 
00040 #ifdef MIN
00041 #undef MIN
00042 #endif
00043 
00044 #ifdef MAX
00045 #undef MAX
00046 #endif
00047 
00048 template<typename T> inline T ABS(T x)      { return (x >= 0) ? x : -x; }
00049 template<typename T> inline T MIN(T a, T b) { return (a < b) ? a : b; }
00050 template<typename T> inline T MAX(T a, T b) { return (a > b) ? a : b; }
00051 template<typename T> inline T CLIP(T v, T amin, T amax)
00052         { if (v < amin) return amin; else if (v > amax) return amax; else return v; }
00053 
00057 template<typename T> inline void SWAP(T &a, T &b) { T tmp = a; a = b; b = tmp; }
00058 
00059 #ifdef ARRAYSIZE
00060 #undef ARRAYSIZE
00061 #endif
00062 
00066 #define ARRAYSIZE(x) ((int)(sizeof(x) / sizeof(x[0])))
00067 
00071 #define ARRAYEND(x) ((x) + ARRAYSIZE((x)))
00072 
00073 
00078 #if defined(__GNUC__)
00079 # define SCUMMVM_CURRENT_FUNCTION __PRETTY_FUNCTION__
00080 #elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901)
00081 #  define SCUMMVM_CURRENT_FUNCTION  __func__
00082 #elif defined(_MSC_VER)
00083 #  define SCUMMVM_CURRENT_FUNCTION __FUNCTION__
00084 #else
00085 #  define SCUMMVM_CURRENT_FUNCTION "<unknown>"
00086 #endif
00087 
00088 namespace Common {
00089 
00098 extern void hexdump(const byte * data, int len, int bytesPerLine = 16, int startOffset = 0);
00099 
00100 
00111 bool parseBool(const String &val, bool &valAsBool);
00112 
00113 
00122 bool isAlnum(int c);
00123 
00132 bool isAlpha(int c);
00133 
00142 bool isDigit(int c);
00143 
00152 bool isLower(int c);
00153 
00164 bool isSpace(int c);
00165 
00174 bool isUpper(int c);
00175 
00186 bool isPrint(int c);
00187 
00188 
00196 bool isPunct(int c);
00197 
00198 } // End of namespace Common
00199 
00200 #endif


Generated on Sat Feb 16 2019 05:01:10 for ResidualVM by doxygen 1.7.1
curved edge   curved edge