-
-
Save atsushieno/ac65ebfed6cf7ac66ac8273bb1e81eb5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// works | |
auto pluginEntriesToJson(std::vector<remidy::PluginCatalogEntry*> list) { | |
std::vector<nlohmann::ordered_json> ret{}; | |
for (auto e : list) | |
ret.emplace_back(nlohmann::ordered_json { | |
{"format", e->format()}, | |
{"id", e->pluginId()}, | |
{"bundle", e->bundlePath()}, | |
{"name", e->getMetadataProperty(remidy::PluginCatalogEntry::DisplayName)}, | |
{"vendor", e->getMetadataProperty(remidy::PluginCatalogEntry::VendorName)}, | |
{"url", e->getMetadataProperty(remidy::PluginCatalogEntry::ProductUrl)}, | |
}); | |
return ret; | |
} | |
// does not | |
auto pluginEntriesToJson(std::vector<remidy::PluginCatalogEntry*> list) { | |
return list | std::views::transform([](remidy::PluginCatalogEntry* e) { | |
return nlohmann::ordered_json { | |
{"format", e->format()}, | |
{"id", e->pluginId()}, | |
{"bundle", e->bundlePath()}, | |
{"name", e->getMetadataProperty(remidy::PluginCatalogEntry::DisplayName)}, | |
{"vendor", e->getMetadataProperty(remidy::PluginCatalogEntry::VendorName)}, | |
{"url", e->getMetadataProperty(remidy::PluginCatalogEntry::ProductUrl)}, | |
}; | |
}); | |
} | |
nlohmann::json toJson(remidy::PluginCatalog* catalog) { | |
auto plugins = pluginEntriesToJson(catalog->getPlugins()); | |
auto denyList = pluginEntriesToJson(catalog->getDenyList()); | |
nlohmann::json j = { | |
{"plugins", std::vector(plugins.begin(), plugins.end()) }, | |
{"denyList", std::vector(denyList.begin(), denyList.end()) } | |
}; | |
return j; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment