Jamba C++ API 7.5.0
Loading...
Searching...
No Matches
pongasoft::Utils Namespace Reference

Namespaces

namespace  Collection
namespace  Concurrent
namespace  cpp17
namespace  Operators

Classes

class  Cast
 dynamic_cast<U *>(x) does not compile if x is not polymorphic. More...
class  Disposable
 Classes who can release resources can implement this interface. More...
class  Lerp
 Util class to compute linear interpolation. More...
struct  Range
 Defines a range of values. More...

Typedefs

using DPLerp = Lerp<double, double, double>
template<typename X>
using DPLerpX = Lerp<double, X, double>
template<typename X, typename Y>
using DPLerpXY = Lerp<double, X, Y>
template<typename Y>
using DPLerpY = Lerp<double, double, Y>
template<typename T>
using operator_not_eq_t = decltype(std::declval<T const&>() != std::declval<T const&>())
 Defines the type for operator!=.
template<typename T>
using operator_write_to_ostream_t = decltype(std::declval<std::ostream &>() << std::declval<T const&>())
 Defines the type for operator<<.
using SPLerp = Lerp<float, float, float>
template<typename X>
using SPLerpX = Lerp<float, X, float>
template<typename X, typename Y>
using SPLerpXY = Lerp<float, X, Y>
template<typename Y>
using SPLerpY = Lerp<float, float, Y>
template<typename From, typename To>
using static_cast_t = decltype(static_cast<To>(std::declval<From>()))
 Defines the type for static_cast<To>(From).

Functions

template<typename T, typename U>
static T clamp (const U &iValue, const T &iLower, const T &iUpper)
 Make sure that the value remains within its bounds.
template<typename T, typename U>
static T clampE (const U &value, const T &lower, const T &upper)
 Same as clamp except it will actually fail/assert in debug mode.
template<typename T, typename U>
static T clampRange (const U &iValue, const T &iFrom, const T &iTo)
 Make sure that the value remains within its bounds.
template<typename X, typename Y>
static DPLerpXY< X, Y > mapRangeDPXY (X iFromLow, X iFromHigh, Y iToLow, Y iToHigh)
 Convenient shortcut for double precision.
template<typename X, typename Y>
static SPLerpXY< X, Y > mapRangeSPXY (X iFromLow, X iFromHigh, Y iToLow, Y iToHigh)
 Convenient shortcut for single precision.
static double mapValueDP (double iValue, double iFromLow, double iFromHigh, double iToLow, double iToHigh, bool iClamp=true)
 Convenient shortcut for single precision.
template<typename X>
static double mapValueDPX (X iValue, X iFromLow, X iFromHigh, double iToLow, double iToHigh, bool iClamp=true)
 Convenient shortcut for single precision.
template<typename X, typename Y>
static Y mapValueDPXY (X iValue, X iFromLow, X iFromHigh, Y iToLow, Y iToHigh, bool iClamp=true)
 Convenient shortcut for single precision.
template<typename Y>
static Y mapValueDPY (double iValue, double iFromLow, double iFromHigh, Y iToLow, Y iToHigh, bool iClamp=true)
 Convenient shortcut for single precision.
static float mapValueSP (float iValue, float iFromLow, float iFromHigh, float iToLow, float iToHigh, bool iClamp=true)
 Convenient shortcut for single precision.
template<typename X>
static float mapValueSPX (X iValue, X iFromLow, X iFromHigh, float iToLow, float iToHigh, bool iClamp=true)
 Convenient shortcut for single precision.
template<typename X, typename Y>
static Y mapValueSPXY (X iValue, X iFromLow, X iFromHigh, Y iToLow, Y iToHigh, bool iClamp=true)
 Convenient shortcut for single precision.
template<typename Y>
static Y mapValueSPY (float iValue, float iFromLow, float iFromHigh, Y iToLow, Y iToHigh, bool iClamp=true)
 Convenient shortcut for single precision.
template<typename TFloat>
std::vector< TFloat > splitFloats (const std::string &iString, char iDelimiter, bool iSkipEmptyEntries=false)
 Converts the string to a an array of floats.
std::vector< std::string > splitString (const std::string &iString, char iDelimiter, bool iSkipEmptyEntries)
 Split a string according to a delimiter and returns a vector.
template<typename Out>
void splitString (const std::string &iString, char iDelimiter, Out oResult, bool iSkipEmptyEntries=false)
 Split a string according to a delimiter and writes the result into Out (can be a vector, array, etc...).
template<typename TFloat>
TFloat stringToFloat (const std::string &iString)
 Converts the string to a TFloat.
template<typename TFloat>
bool stringToFloat (const std::string &iString, TFloat &oValue)
 Converts the string to a TFloat (float or double).
constexpr char const * to_string (bool iValue)
 Convenient call to convert a boolean into a string.
template<typename T>
std::string typeString ()
 typeid(T).name() does not account for const or reference.

Variables

template<typename T>
constexpr auto is_operator_not_eq_defined = cpp17::experimental::is_detected_v<operator_not_eq_t, T>
 Allows to detect whether a type defines operator!= at compile time.
template<typename T>
constexpr auto is_operator_write_to_ostream_defined = cpp17::experimental::is_detected_v<operator_write_to_ostream_t, T>
 Allows to detect whether a type defines ostream << x at compile time.
template<typename From, typename To>
constexpr auto is_static_cast_defined = cpp17::experimental::is_detected_v<static_cast_t, From, To>
 Allows to detect (at compilation time) whether the call static_cast<To>(from) (where from is of type From) will compile.
constexpr auto mapRangeDP = mapRangeDPXY<double, double>
template<typename X>
constexpr auto mapRangeDPX = mapRangeDPXY<X, double>
template<typename Y>
constexpr auto mapRangeDPY = mapRangeDPXY<double, Y>
constexpr auto mapRangeSP = mapRangeSPXY<float, float>
template<typename X>
constexpr auto mapRangeSPX = mapRangeSPXY<X, float>
template<typename Y>
constexpr auto mapRangeSPY = mapRangeSPXY<float, Y>
constexpr Steinberg::int32 MAX_INT32 = 0x7fffffff
constexpr auto ZERO_INT32 = static_cast<Steinberg::int32>(0)

Typedef Documentation

◆ DPLerp

using DPLerp = Lerp<double, double, double>

◆ DPLerpX

template<typename X>
using DPLerpX = Lerp<double, X, double>

◆ DPLerpXY

template<typename X, typename Y>
using DPLerpXY = Lerp<double, X, Y>

◆ DPLerpY

template<typename Y>
using DPLerpY = Lerp<double, double, Y>

◆ operator_not_eq_t

template<typename T>
using operator_not_eq_t = decltype(std::declval<T const&>() != std::declval<T const&>())

Defines the type for operator!=.

◆ operator_write_to_ostream_t

template<typename T>
using operator_write_to_ostream_t = decltype(std::declval<std::ostream &>() << std::declval<T const&>())

Defines the type for operator<<.

◆ SPLerp

using SPLerp = Lerp<float, float, float>

◆ SPLerpX

template<typename X>
using SPLerpX = Lerp<float, X, float>

◆ SPLerpXY

template<typename X, typename Y>
using SPLerpXY = Lerp<float, X, Y>

◆ SPLerpY

template<typename Y>
using SPLerpY = Lerp<float, float, Y>

◆ static_cast_t

template<typename From, typename To>
using static_cast_t = decltype(static_cast<To>(std::declval<From>()))

Defines the type for static_cast<To>(From).

Function Documentation

◆ clamp()

template<typename T, typename U>
T clamp ( const U & iValue,
const T & iLower,
const T & iUpper )
inlinestatic

Make sure that the value remains within its bounds.

Parameters
iValuethe value to clamp between iLower and iUpper
iLowerthe lower bound (must be <= iUpper)
iUpperthe upper bound (must be >= iLower)

◆ clampE()

template<typename T, typename U>
T clampE ( const U & value,
const T & lower,
const T & upper )
inlinestatic

Same as clamp except it will actually fail/assert in debug mode.

For example can be used to access an array with an index and making sure the index is valid within the array. If it happens in production release then it will no randomly crash the application by accessing random memory.

◆ clampRange()

template<typename T, typename U>
T clampRange ( const U & iValue,
const T & iFrom,
const T & iTo )
inlinestatic

Make sure that the value remains within its bounds.

The difference with clamp is that iFrom and iTo do not have to be provided in any specific order.

◆ mapRangeDPXY()

template<typename X, typename Y>
DPLerpXY< X, Y > mapRangeDPXY ( X iFromLow,
X iFromHigh,
Y iToLow,
Y iToHigh )
inlinestatic

Convenient shortcut for double precision.

See Lerp::mapRange

◆ mapRangeSPXY()

template<typename X, typename Y>
SPLerpXY< X, Y > mapRangeSPXY ( X iFromLow,
X iFromHigh,
Y iToLow,
Y iToHigh )
inlinestatic

Convenient shortcut for single precision.

See Lerp::mapRange

◆ mapValueDP()

double mapValueDP ( double iValue,
double iFromLow,
double iFromHigh,
double iToLow,
double iToHigh,
bool iClamp = true )
inlinestatic

Convenient shortcut for single precision.

See Lerp::mapValue

◆ mapValueDPX()

template<typename X>
double mapValueDPX ( X iValue,
X iFromLow,
X iFromHigh,
double iToLow,
double iToHigh,
bool iClamp = true )
inlinestatic

Convenient shortcut for single precision.

See Lerp::mapValue

◆ mapValueDPXY()

template<typename X, typename Y>
Y mapValueDPXY ( X iValue,
X iFromLow,
X iFromHigh,
Y iToLow,
Y iToHigh,
bool iClamp = true )
inlinestatic

Convenient shortcut for single precision.

See Lerp::mapValue

◆ mapValueDPY()

template<typename Y>
Y mapValueDPY ( double iValue,
double iFromLow,
double iFromHigh,
Y iToLow,
Y iToHigh,
bool iClamp = true )
inlinestatic

Convenient shortcut for single precision.

See Lerp::mapValue

◆ mapValueSP()

float mapValueSP ( float iValue,
float iFromLow,
float iFromHigh,
float iToLow,
float iToHigh,
bool iClamp = true )
inlinestatic

Convenient shortcut for single precision.

See Lerp::mapValue

◆ mapValueSPX()

template<typename X>
float mapValueSPX ( X iValue,
X iFromLow,
X iFromHigh,
float iToLow,
float iToHigh,
bool iClamp = true )
inlinestatic

Convenient shortcut for single precision.

See Lerp::mapValue

◆ mapValueSPXY()

template<typename X, typename Y>
Y mapValueSPXY ( X iValue,
X iFromLow,
X iFromHigh,
Y iToLow,
Y iToHigh,
bool iClamp = true )
inlinestatic

Convenient shortcut for single precision.

See Lerp::mapValue

◆ mapValueSPY()

template<typename Y>
Y mapValueSPY ( float iValue,
float iFromLow,
float iFromHigh,
Y iToLow,
Y iToHigh,
bool iClamp = true )
inlinestatic

Convenient shortcut for single precision.

See Lerp::mapValue

◆ splitFloats()

template<typename TFloat>
std::vector< TFloat > splitFloats ( const std::string & iString,
char iDelimiter,
bool iSkipEmptyEntries = false )

Converts the string to a an array of floats.

◆ splitString() [1/2]

std::vector< std::string > splitString ( const std::string & iString,
char iDelimiter,
bool iSkipEmptyEntries )

Split a string according to a delimiter and returns a vector.

Parameters
iStringthe string to split
iDelimiterthe delimiter
iSkipEmptyEntrieswhether to include or not empty entries

◆ splitString() [2/2]

template<typename Out>
void splitString ( const std::string & iString,
char iDelimiter,
Out oResult,
bool iSkipEmptyEntries = false )

Split a string according to a delimiter and writes the result into Out (can be a vector, array, etc...).

Parameters
iStringthe string to split
iDelimiterthe delimiter
oResultthe result
iSkipEmptyEntrieswhether to include or not empty entries

◆ stringToFloat() [1/2]

template<typename TFloat>
TFloat stringToFloat ( const std::string & iString)

Converts the string to a TFloat.

Implementation note: the VST3 SDK uses fast-math compilation option which essentially disables the use of NaN, and so it doesn't make sense to return NaN when the string is not a number because you cannot test for it in an efficient manner

Returns
the float or 0 if not a number

◆ stringToFloat() [2/2]

template<typename TFloat>
bool stringToFloat ( const std::string & iString,
TFloat & oValue )

Converts the string to a TFloat (float or double).

Returns
true if it could be extracted in which case oValue will contain the float, false otherwise

◆ to_string()

char const * to_string ( bool iValue)
constexpr

Convenient call to convert a boolean into a string.

◆ typeString()

template<typename T>
std::string typeString ( )

typeid(T).name() does not account for const or reference.

This function adds the const and & qualifier when necessary

Variable Documentation

◆ is_operator_not_eq_defined

template<typename T>
auto is_operator_not_eq_defined = cpp17::experimental::is_detected_v<operator_not_eq_t, T>
constexpr

Allows to detect whether a type defines operator!= at compile time.

Example:

// implementation allows to write a != b (with a/b of MyType)
} else {
// no such operator... alternate implementation
}
constexpr auto is_operator_not_eq_defined
Allows to detect whether a type defines operator!= at compile time.
Definition Metaprogramming.h:70

◆ is_operator_write_to_ostream_defined

template<typename T>
auto is_operator_write_to_ostream_defined = cpp17::experimental::is_detected_v<operator_write_to_ostream_t, T>
constexpr

Allows to detect whether a type defines ostream << x at compile time.

Example:

// implementation allows to write std::cout << x // (with x of type MyType)
} else {
// no such operator... alternate implementation
}
constexpr auto is_operator_write_to_ostream_defined
Allows to detect whether a type defines ostream << x at compile time.
Definition Metaprogramming.h:115

◆ is_static_cast_defined

template<typename From, typename To>
auto is_static_cast_defined = cpp17::experimental::is_detected_v<static_cast_t, From, To>
constexpr

Allows to detect (at compilation time) whether the call static_cast<To>(from) (where from is of type From) will compile.

Example:

void f(SomeType &iValue) {
auto i = static_cast<int>(iValue); // this will compile!
...
} else {
// static_cast<int>(iValue) does NOT compile so do something different
}
constexpr auto is_static_cast_defined
Allows to detect (at compilation time) whether the call static_cast<To>(from) (where from is of type ...
Definition Metaprogramming.h:94

◆ mapRangeDP

auto mapRangeDP = mapRangeDPXY<double, double>
constexpr

◆ mapRangeDPX

template<typename X>
auto mapRangeDPX = mapRangeDPXY<X, double>
constexpr

◆ mapRangeDPY

template<typename Y>
auto mapRangeDPY = mapRangeDPXY<double, Y>
constexpr

◆ mapRangeSP

auto mapRangeSP = mapRangeSPXY<float, float>
constexpr

◆ mapRangeSPX

template<typename X>
auto mapRangeSPX = mapRangeSPXY<X, float>
constexpr

◆ mapRangeSPY

template<typename Y>
auto mapRangeSPY = mapRangeSPXY<float, Y>
constexpr

◆ MAX_INT32

Steinberg::int32 MAX_INT32 = 0x7fffffff
constexpr

◆ ZERO_INT32

auto ZERO_INT32 = static_cast<Steinberg::int32>(0)
constexpr