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

Namespaces

namespace  Collection
namespace  Concurrent
namespace  Operators

Classes

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...

Concepts

concept  ConvertibleTo
 Allows to detect (at compilation time) whether the call static_cast<To>(from) (where from is of type From) will compile.
concept  DynamicCastablePointer
concept  ElementModifier
 Concept for updating an element. We do not explicitly restrict the return type which is unused.
concept  ElementPredicate
 Concept for updating an element.
concept  HasNotEqual
 Allows to detect whether a type defines operator!= at compile time.
concept  HasStaticMapValue
 Concept for a static mapValue function.
concept  IntegralOrEnum
 Concept that encapsulates both an integer and an enum (underlying type is an integral).
concept  OstreamWritable
 Allows to detect whether a type defines ostream << x at compile time.
concept  StringOutputIterator
 A concept to check if T is an output iterator that accepts std::string.
concept  UnaryFunction
 Matches a callable used for read-only operations.
concept  UnaryModifier
 Matches a callable used for modification.
concept  UnaryTransformer
 Matches any callable (lambda, function object, etc.) that can be invoked with a T const& (or T) and return a value convertible to T.

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>
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>

Functions

template<typename T, typename U>
static constexpr 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 constexpr 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 constexpr 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 constexpr DPLerpXY< X, Y > mapRangeDPXY (X iFromLow, X iFromHigh, Y iToLow, Y iToHigh)
 Convenient shortcut for double precision.
template<typename X, typename Y>
static constexpr SPLerpXY< X, Y > mapRangeSPXY (X iFromLow, X iFromHigh, Y iToLow, Y iToHigh) noexcept
 Convenient shortcut for single precision.
static constexpr double mapValueDP (double iValue, double iFromLow, double iFromHigh, double iToLow, double iToHigh, bool iClamp=true)
 Convenient shortcut for single precision.
template<typename X>
static constexpr 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 constexpr Y mapValueDPXY (X iValue, X iFromLow, X iFromHigh, Y iToLow, Y iToHigh, bool iClamp=true)
 Convenient shortcut for single precision.
template<typename Y>
static constexpr Y mapValueDPY (double iValue, double iFromLow, double iFromHigh, Y iToLow, Y iToHigh, bool iClamp=true)
 Convenient shortcut for single precision.
static constexpr float mapValueSP (float iValue, float iFromLow, float iFromHigh, float iToLow, float iToHigh, bool iClamp=true)
 Convenient shortcut for single precision.
template<typename X>
static constexpr 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 constexpr Y mapValueSPXY (X iValue, X iFromLow, X iFromHigh, Y iToLow, Y iToHigh, bool iClamp=true)
 Convenient shortcut for single precision.
template<typename Y>
static constexpr Y mapValueSPY (float iValue, float iFromLow, float iFromHigh, Y iToLow, Y iToHigh, bool iClamp=true)
 Convenient shortcut for single precision.
template<typename To, typename From>
constexpr To safe_dynamic_cast (From *p) noexcept
 dynamic_cast<U *>(x) does not compile if x is not polymorphic.
template<std::floating_point T>
std::vector< T > splitFloats (const std::string &iString, char iDelimiter, bool iSkipEmptyEntries=false)
 Converts the string to an array of floating points (floats or doubles).
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<StringOutputIterator 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<std::floating_point T>
stringToFloat (const std::string &iString)
 Converts the string to a floating point (float or double).
template<std::floating_point T>
bool stringToFloat (const std::string &iString, T &oValue)
 Converts the string to a floating point (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

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>

◆ 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>

Function Documentation

◆ clamp()

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

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>
constexpr T clampE ( const U & value,
const T & lower,
const T & upper )
staticconstexpr

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>
constexpr T clampRange ( const U & iValue,
const T & iFrom,
const T & iTo )
staticconstexpr

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>
constexpr DPLerpXY< X, Y > mapRangeDPXY ( X iFromLow,
X iFromHigh,
Y iToLow,
Y iToHigh )
staticconstexpr

Convenient shortcut for double precision.

See Lerp::mapRange

◆ mapRangeSPXY()

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

Convenient shortcut for single precision.

See Lerp::mapRange

◆ mapValueDP()

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

Convenient shortcut for single precision.

See Lerp::mapValue

◆ mapValueDPX()

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

Convenient shortcut for single precision.

See Lerp::mapValue

◆ mapValueDPXY()

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

Convenient shortcut for single precision.

See Lerp::mapValue

◆ mapValueDPY()

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

Convenient shortcut for single precision.

See Lerp::mapValue

◆ mapValueSP()

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

Convenient shortcut for single precision.

See Lerp::mapValue

◆ mapValueSPX()

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

Convenient shortcut for single precision.

See Lerp::mapValue

◆ mapValueSPXY()

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

Convenient shortcut for single precision.

See Lerp::mapValue

◆ mapValueSPY()

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

Convenient shortcut for single precision.

See Lerp::mapValue

◆ safe_dynamic_cast()

template<typename To, typename From>
To safe_dynamic_cast ( From * p)
constexprnoexcept

dynamic_cast<U *>(x) does not compile if x is not polymorphic.

This function allows calling it with a non-polymorphic type.

◆ splitFloats()

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

Converts the string to an array of floating points (floats or doubles).

◆ 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<StringOutputIterator 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<std::floating_point T>
T stringToFloat ( const std::string & iString)

Converts the string to a floating point (float or double).

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<std::floating_point T>
bool stringToFloat ( const std::string & iString,
T & oValue )

Converts the string to a floating point (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

◆ 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