Jamba C++ API  4.0.0
pongasoft::VST::VstUtils Namespace Reference

Functions

template<typename T , typename... Args>
std::shared_ptr< T > make_sfo (Args &&...iArgs)
 The VST SDK uses the concept of FObject (which are self contained reference counted objects) but require to be manually managed (by calling addRef and release). More...
 
std::string toUT8String (VstString16 const &iString)
 Converts a VstString16 to a regular std::string that is properly utf-8 encoded. More...
 
template<typename T >
std::string toUTF8String (T const &iValue, Steinberg::int32 iPrecision)
 This generic function will determine (at compilation time) whether T can be written to an ostream and if that is the case, will use this information to build the string. More...
 

Function Documentation

◆ make_sfo()

std::shared_ptr<T> pongasoft::VST::VstUtils::make_sfo ( Args &&...  iArgs)

The VST SDK uses the concept of FObject (which are self contained reference counted objects) but require to be manually managed (by calling addRef and release).

In a few instances (GUIValParameter and GUIJmbParameter), Jamba creates and manages std::shared_ptr while using the underlying raw pointer with VST SDK classes. So in order to marry the 2 worlds, this util method creates a shared_ptr whose deleter simply delegates to the FObject::release method:

  • if the internal ref count is 1 and the shared_ptr goes away, p->release() will destroy the object
  • if the internal ref count is > 1 (for example, FObjectCx still holds a reference) and the shared_ptr goes away, then p->release() only decrements the counter and whenever FObjectCx goes away, it will call p->release() which will then destroy the object

◆ toUT8String()

std::string pongasoft::VST::VstUtils::toUT8String ( VstString16 const &  iString)
inline

Converts a VstString16 to a regular std::string that is properly utf-8 encoded.

◆ toUTF8String()

std::string pongasoft::VST::VstUtils::toUTF8String ( T const &  iValue,
Steinberg::int32  iPrecision 
)

This generic function will determine (at compilation time) whether T can be written to an ostream and if that is the case, will use this information to build the string.

Otherwise returns an empty string.