api: Fix various crashes on bad settings data. (#186)

getSetting now returns a straight nlohmann::json instead of an optional.
If the data isn't present, it will return a json null.

All accesses to the settings will first check that the data has the
expected type.
This commit is contained in:
Robin Lambertz
2021-03-06 12:40:29 +01:00
committed by GitHub
parent 32cfaac1e2
commit 4f98149fa7
6 changed files with 11 additions and 11 deletions

View File

@@ -51,7 +51,7 @@ namespace hex {
static std::vector<std::string> read(std::string_view unlocalizedCategory, std::string_view unlocalizedName, const std::vector<std::string>& defaultValue = { });
static std::map<std::string, std::vector<Entry>>& getEntries();
static std::optional<nlohmann::json> getSetting(std::string_view unlocalizedCategory, std::string_view unlocalizedName);
static nlohmann::json getSetting(std::string_view unlocalizedCategory, std::string_view unlocalizedName);
static nlohmann::json& getSettingsData();
};