Contains helper macros and functions. More...
#include <string>#include <cctype>#include <stdint.h>Go to the source code of this file.
Macros | |
| #define | HELPERS_H |
| #define | ARRAYLENGTH(aa) ( sizeof( aa ) / sizeof( ( aa )[ 0 ] ) ) |
Calculates the number of elements in the array aa by dividing the size of aa by the size of each element. | |
| #define | STDCALL __stdcall |
| #define | ALIGN(aa) __declspec( align( aa ) ) |
Functions | |
| template<typename t_Type > | |
| t_Type | Square (t_Type const &value) |
| Returns the square of its argument. | |
| template<typename t_Type > | |
| t_Type | Cube (t_Type const &value) |
| Returns the cube of its argument. | |
| std::string | CollapseWhitespace (std::string const &source, char const space= ' ') |
| Removes leading/trailing whitespace, and collapses internal whitespace. | |
| uint8_t | CountBits (uint8_t number) |
| Returns the number of set bits in an 8-bit integer. | |
| uint16_t | CountBits (uint16_t number) |
| Returns the number of set bits in a 16-bit integer. | |
| uint32_t | CountBits (uint32_t number) |
| Returns the number of set bits in a 32-bit integer. | |
| uint64_t | CountBits (uint64_t number) |
| Returns the number of set bits in a 64-bit integer. | |
| unsigned int | CountLowBits (uint8_t number) |
| Returns the number of bits required to represent the given 8-bit integer. The number of bits required to represent 0 is taken to be 0. | |
| unsigned int | CountLowBits (uint16_t number) |
| Returns the number of bits required to represent the given 16-bit integer. The number of bits required to represent 0 is taken to be 0. | |
| unsigned int | CountLowBits (uint32_t number) |
| Returns the number of bits required to represent the given 32-bit integer. The number of bits required to represent 0 is taken to be 0. | |
| unsigned int | CountLowBits (uint64_t number) |
| Returns the number of bits required to represent the given 64-bit integer. The number of bits required to represent 0 is taken to be 0. | |
Contains helper macros and functions.
Definition in file helpers.h.
|
inline |
Removes leading/trailing whitespace, and collapses internal whitespace.
| source | String in which to collapse whitespace. |
| space | Character with which to replace internal stretches of whitespace. |
The purpose of this function is to make strings which may contain leading/trailing whitespace, and annoying stretches of internal space (including newlines and tabs), somewhat "cleaner" to print or display in a dialog. In addition to the removal of leading and trailing whitespace, all "stretches" of consecutive whitespace characters (found using std::isspace) in the interior of the string will be replaced with (one copy of) the given space character.
1.8.1.2