mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-24 18:01:56 +00:00
meh
This commit is contained in:
parent
2c393d35f0
commit
98c174edc4
520 changed files with 74815 additions and 58942 deletions
|
@ -14,7 +14,27 @@ picojson::object ToJsonObject(const Common::Vec3& vec)
|
|||
|
||||
void FromJson(const picojson::object& obj, Common::Vec3& vec)
|
||||
{
|
||||
vec.x = ReadNumericOrDefault<float>(obj, "x");
|
||||
vec.y = ReadNumericOrDefault<float>(obj, "y");
|
||||
vec.z = ReadNumericOrDefault<float>(obj, "z");
|
||||
vec.x = ReadNumericFromJson<float>(obj, "x").value_or(0.0f);
|
||||
vec.y = ReadNumericFromJson<float>(obj, "y").value_or(0.0f);
|
||||
vec.z = ReadNumericFromJson<float>(obj, "z").value_or(0.0f);
|
||||
}
|
||||
|
||||
std::optional<std::string> ReadStringFromJson(const picojson::object& obj, const std::string& key)
|
||||
{
|
||||
const auto it = obj.find(key);
|
||||
if (it == obj.end())
|
||||
return std::nullopt;
|
||||
if (!it->second.is<std::string>())
|
||||
return std::nullopt;
|
||||
return it->second.to_str();
|
||||
}
|
||||
|
||||
std::optional<bool> ReadBoolFromJson(const picojson::object& obj, const std::string& key)
|
||||
{
|
||||
const auto it = obj.find(key);
|
||||
if (it == obj.end())
|
||||
return std::nullopt;
|
||||
if (!it->second.is<bool>())
|
||||
return std::nullopt;
|
||||
return it->second.get<bool>();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue