PIP 0.7.1 Platform-Independent Primitives

Macros | Functions | Variables
pibase.h File Reference

Base types and functions. More...

## Macros
#define | PIP_VERSION ((PIP_VERSION_MAJOR << 16) | (PIP_VERSION_MINOR < 8) | PIP_VERSION_REVISION)
| Version of PIP in hex - 0x##(Major)##(Minor)##(Revision)
#define | PIP_VERSION_MAJOR
| Major value of PIP version.
#define | PIP_VERSION_MINOR
| Minor value of PIP version.
#define | PIP_VERSION_REVISION
| Revision value of PIP version.
#define | PIP_VERSION_SUFFIX
| Suffix of PIP version.
#define | PIP_DEBUG
| Macro is defined when compile-time debug is enabled.
#define | WINDOWS
| Macro is defined when host is any Windows.
#define | QNX
| Macro is defined when host is QNX or Blackberry.
#define | BLACKBERRY
| Macro is defined when host is Blackberry.
#define | FREE_BSD
| Macro is defined when host is FreeBSD.
#define | MAC_OS
| Macro is defined when host is Mac OS.
#define | ANDROID
| Macro is defined when host is Android.
#define | LINUX
| Macro is defined when host is any Linux.
#define | CC_GCC
| Macro is defined when compiler is GCC or MinGW.
#define | HAS_LOCALE
| Macro is defined when PIP is decided that host is support language.
#define | CC_VC
| Macro is defined when compiler is Visual Studio.
#define | CC_OTHER
| Macro is defined when compiler is unknown.
#define | PIP_TIMER_RT
| Macro is defined when PIP can use "rt" library for "PITimer::ThreadRT" timers implementation.
#define | PIP_CONTAINERS_STL
| Define this macro to use STL implementation of containers, else PIP implementation will be used.
#define | FOREVER for (;;)
| Macro used for infinite loop.
#define | FOREVER_WAIT FOREVER msleep(1);
| Macro used for infinite wait.
#define | WAIT_FOREVER FOREVER msleep(1);
| Macro used for infinite wait.

## Functions
template<typename T >
void | piSwap (T &f, T &s)
| Templated function for swap two values. More...
template<typename T >
void | piSwapBinary (T &f, T &s)
| Templated function for swap two values without "=". More...
template<typename T >
int | piRound (const T &v)
| Templated function return round of float falue. More...
template<typename T >
int | piFloor (const T &v)
| Templated function return floor of float falue. More...
template<typename T >
int | piCeil (const T &v)
| Templated function return ceil of float falue. More...
template<typename T >
T | piAbs (const T &v)
| Templated function return absolute of numeric falue. More...
template<typename T >
T | piMin (const T &f, const T &s)
| Templated function return minimum of two values. More...
template<typename T >
T | piMin (const T &f, const T &s, const T &t)
| Templated function return minimum of tree values. More...
template<typename T >
T | piMax (const T &f, const T &s)
| Templated function return maximum of two values. More...
template<typename T >
T | piMax (const T &f, const T &s, const T &t)
| Templated function return maximum of tree values. More...
template<typename T >
T | piClamp (const T &v, const T &min, const T &max)
| Templated function return clamped value. More...
void | piLetobe (void *data, int size)
| Function inverse byte order in memory block.
template<typename T >
void | piLetobe (T *v)
| Templated function that inverse byte order of value "v".
template<typename T >
T | piLetobe (const T &v)
| Templated function that returns "v" with inversed byte order. More...
ushort | letobe_s (ushort v)
| Use piLetobe() instead of this function. More...
uint | letobe_i (uint v)
| Use piLetobe() instead of this function. More...

## Variables
bool | piDebug
| global variable enabling output to piCout, default is true
double | piMountInfoRefreshIntervalMs

## Detailed Description

Base types and functions.

This file implements first layer above the system and declares some basic useful functions

## Function Documentation

## ◆ piSwap()

template<typename T >

void piSwap | ( | T & | f,
|  | T & | s
| ) |  |
| inline

Templated function for swap two values.

Example:

int v1 = 1, v2 = 2;
piCout << v1 << v2; // 1 2
piSwap<int>(v1, v2);
piCout << v1 << v2; // 2 1

## ◆ piSwapBinary()

template<typename T >

void piSwapBinary | ( | T & | f,
|  | T & | s
| ) |  |
| inline

Templated function for swap two values without "=".

Example:

## ◆ piRound()

template<typename T >

int piRound | ( | const T & | v | ) |
| inline

Templated function return round of float falue.

Round is the nearest integer value
There are some macros:

- `piRoundf` for "float"
- `piRoundd` for "double"

Example:

piCout << piRoundf(0.6f) << piRoundd(0.2); // 1 0
piCout << piRoundf(-0.6f) << piRoundd(-0.2); // -1 0

## ◆ piFloor()

template<typename T >

int piFloor | ( | const T & | v | ) |
| inline

Templated function return floor of float falue.

Floor is the largest integer that is not greater than value
There are some macros:

- `piFloorf` for "float"
- `piFloord` for "double"

Example:

piCout << piFloorf(0.6f) << piFloorf(0.2); // 0 0
piCout << piFloorf(-0.6f) << piFloorf(-0.2f); // -1 -1

## ◆ piCeil()

template<typename T >

int piCeil | ( | const T & | v | ) |
| inline

Templated function return ceil of float falue.

Ceil is the smallest integer that is not less than value
There are some macros:

- `piCeilf` for "float"
- `piCeild` for "double"

Example:

piCout << piCeilf(0.6f) << piCeilf(0.2); // 1 1
piCout << piCeilf(-0.6f) << piCeilf(-0.2f); // 0 0

## ◆ piAbs()

template<typename T >

T piAbs | ( | const T & | v | ) |
| inline

Templated function return absolute of numeric falue.

Absolute is the positive or equal 0 value
There are some macros:

- `piAbss` for "short"
- `piAbsi` for "int"
- `piAbsl` for "long"
- `piAbsll` for "llong"
- `piAbsf` for "float"
- `piAbsd` for "double"

Example:

piCout << piAbsi(5) << piAbsi(-11); // 5 11
piCout << piAbsf(-0.6f) << piAbsf(-0.2f); // 0.6 0.2

## ◆ piMin() [1/2]

template<typename T >

T piMin | ( | const T & | f,
|  | const T & | s
| ) |  |
| inline

Templated function return minimum of two values.

There are some macros:

- `piMins` for "short"
- `piMini` for "int"
- `piMinl` for "long"
- `piMinll` for "llong"
- `piMinf` for "float"
- `piMind` for "double"

Example:

piCout << piMini(5, 1); // 1
piCout << piMinf(-0.6f, -0.2f); // -0.6

## ◆ piMin() [2/2]

template<typename T >

T piMin | ( | const T & | f,
|  | const T & | s,
|  | const T & | t
| ) |  |
| inline

Templated function return minimum of tree values.

There are some macros:

- `piMins` for "short"
- `piMini` for "int"
- `piMinl` for "long"
- `piMinll` for "llong"
- `piMinf` for "float"
- `piMind` for "double"

Example:

piCout << piMini(5, 1, -1); // -1
piCout << piMinf(-0.6f, -0.2f, 1.f); // -0.6

## ◆ piMax() [1/2]

template<typename T >

T piMax | ( | const T & | f,
|  | const T & | s
| ) |  |
| inline

Templated function return maximum of two values.

There are some macros:

- `piMaxs` for "short"
- `piMaxi` for "int"
- `piMaxl` for "long"
- `piMaxll` for "llong"
- `piMaxf` for "float"
- `piMaxd` for "double"

Example:

piCout << piMaxi(5, 1); // 5
piCout << piMaxf(-0.6f, -0.2f); // -0.2

## ◆ piMax() [2/2]

template<typename T >

T piMax | ( | const T & | f,
|  | const T & | s,
|  | const T & | t
| ) |  |
| inline

Templated function return maximum of tree values.

There are some macros:

- `piMaxs` for "short"
- `piMaxi` for "int"
- `piMaxl` for "long"
- `piMaxll` for "llong"
- `piMaxf` for "float"
- `piMaxd` for "double"

Example:

piCout << piMaxi(5, 1, -1); // 5
piCout << piMaxf(-0.6f, -0.2f, 1.f); // 1

## ◆ piClamp()

template<typename T >

T piClamp | ( | const T & | v,
|  | const T & | min,
|  | const T & | max
| ) |  |
| inline

Templated function return clamped value.

Clamped is the not greater than "max" and not lesser than "min" value
There are some macros:

- `piClamps` for "short"
- `piClampi` for "int"
- `piClampl` for "long"
- `piClampll` for "llong"
- `piClampf` for "float"
- `piClampd` for "double"

Example:

piCout << piClampf(-5, -3, 2); // -3
piCout << piClampf(1, -3, 2); // 1
piCout << piClampf(5, -3, 2); // 2

## ◆ piLetobe()

template<typename T >

T piLetobe | ( | const T & | v | ) |
| inline

Templated function that returns "v" with inversed byte order.

This function used to convert values between little and big endian
There are some macros:

- `piLetobes` for "ushort"
- `piLetobei` for "uint"
- `piLetobel` for "ulong"
- `piLetobell` for "ullong"

Example:

## ◆ letobe_s()

ushort letobe_s | ( | ushort | v | ) |

Use piLetobe() instead of this function.

Deprecated:

## ◆ letobe_i()

uint letobe_i | ( | uint | v | ) |

Use piLetobe() instead of this function.

Deprecated:

## Variable Documentation

## ◆ piMountInfoRefreshIntervalMs

double piMountInfoRefreshIntervalMs

global variable that set minimum real update interval for function PIInit::mountInfo(), default is 10000 ms