float getParameterValue(const uint32_t index) const { DISTRHO_SAFE_ASSERT_RETURN(fPlugin != nullptr, 0.0f); DISTRHO_SAFE_ASSERT_RETURN(fData != nullptr && index < fData->parameterCount, 0.0f); return fPlugin->d_getParameterValue(index); }
Color Color::fromHTML(const char* rgb, float alpha) { Color fallback; DISTRHO_SAFE_ASSERT_RETURN(rgb != nullptr && rgb[0] != '\0', fallback); if (rgb[0] == '#') ++rgb; DISTRHO_SAFE_ASSERT_RETURN(rgb[0] != '\0', fallback); std::size_t rgblen(std::strlen(rgb)); DISTRHO_SAFE_ASSERT_RETURN(rgblen == 3 || rgblen == 6, fallback); char rgbtmp[3] = { '\0', '\0', '\0' }; int r, g, b; if (rgblen == 3) { rgbtmp[0] = rgb[0]; r = static_cast<int>(std::strtol(rgbtmp, nullptr, 16)); rgbtmp[0] = rgb[1]; g = static_cast<int>(std::strtol(rgbtmp, nullptr, 16)); rgbtmp[0] = rgb[2]; b = static_cast<int>(std::strtol(rgbtmp, nullptr, 16)); } else { rgbtmp[0] = rgb[0]; rgbtmp[1] = rgb[1]; r = static_cast<int>(std::strtol(rgbtmp, nullptr, 16)); rgbtmp[0] = rgb[2]; rgbtmp[1] = rgb[3]; g = static_cast<int>(std::strtol(rgbtmp, nullptr, 16)); rgbtmp[0] = rgb[4]; rgbtmp[1] = rgb[5]; b = static_cast<int>(std::strtol(rgbtmp, nullptr, 16)); } return Color(r, g, b, static_cast<int>(getFixedRange(alpha)*255.0f)); }
/** Changes this ScopedPointer to point to a new object. Because a pointer can only belong to one ScopedPointer, this transfers the pointer from the other object to this one, and the other object is reset to be a null pointer. If this ScopedPointer already points to an object, that object will first be deleted. */ ScopedPointer& operator=(ScopedPointer& objectToTransferFrom) { if (this != objectToTransferFrom.getAddress()) { // Two ScopedPointers should never be able to refer to the same object - if // this happens, you must have done something dodgy! DISTRHO_SAFE_ASSERT_RETURN(object == nullptr || object != objectToTransferFrom.object, *this); ObjectType* const oldObject = object; object = objectToTransferFrom.object; objectToTransferFrom.object = nullptr; ContainerDeletePolicy<ObjectType>::destroy(oldObject); } return *this; }
GLuint NanoImage::getTextureHandle() const { DISTRHO_SAFE_ASSERT_RETURN(fHandle.context != nullptr && fHandle.imageId != 0, 0); return nvglImageHandle(fHandle.context, fHandle.imageId); }
const ParameterRanges& getParameterRanges(const uint32_t index) const noexcept { DISTRHO_SAFE_ASSERT_RETURN(fData != nullptr && index < fData->parameterCount, sFallbackRanges); return fData->parameters[index].ranges; }
uint32_t getParameterHints(const uint32_t index) const noexcept { DISTRHO_SAFE_ASSERT_RETURN(fData != nullptr && index < fData->parameterCount, 0x0); return fData->parameters[index].hints; }
const d_string& getParameterUnit(const uint32_t index) const noexcept { DISTRHO_SAFE_ASSERT_RETURN(fData != nullptr && index < fData->parameterCount, sFallbackString); return fData->parameters[index].unit; }
uint32_t getParameterCount() const noexcept { DISTRHO_SAFE_ASSERT_RETURN(fData != nullptr, 0); return fData->parameterCount; }
uint32_t getLatency() const noexcept { DISTRHO_SAFE_ASSERT_RETURN(fData != nullptr, 0); return fData->latency; }
long getUniqueId() const noexcept { DISTRHO_SAFE_ASSERT_RETURN(fPlugin != nullptr, 0); return fPlugin->d_getUniqueId(); }
uint32_t getVersion() const noexcept { DISTRHO_SAFE_ASSERT_RETURN(fPlugin != nullptr, 0); return fPlugin->d_getVersion(); }
const char* getLicense() const noexcept { DISTRHO_SAFE_ASSERT_RETURN(fPlugin != nullptr, ""); return fPlugin->d_getLicense(); }