Jamba C++ API  5.1.1
pongasoft::Utils Namespace Reference

Namespaces

 Collection
 
 Concurrent
 
 cpp17
 
 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!= More...
 
template<typename T >
using operator_write_to_ostream_t = decltype(std::declval< std::ostream & >()<< std::declval< T const & >())
 Defines the type for operator<< More...
 
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) More...
 

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. More...
 
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. More...
 
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. More...
 
template<typename X , typename Y >
static DPLerpXY< X, Y > mapRangeDPXY (X iFromLow, X iFromHigh, Y iToLow, Y iToHigh)
 Convenient shortcut for double precision. More...
 
template<typename X , typename Y >
static SPLerpXY< X, Y > mapRangeSPXY (X iFromLow, X iFromHigh, Y iToLow, Y iToHigh)
 Convenient shortcut for single precision. More...
 
static double mapValueDP (double iValue, double iFromLow, double iFromHigh, double iToLow, double iToHigh, bool iClamp=true)
 Convenient shortcut for single precision. More...
 
template<typename X >
static double mapValueDPX (X iValue, X iFromLow, X iFromHigh, double iToLow, double iToHigh, bool iClamp=true)
 Convenient shortcut for single precision. More...
 
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. More...
 
template<typename Y >
static Y mapValueDPY (double iValue, double iFromLow, double iFromHigh, Y iToLow, Y iToHigh, bool iClamp=true)
 Convenient shortcut for single precision. More...
 
static float mapValueSP (float iValue, float iFromLow, float iFromHigh, float iToLow, float iToHigh, bool iClamp=true)
 Convenient shortcut for single precision. More...
 
template<typename X >
static float mapValueSPX (X iValue, X iFromLow, X iFromHigh, float iToLow, float iToHigh, bool iClamp=true)
 Convenient shortcut for single precision. More...
 
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. More...
 
template<typename Y >
static Y mapValueSPY (float iValue, float iFromLow, float iFromHigh, Y iToLow, Y iToHigh, bool iClamp=true)
 Convenient shortcut for single precision. More...
 
template<typename TFloat >
std::vector< TFloat > splitFloats (const std::string &iString, char iDelimiter, bool iSkipEmptyEntries=false)
 Converts the string to a TFloat. More...
 
std::vector< std::string > splitString (const std::string &iString, char iDelimiter, bool iSkipEmptyEntries)
 Split a string according to a delimiter and returns a vector. More...
 
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...) More...
 
template<typename TFloat >
bool stringToFloat (const std::string &iString, TFloat &oValue)
 Converts the string to a TFloat (float or double) More...
 
template<typename TFloat >
TFloat stringToFloat (const std::string &iString)
 Converts the string to a TFloat. More...
 
constexpr char const * to_string (bool iValue)
 Convenient call to convert a boolean into a string. More...
 
template<typename T >
std::string typeString ()
 typeid(T).name() does not account for const or reference. More...
 

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

using DPLerpX = Lerp<double, X, double>

◆ DPLerpXY

using DPLerpXY = Lerp<double, X, Y>

◆ DPLerpY

using DPLerpY = Lerp<double, double, Y>

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

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

using SPLerpX = Lerp<float, X, float>

◆ SPLerpXY

using SPLerpXY = Lerp<float, X, Y>

◆ SPLerpY

using SPLerpY = Lerp<float, float, Y>

◆ static_cast_t

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

Defines the type for static_cast<To>(From)

Function Documentation

◆ clamp()

static T pongasoft::Utils::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()

static T pongasoft::Utils::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()

static T pongasoft::Utils::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()

static DPLerpXY<X, Y> pongasoft::Utils::mapRangeDPXY ( iFromLow,
iFromHigh,
iToLow,
iToHigh 
)
inlinestatic

Convenient shortcut for double precision.

See Lerp::mapRange

◆ mapRangeSPXY()

static SPLerpXY<X, Y> pongasoft::Utils::mapRangeSPXY ( iFromLow,
iFromHigh,
iToLow,
iToHigh 
)
inlinestatic

Convenient shortcut for single precision.

See Lerp::mapRange

◆ mapValueDP()

static double pongasoft::Utils::mapValueDP ( double  iValue,
double  iFromLow,
double  iFromHigh,
double  iToLow,
double  iToHigh,
bool  iClamp = true 
)
inlinestatic

Convenient shortcut for single precision.

See Lerp::mapValue

◆ mapValueDPX()

static double pongasoft::Utils::mapValueDPX ( iValue,
iFromLow,
iFromHigh,
double  iToLow,
double  iToHigh,
bool  iClamp = true 
)
inlinestatic

Convenient shortcut for single precision.

See Lerp::mapValue

◆ mapValueDPXY()

static Y pongasoft::Utils::mapValueDPXY ( iValue,
iFromLow,
iFromHigh,
iToLow,
iToHigh,
bool  iClamp = true 
)
inlinestatic

Convenient shortcut for single precision.

See Lerp::mapValue

◆ mapValueDPY()

static Y pongasoft::Utils::mapValueDPY ( double  iValue,
double  iFromLow,
double  iFromHigh,
iToLow,
iToHigh,
bool  iClamp = true 
)
inlinestatic

Convenient shortcut for single precision.

See Lerp::mapValue

◆ mapValueSP()

static float pongasoft::Utils::mapValueSP ( float  iValue,
float  iFromLow,
float  iFromHigh,
float  iToLow,
float  iToHigh,
bool  iClamp = true 
)
inlinestatic

Convenient shortcut for single precision.

See Lerp::mapValue

◆ mapValueSPX()

static float pongasoft::Utils::mapValueSPX ( iValue,
iFromLow,
iFromHigh,
float  iToLow,
float  iToHigh,
bool  iClamp = true 
)
inlinestatic

Convenient shortcut for single precision.

See Lerp::mapValue

◆ mapValueSPXY()

static Y pongasoft::Utils::mapValueSPXY ( iValue,
iFromLow,
iFromHigh,
iToLow,
iToHigh,
bool  iClamp = true 
)
inlinestatic

Convenient shortcut for single precision.

See Lerp::mapValue

◆ mapValueSPY()

static Y pongasoft::Utils::mapValueSPY ( float  iValue,
float  iFromLow,
float  iFromHigh,
iToLow,
iToHigh,
bool  iClamp = true 
)
inlinestatic

Convenient shortcut for single precision.

See Lerp::mapValue

◆ splitFloats()

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

Converts the string to a TFloat.

Returns
the float or nan if not a number

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

void pongasoft::Utils::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]

bool pongasoft::Utils::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

◆ stringToFloat() [2/2]

TFloat pongasoft::Utils::stringToFloat ( const std::string &  iString)

Converts the string to a TFloat.

Returns
the float or nan if not a number

◆ to_string()

constexpr char const* pongasoft::Utils::to_string ( bool  iValue)

Convenient call to convert a boolean into a string.

◆ typeString()

std::string pongasoft::Utils::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

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.

Example:

if constexpr (Utils::is_operator_not_eq_defined<MyType>) {
// implementation allows to write a != b (with a/b of MyType)
} else {
// no such operator... alternate implementation
}

◆ is_operator_write_to_ostream_defined

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.

Example:

if constexpr (Utils::is_operator_write_to_ostream_defined<MyType>) {
// implementation allows to write std::cout << x // (with x of type MyType)
} else {
// no such operator... alternate implementation
}

◆ is_static_cast_defined

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.

Example:

void f(SomeType &iValue) {
if constexpr(Utils::is_static_cast_defined<SomeType, int>) {
auto i = static_cast<int>(iValue); // this will compile!
...
} else {
// static_cast<int>(iValue) does NOT compile so do something different
}

◆ mapRangeDP

constexpr auto mapRangeDP = mapRangeDPXY<double, double>

◆ mapRangeDPX

constexpr auto mapRangeDPX = mapRangeDPXY<X, double>

◆ mapRangeDPY

constexpr auto mapRangeDPY = mapRangeDPXY<double, Y>

◆ mapRangeSP

constexpr auto mapRangeSP = mapRangeSPXY<float, float>

◆ mapRangeSPX

constexpr auto mapRangeSPX = mapRangeSPXY<X, float>

◆ mapRangeSPY

constexpr auto mapRangeSPY = mapRangeSPXY<float, Y>

◆ MAX_INT32

constexpr Steinberg::int32 MAX_INT32 = 0x7fffffff

◆ ZERO_INT32

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