mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-04-22 11:18:22 -05:00
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:
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user