25#include "common/scummsys.h"
27#include "common/type_traits.h"
44#define IS_ALIGNED(value, alignment) \
45 ((((size_t)value) & ((alignment) - 1)) == 0)
60template<
typename T>
inline T
ABS(T x) {
return (x >= 0) ? x : -x; }
63template<
typename T>
inline T
MIN(T a, T b) {
return (a < b) ? a : b; }
66template<
typename T>
inline T
MAX(T a, T b) {
return (a > b) ? a : b; }
69template<
typename T>
inline T
CLIP(T v, T amin, T amax)
71#if !defined(RELEASE_BUILD)
78 if (v < amin)
return amin;
79 else if (v > amax)
return amax;
86template<
typename T>
inline void SWAP(T &a, T &b);
89static inline uint32 ROTATE_LEFT_32(
const uint32 x,
const uint32 r) {
90 return (x >> (32 - r)) | (x << r);
94static inline uint32 ROTATE_RIGHT_32(
const uint32 x,
const uint32 r) {
95 return (x << (32 - r)) | (x >> r);
98#if !defined(_MSC_VER) || _MSC_VER >= 1910
100template<
typename... A>
constexpr size_t NUMARGS(A&&...) {
return sizeof...(A); }
103using int_c_array =
int[];
104#define NUMARGS(...) (sizeof(int_c_array{__VA_ARGS__})/sizeof(int))
114#define ARRAYSIZE(x) ((int)(sizeof(x) / sizeof(x[0])))
119#define ARRAYEND(x) ((x) + ARRAYSIZE((x)))
124template<
typename T,
size_t N>
inline void ARRAYCLEAR(T (&array) [N],
const T &value = T()) {
135# define SCUMMVM_CURRENT_FUNCTION __PRETTY_FUNCTION__
136#elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901)
137# define SCUMMVM_CURRENT_FUNCTION __func__
138#elif defined(_MSC_VER)
139# define SCUMMVM_CURRENT_FUNCTION __FUNCTION__
141# define SCUMMVM_CURRENT_FUNCTION "<unknown>"
160constexpr remove_reference_t<T> &&
move(T &&t)
noexcept {
161 return static_cast<remove_reference_t<T> &&
>(t);
165constexpr T&& forward(remove_reference_t<T> &&t)
noexcept {
166 return static_cast<T &&
>(t);
170constexpr T&& forward(remove_reference_t<T> &t)
noexcept {
171 return static_cast<T &&
>(t);
177template<
class T1,
class T2>
185 constexpr Pair(
const Pair &other) : first(other.first), second(other.second) {
191 constexpr Pair(
const T1 &first_,
const T2 &second_) : first(first_), second(second_) {
197 constexpr Pair(T1 &&first_,
const T2 &second_) : first(
Common::move(first_)), second(second_) {
200 constexpr Pair(
const T1 &first_, T2 &&second_) : first(first_), second(
Common::move(second_)) {
203 Pair &operator=(
const Pair &other) {
204 this->first = other.first;
205 this->second = other.second;
225extern void hexdump(
const byte * data,
int len,
int bytesPerLine = 16,
int startOffset = 0);
447 static void swap(T &a, T &b) {
456 static void swap(T &a, T &b) {
Out move(In first, In last, Out dst)
Definition: algorithm.h:109
T CLIP(T v, T amin, T amax)
Definition: util.h:69
constexpr size_t NUMARGS(A &&...)
Definition: util.h:100
Common::String getHumanReadableBytes(uint64 bytes, const char *&unitsOut)
T ABS(T x)
Definition: util.h:60
void SWAP(T &a, T &b)
Definition: util.h:467
T MIN(T a, T b)
Definition: util.h:63
bool parseBool(const String &val, bool &valAsBool)
void ARRAYCLEAR(T(&array)[N], const T &value=T())
Definition: util.h:124
T MAX(T a, T b)
Definition: util.h:66
void hexdump(const byte *data, int len, int bytesPerLine=16, int startOffset=0)
TimeDate int64ToTimeDate(int64 integer)
int64_t dateTimeToInt64(const TimeDate &timeDate)
Common::String formatTime(int64 integer)
Definition: algorithm.h:29
Definition: type_traits.h:149