1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-18 00:54:19 +00:00

LV2 Client: Add basic LV2URI validation at build time

This commit is contained in:
reuk 2023-08-30 16:00:14 +01:00
parent 88e5e23f95
commit 583f90bef3
2 changed files with 19 additions and 0 deletions

View file

@ -61,6 +61,24 @@ namespace juce
namespace lv2_client
{
constexpr bool startsWithValidScheme (const std::string_view str)
{
constexpr const char* prefixes[] { "http://", "https://", "urn:" };
for (const std::string_view prefix : prefixes)
if (prefix == str.substr (0, prefix.size()))
return true;
return false;
}
// If your LV2 plugin fails to build here, it may be because you haven't explicitly set an LV2 URI,
// or you've requested a malformed URI.
// If you're using the Projucer, update the value of the "LV2 URI" field in your project settings.
// If you're using CMake, specify a valid LV2URI argument to juce_add_plugin.
static_assert (startsWithValidScheme (JucePlugin_LV2URI),
"Your configured LV2 URI must include a leading scheme specifier.");
constexpr auto uriSeparator = ":";
const auto JucePluginLV2UriUi = String (JucePlugin_LV2URI) + uriSeparator + "UI";
const auto JucePluginLV2UriState = String (JucePlugin_LV2URI) + uriSeparator + "StateString";

View file

@ -67,6 +67,7 @@
#include <queue>
#include <set>
#include <sstream>
#include <string_view>
#include <thread>
#include <typeindex>
#include <unordered_map>