25 #include "common/scummsys.h" 40 #define IS_ALIGNED(value, alignment) \ 41 ((((size_t)value) & ((alignment) - 1)) == 0) 56 template<
typename T>
inline T
ABS(T x) {
return (x >= 0) ? x : -x; }
59 template<
typename T>
inline T
MIN(T a, T b) {
return (a < b) ? a : b; }
62 template<
typename T>
inline T
MAX(T a, T b) {
return (a > b) ? a : b; }
65 template<
typename T>
inline T
CLIP(T v, T amin, T amax)
67 #if !defined(RELEASE_BUILD) 74 if (v < amin)
return amin;
75 else if (v > amax)
return amax;
82 template<
typename T>
inline void SWAP(T &a, T &b) { T tmp = a; a = b; b = tmp; }
91 #define ARRAYSIZE(x) ((int)(sizeof(x) / sizeof(x[0]))) 96 #define ARRAYEND(x) ((x) + ARRAYSIZE((x))) 101 template<
typename T,
size_t N>
inline void ARRAYCLEAR(T (&array) [N],
const T &value = T()) {
111 #if defined(__GNUC__) 112 # define SCUMMVM_CURRENT_FUNCTION __PRETTY_FUNCTION__ 113 #elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901) 114 # define SCUMMVM_CURRENT_FUNCTION __func__ 115 #elif defined(_MSC_VER) 116 # define SCUMMVM_CURRENT_FUNCTION __FUNCTION__ 118 # define SCUMMVM_CURRENT_FUNCTION "<unknown>" 182 using remove_cv_t =
typename remove_cv<T>::type;
184 using remove_const_t =
typename remove_const<T>::type;
186 using remove_volatile_t =
typename remove_volatile<T>::type;
189 using remove_reference_t =
typename remove_reference<T>::type;
195 constexpr remove_reference_t<T> &&
move(T &&t) noexcept {
196 return static_cast<remove_reference_t<T> &&
>(t);
200 constexpr T&& forward(remove_reference_t<T> &&t) noexcept {
201 return static_cast<T &&
>(t);
205 constexpr T&& forward(remove_reference_t<T> &t) noexcept {
206 return static_cast<T &&
>(t);
212 template<
class T1,
class T2>
220 Pair(
const Pair &other) : first(other.first), second(other.second) {
226 Pair(
const T1 &first_,
const T2 &second_) : first(first_), second(second_) {
232 Pair(T1 &&first_,
const T2 &second_) : first(
Common::move(first_)), second(second_) {
235 Pair(
const T1 &first_, T2 &&second_) : first(first_), second(
Common::move(second_)) {
238 Pair &operator=(
const Pair &other) {
239 this->first = other.first;
240 this->second = other.second;
260 extern void hexdump(
const byte * data,
int len,
int bytesPerLine = 16,
int startOffset = 0);
void ARRAYCLEAR(T(&array) [N], const T &value=T())
Definition: util.h:101
bool parseBool(const String &val, bool &valAsBool)
void SWAP(T &a, T &b)
Definition: util.h:82
T CLIP(T v, T amin, T amax)
Definition: util.h:65
void hexdump(const byte *data, int len, int bytesPerLine=16, int startOffset=0)
Definition: algorithm.h:29
Common::String getHumanReadableBytes(uint64 bytes, const char *&unitsOut)
Out move(In first, In last, Out dst)
Definition: algorithm.h:109
T MIN(T a, T b)
Definition: util.h:59
T MAX(T a, T b)
Definition: util.h:62
T ABS(T x)
Definition: util.h:56