diff options
author | hnOsmium0001 <[email protected]> | 2022-04-15 20:30:39 -0700 |
---|---|---|
committer | hnOsmium0001 <[email protected]> | 2022-04-15 20:30:39 -0700 |
commit | 509201784d6525fc26345e55a56ab81e4a7616b3 (patch) | |
tree | bcd68f247937324d06480b58a284b47e1c6bb2b8 /source/RapidJsonHelper.hpp | |
parent | 989f90ebe2c37e8a517691a35d7e0d827fbe7006 (diff) |
Work on Material system
Diffstat (limited to 'source/RapidJsonHelper.hpp')
-rw-r--r-- | source/RapidJsonHelper.hpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/source/RapidJsonHelper.hpp b/source/RapidJsonHelper.hpp index ac1f664..9dc0701 100644 --- a/source/RapidJsonHelper.hpp +++ b/source/RapidJsonHelper.hpp @@ -31,9 +31,20 @@ namespace rapidjson { +inline const Value* GetProperty(const Value& value, std::string_view name) { + for (auto it = value.MemberBegin(); it != value.MemberEnd(); ++it) { + if (it->name.GetStringLength() != name.size()) continue; + if (std::memcmp(it->name.GetString(), name.data(), name.size())) continue; + + return &it->value; + } + return nullptr; +} + inline const Value* GetProperty(const Value& value, Type type, std::string_view name) { for (auto it = value.MemberBegin(); it != value.MemberEnd(); ++it) { if (it->name.GetStringLength() != name.size()) continue; + if (it->value.GetType() != type) continue; if (std::memcmp(it->name.GetString(), name.data(), name.size())) continue; return &it->value; |