From afcac59c7d04f4337d6b04ebed8cac7e871ccc50 Mon Sep 17 00:00:00 2001 From: rtk0c Date: Fri, 15 Apr 2022 20:30:39 -0700 Subject: Changeset: 7 Work on Material system --- source/RapidJsonHelper.hpp | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'source/RapidJsonHelper.hpp') 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; -- cgit v1.2.3-70-g09d2