diff --git a/src/interaction/keybindingmanager.cpp b/src/interaction/keybindingmanager.cpp index 8ec82b5953..2c6881f310 100644 --- a/src/interaction/keybindingmanager.cpp +++ b/src/interaction/keybindingmanager.cpp @@ -39,14 +39,25 @@ namespace openspace::interaction { void sortJson(nlohmann::json& json) { - std::sort(json.begin(), json.end(), [] - (const nlohmann::json& lhs, const nlohmann::json& rhs) { + std::sort( + json.begin(), + json.end(), + [](const nlohmann::json& lhs, const nlohmann::json& rhs) { std::string lhsString = lhs["Name"]; std::string rhsString = rhs["Name"]; - std::transform(lhsString.begin(), lhsString.end(), lhsString.begin(), - [](unsigned char c) { return std::tolower(c); }); - std::transform(rhsString.begin(), rhsString.end(), rhsString.begin(), - [](unsigned char c) { return std::tolower(c); }); + std::transform( + lhsString.begin(), + lhsString.end(), + lhsString.begin(), + [](unsigned char c) { return std::tolower(c); } + ); + std::transform( + rhsString.begin(), + rhsString.end(), + rhsString.begin(), + [](unsigned char c) { return std::tolower(c); } + ); + return rhsString > lhsString; }); } @@ -162,7 +173,7 @@ nlohmann::json KeybindingManager::generateJsonJson() const { nlohmann::json keybind; keybind["Name"] = ghoul::to_string(p.first); keybind["Action"] = p.second; - json.push_back(keybind); + json.push_back(std::move(keybind)); } sortJson(json); diff --git a/src/properties/propertyowner.cpp b/src/properties/propertyowner.cpp index 3a2c8f890c..a245bf62f1 100644 --- a/src/properties/propertyowner.cpp +++ b/src/properties/propertyowner.cpp @@ -42,14 +42,25 @@ namespace { constexpr std::string_view _loggerCat = "PropertyOwner"; void sortJson(nlohmann::json& json) { - std::sort(json.begin(), json.end(), [] - (const nlohmann::json& lhs, const nlohmann::json& rhs) { + std::sort( + json.begin(), + json.end(), + [](const nlohmann::json& lhs, const nlohmann::json& rhs) { std::string lhsString = lhs["Name"]; std::string rhsString = rhs["Name"]; - std::transform(lhsString.begin(), lhsString.end(), lhsString.begin(), - [](unsigned char c) { return std::tolower(c); }); - std::transform(rhsString.begin(), rhsString.end(), rhsString.begin(), - [](unsigned char c) { return std::tolower(c); }); + std::transform( + lhsString.begin(), + lhsString.end(), + lhsString.begin(), + [](unsigned char c) { return std::tolower(c); } + ); + std::transform( + rhsString.begin(), + rhsString.end(), + rhsString.begin(), + [](unsigned char c) { return std::tolower(c); } + ); + return rhsString > lhsString; }); } diff --git a/src/scene/scenelicensewriter.cpp b/src/scene/scenelicensewriter.cpp index 27706a62ad..b97c5f6113 100644 --- a/src/scene/scenelicensewriter.cpp +++ b/src/scene/scenelicensewriter.cpp @@ -47,14 +47,25 @@ SceneLicenseWriter::SceneLicenseWriter() {} void sortJson(nlohmann::json& json) { - std::sort(json.begin(), json.end(), [] - (const nlohmann::json& lhs, const nlohmann::json& rhs) { + std::sort( + json.begin(), + json.end(), + [](const nlohmann::json& lhs, const nlohmann::json& rhs) { std::string lhsString = lhs["Name"]; std::string rhsString = rhs["Name"]; - std::transform(lhsString.begin(), lhsString.end(), lhsString.begin(), - [](unsigned char c) { return std::tolower(c); }); - std::transform(rhsString.begin(), rhsString.end(), rhsString.begin(), - [](unsigned char c) { return std::tolower(c); }); + std::transform( + lhsString.begin(), + lhsString.end(), + lhsString.begin(), + [](unsigned char c) { return std::tolower(c); } + ); + std::transform( + rhsString.begin(), + rhsString.end(), + rhsString.begin(), + [](unsigned char c) { return std::tolower(c); } + ); + return rhsString > lhsString; }); } @@ -86,7 +97,7 @@ nlohmann::json SceneLicenseWriter::generateJsonJson() const { metaJson["Url"] = global::profile->meta->url.value_or(""); metaJson["License"] = global::profile->meta->license.value_or(""); metaJson["Type"] = "license"; - json.push_back(metaJson); + json.push_back(std::move(metaJson)); } std::map assetLicenses; @@ -95,7 +106,6 @@ nlohmann::json SceneLicenseWriter::generateJsonJson() const { nlohmann::json assetJson; if (!meta.has_value()) { - assetJson["Name"] = ""; assetJson["Version"] = ""; assetJson["Description"] = ""; @@ -106,27 +116,27 @@ nlohmann::json SceneLicenseWriter::generateJsonJson() const { assetJson["Path"] = asset->path().string(); assetLicenses["No license"].push_back(assetJson); - continue; } + else { + std::string license = meta->license == "" ? "No license" : meta->license; + assetJson["Name"] = meta->name; + assetJson["Version"] = meta->version; + assetJson["Description"] = meta->description; + assetJson["Author"] = meta->author; + assetJson["Url"] = meta->url; + assetJson["License"] = license; + assetJson["Identifiers"] = meta->identifiers; + assetJson["Path"] = asset->path().string(); - std::string license = meta->license == "" ? "No license" : meta->license; - assetJson["Name"] = meta->name; - assetJson["Version"] = meta->version; - assetJson["Description"] = meta->description; - assetJson["Author"] = meta->author; - assetJson["Url"] = meta->url; - assetJson["License"] = license; - assetJson["Identifiers"] = meta->identifiers; - assetJson["Path"] = asset->path().string(); - - assetLicenses[license].push_back(assetJson); + assetLicenses[license].push_back(assetJson); + } } nlohmann::json assetsJson; assetsJson["Name"] = "Assets"; assetsJson["Type"] = "Licenses"; - for (std::pair assetLicense : assetLicenses) { + for (const std::pair& assetLicense : assetLicenses) { nlohmann::json entry; entry["Name"] = assetLicense.first; entry["Assets"] = assetLicense.second; diff --git a/src/scripting/scriptengine.cpp b/src/scripting/scriptengine.cpp index fd29c07b07..c2fc5fb626 100644 --- a/src/scripting/scriptengine.cpp +++ b/src/scripting/scriptengine.cpp @@ -82,14 +82,25 @@ namespace { } void sortJson(nlohmann::json& json) { - std::sort(json.begin(), json.end(), [] - (const nlohmann::json& lhs, const nlohmann::json& rhs) { + std::sort( + json.begin(), + json.end(), + [](const nlohmann::json& lhs, const nlohmann::json& rhs) { std::string lhsString = lhs["Name"]; std::string rhsString = rhs["Name"]; - std::transform(lhsString.begin(), lhsString.end(), lhsString.begin(), - [](unsigned char c) { return std::tolower(c); }); - std::transform(rhsString.begin(), rhsString.end(), rhsString.begin(), - [](unsigned char c) { return std::tolower(c); }); + std::transform( + lhsString.begin(), + lhsString.end(), + lhsString.begin(), + [](unsigned char c) { return std::tolower(c); } + ); + std::transform( + rhsString.begin(), + rhsString.end(), + rhsString.begin(), + [](unsigned char c) { return std::tolower(c); } + ); + return rhsString > lhsString; }); } @@ -476,7 +487,7 @@ nlohmann::json ScriptEngine::generateJsonJson() const { using namespace openspace::scripting; nlohmann::json library; - std::string libraryName = l.name == "" ? "openspace" : "openspace." + l.name; + std::string libraryName = l.name.empty() ? "openspace" : "openspace." + l.name; library["Name"] = libraryName; for (const LuaLibrary::Function& f : l.functions) { diff --git a/src/util/factorymanager.cpp b/src/util/factorymanager.cpp index 7e8c1849bb..2502716654 100644 --- a/src/util/factorymanager.cpp +++ b/src/util/factorymanager.cpp @@ -43,14 +43,25 @@ using namespace openspace; using namespace openspace::documentation; void sortJson(nlohmann::json& json) { - std::sort(json.begin(), json.end(), [] - (const nlohmann::json& lhs, const nlohmann::json& rhs) { + std::sort( + json.begin(), + json.end(), + [](const nlohmann::json& lhs, const nlohmann::json& rhs) { std::string lhsString = lhs["Name"]; std::string rhsString = rhs["Name"]; - std::transform(lhsString.begin(), lhsString.end(), lhsString.begin(), - [](unsigned char c) { return std::tolower(c); }); - std::transform(rhsString.begin(), rhsString.end(), rhsString.begin(), - [](unsigned char c) { return std::tolower(c); }); + std::transform( + lhsString.begin(), + lhsString.end(), + lhsString.begin(), + [](unsigned char c) { return std::tolower(c); } + ); + std::transform( + rhsString.begin(), + rhsString.end(), + rhsString.begin(), + [](unsigned char c) { return std::tolower(c); } + ); + return rhsString > lhsString; }); } @@ -65,7 +76,7 @@ nlohmann::json generateJsonDocumentation(const Documentation& d) { for (const DocumentationEntry& p : d.entries) { nlohmann::json entry; entry["Name"] = p.key; - entry["Optional"] = p.optional ? true : false; + entry["Optional"] = p.optional.value; entry["Type"] = p.verifier->type(); entry["Documentation"] = p.documentation; @@ -176,7 +187,6 @@ std::string FactoryManager::generateJson() const { json["Data"].push_back(factory); } - // I did not check the output of this for correctness ---abock return json.dump(); } @@ -201,7 +211,8 @@ nlohmann::json FactoryManager::generateJsonJson() const { nlohmann::json documentation = generateJsonDocumentation(*factoryDoc); factory["Classes"].push_back(documentation); // Remove documentation from list check at the end if all docs got put in - docs.erase(factoryDoc); } + docs.erase(factoryDoc); + } else { nlohmann::json documentation; documentation["Name"] = factoryInfo.name;