Introduction of new Dictionary class (#1446)

* Adapting to introduction of new Dictionary class in Ghoul
 * Mainly replacing usage of float instead of doubles as expected
 * Adjust to the lack of the hasKeyAndValue function
This commit is contained in:
Alexander Bock
2021-01-02 15:07:11 +01:00
committed by GitHub
parent 7bf7a25401
commit 067c0f4b27
121 changed files with 2299 additions and 2160 deletions
+3 -20
View File
@@ -72,20 +72,9 @@ namespace ghoul {
void to_json(json& j, const Dictionary& dictionary) {
json object;
for (const std::string& key : dictionary.keys()) {
if (dictionary.hasValue<glm::vec4>(key)) {
const glm::vec4 v = dictionary.value<glm::vec4>(key);
object[key] = json::array({ v[0], v[1], v[2], v[3] });
}
else if (dictionary.hasValue<glm::vec3>(key)) {
const glm::vec3 v = dictionary.value<glm::vec3>(key);
object[key] = json::array({ v[0], v[1], v[2] });
}
else if (dictionary.hasValue<glm::vec2>(key)) {
const glm::vec2 v = dictionary.value<glm::vec2>(key);
object[key] = json::array({ v[0], v[1] });
}
else if (dictionary.hasValue<glm::dvec4>(key)) {
for (std::string_view k : dictionary.keys()) {
std::string key = std::string(k);
if (dictionary.hasValue<glm::dvec4>(key)) {
const glm::dvec4 v = dictionary.value<glm::dvec4>(key);
object[key] = json::array({ v[0], v[1], v[2], v[3] });
}
@@ -97,18 +86,12 @@ void to_json(json& j, const Dictionary& dictionary) {
const glm::dvec2 v = dictionary.value<glm::dvec2>(key);
object[key] = json::array({ v[0], v[1] });
}
else if (dictionary.hasValue<float>(key)) {
object[key] = dictionary.value<float>(key);
}
else if (dictionary.hasValue<double>(key)) {
object[key] = dictionary.value<double>(key);
}
else if (dictionary.hasValue<int>(key)) {
object[key] = dictionary.value<int>(key);
}
else if (dictionary.hasValue<unsigned int>(key)) {
object[key] = dictionary.value<unsigned int>(key);
}
else if (dictionary.hasValue<std::string>(key)) {
object[key] = dictionary.value<std::string>(key);
}
+1 -1
View File
@@ -137,7 +137,7 @@ ServerInterface::ServerInterface(const ghoul::Dictionary& config)
if (config.hasValue<ghoul::Dictionary>(key)) {
const ghoul::Dictionary& dict = config.value<ghoul::Dictionary>(key);
std::vector<std::string> v;
for (const std::string& k : dict.keys()) {
for (std::string_view k : dict.keys()) {
v.push_back(dict.value<std::string>(k));
}
list.set(v);