MCPcopy Create free account
hub / github.com/DISTRHO/Cardinal / modelFromJson

Function modelFromJson

src/override/plugin.cpp:163–182  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

161
162
163Model* modelFromJson(json_t* moduleJ) {
164 // Get slugs
165 json_t* pluginSlugJ = json_object_get(moduleJ, "plugin");
166 if (!pluginSlugJ)
167 throw Exception("\"plugin\" property not found in module JSON");
168 std::string pluginSlug = json_string_value(pluginSlugJ);
169 pluginSlug = normalizeSlug(pluginSlug);
170
171 json_t* modelSlugJ = json_object_get(moduleJ, "model");
172 if (!modelSlugJ)
173 throw Exception("\"model\" property not found in module JSON");
174 std::string modelSlug = json_string_value(modelSlugJ);
175 modelSlug = normalizeSlug(modelSlug);
176
177 // Get Model
178 Model* model = getModelFallback(pluginSlug, modelSlug);
179 if (!model)
180 throw Exception("Could not find module %s/%s", pluginSlug.c_str(), modelSlug.c_str());
181 return model;
182}
183
184
185bool isSlugValid(const std::string& slug) {

Callers 1

json_array_foreachFunction · 0.85

Calls 4

json_object_getFunction · 0.85
normalizeSlugFunction · 0.85
getModelFallbackFunction · 0.85
c_strMethod · 0.80

Tested by

no test coverage detected