ScummVM
util.h File Reference
#include "common/scummsys.h"
#include "common/str.h"
Include dependency graph for util.h:

Go to the source code of this file.

Namespaces

 Common
 Internal interface to the QuickTime audio decoder.
 

Macros

#define IS_ALIGNED(value, alignment)   ((((size_t)value) & ((alignment) - 1)) == 0)
 Check whether a given pointer is aligned correctly. More...
 
#define ARRAYSIZE(x)   ((int)(sizeof(x) / sizeof(x[0])))
 Macro which determines the number of entries in a fixed size array. More...
 
#define ARRAYEND(x)   ((x) + ARRAYSIZE((x)))
 Compute a pointer to one past the last element of an array. More...
 
#define SCUMMVM_CURRENT_FUNCTION   "<unknown>"
 This macro evaluates to the current function's name on compilers supporting this. More...
 

Functions

template<typename T >
ABS (T x)
 
template<typename T >
MIN (T a, T b)
 
template<typename T >
MAX (T a, T b)
 
template<typename T >
CLIP (T v, T amin, T amax)
 
template<typename T >
void SWAP (T &a, T &b)
 Template method which swaps the vaulues of its two parameters. More...
 
void Common::hexdump (const byte *data, int len, int bytesPerLine=16, int startOffset=0)
 Print a hexdump of the data passed in. More...
 
bool Common::parseBool (const String &val, bool &valAsBool)
 Parse a string for a boolean value. More...
 
bool Common::isAlnum (int c)
 Test whether the given character is alphanumeric (a-z, A-Z, 0-9). More...
 
bool Common::isAlpha (int c)
 Test whether the given character is an alphabetic letter (a-z, A-Z). More...
 
bool Common::isDigit (int c)
 Test whether the given character is a decimal-digit (0-9). More...
 
bool Common::isXDigit (int c)
 Test whether the given character is a hwzadecimal-digit (0-9 or A-F). More...
 
bool Common::isLower (int c)
 Test whether the given character is a lower-case letter (a-z). More...
 
bool Common::isSpace (int c)
 Test whether the given character is a white-space. More...
 
bool Common::isUpper (int c)
 Test whether the given character is an upper-case letter (A-Z). More...
 
bool Common::isPrint (int c)
 Test whether the given character is printable. More...
 
bool Common::isPunct (int c)
 Test whether the given character is a punctuation character, (i.e. More...
 
bool Common::isCntrl (int c)
 Test whether the given character is a control character. More...
 
bool Common::isGraph (int c)
 Test whether the given character has a graphical representation. More...
 
Common::String Common::getHumanReadableBytes (uint64 bytes, Common::String &unitsOut)
 Represent bytes size of a file as a number with floating point and largest suitable units. More...
 

Macro Definition Documentation

◆ ARRAYEND

#define ARRAYEND (   x)    ((x) + ARRAYSIZE((x)))

Compute a pointer to one past the last element of an array.

Definition at line 71 of file util.h.

◆ ARRAYSIZE

#define ARRAYSIZE (   x)    ((int)(sizeof(x) / sizeof(x[0])))

Macro which determines the number of entries in a fixed size array.

Definition at line 66 of file util.h.

◆ IS_ALIGNED

#define IS_ALIGNED (   value,
  alignment 
)    ((((size_t)value) & ((alignment) - 1)) == 0)

Check whether a given pointer is aligned correctly.

Note that 'alignment' must be a power of two!

Definition at line 33 of file util.h.

◆ SCUMMVM_CURRENT_FUNCTION

#define SCUMMVM_CURRENT_FUNCTION   "<unknown>"

This macro evaluates to the current function's name on compilers supporting this.

Definition at line 85 of file util.h.

Function Documentation

◆ ABS()

template<typename T >
T ABS ( x)
inline

Definition at line 48 of file util.h.

◆ CLIP()

template<typename T >
T CLIP ( v,
amin,
amax 
)
inline

Definition at line 51 of file util.h.

◆ MAX()

template<typename T >
T MAX ( a,
b 
)
inline

Definition at line 50 of file util.h.

◆ MIN()

template<typename T >
T MIN ( a,
b 
)
inline

Definition at line 49 of file util.h.

◆ SWAP()

template<typename T >
void SWAP ( T &  a,
T &  b 
)
inline

Template method which swaps the vaulues of its two parameters.

Definition at line 57 of file util.h.