MCPcopy Create free account
hub / github.com/VCVRack/Rack / modelFromJson

Function modelFromJson

src/plugin.cpp:473–492  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

471
472
473Model* modelFromJson(json_t* moduleJ) {
474 // Get slugs
475 json_t* pluginSlugJ = json_object_get(moduleJ, "plugin");
476 if (!pluginSlugJ)
477 throw Exception("\"plugin\" property not found in module JSON");
478 std::string pluginSlug = json_string_value(pluginSlugJ);
479 pluginSlug = normalizeSlug(pluginSlug);
480
481 json_t* modelSlugJ = json_object_get(moduleJ, "model");
482 if (!modelSlugJ)
483 throw Exception("\"model\" property not found in module JSON");
484 std::string modelSlug = json_string_value(modelSlugJ);
485 modelSlug = normalizeSlug(modelSlug);
486
487 // Get Model
488 Model* model = getModelFallback(pluginSlug, modelSlug);
489 if (!model)
490 throw Exception("Could not find module %s/%s", pluginSlug.c_str(), modelSlug.c_str());
491 return model;
492}
493
494
495bool isSlugValid(const std::string& slug) {

Callers 4

json_array_foreachFunction · 0.85
fromJsonMethod · 0.85
json_array_foreachFunction · 0.85
moduleWidgetFromJsonFunction · 0.85

Calls 3

ExceptionClass · 0.85
normalizeSlugFunction · 0.85
getModelFallbackFunction · 0.85

Tested by

no test coverage detected