From ff80573a97387467308c7e6a164a5d743bca02ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o=20Lam?= Date: Sun, 15 Nov 2020 22:55:22 +0100 Subject: [PATCH] ksys/Byaml: Add getter wrappers --- src/KingSystem/Utils/Byaml/Byaml.h | 70 ++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) diff --git a/src/KingSystem/Utils/Byaml/Byaml.h b/src/KingSystem/Utils/Byaml/Byaml.h index 714af5d2..0543ce50 100644 --- a/src/KingSystem/Utils/Byaml/Byaml.h +++ b/src/KingSystem/Utils/Byaml/Byaml.h @@ -88,6 +88,76 @@ public: bool isEqualData(const ByamlIter& other) const; + const char* getStringByIndex(s32 index) const { + const char* value; + if (!tryGetStringByIndex(&value, index)) + return ""; + return value; + } + + const char* getStringByKey(const char* key) const { + const char* value; + if (!tryGetStringByKey(&value, key)) + return ""; + return value; + } + + s32 getIntByIndex(s32 index) const { + s32 value; + if (!tryGetIntByIndex(&value, index)) + return {}; + return value; + } + + s32 getIntByKey(const char* key) const { + s32 value; + if (!tryGetIntByKey(&value, key)) + return {}; + return value; + } + + u32 getUIntByIndex(s32 index) const { + u32 value; + if (!tryGetUIntByIndex(&value, index)) + return {}; + return value; + } + + u32 getUIntByKey(const char* key) const { + u32 value; + if (!tryGetUIntByKey(&value, key)) + return {}; + return value; + } + + f32 getFloatByIndex(s32 index) const { + f32 value; + if (!tryGetFloatByIndex(&value, index)) + return {}; + return value; + } + + f32 getFloatByKey(const char* key) const { + f32 value; + if (!tryGetFloatByKey(&value, key)) + return {}; + return value; + } + + bool getBoolByIndex(s32 index) const { + bool value; + if (!tryGetBoolByIndex(&value, index)) + return {}; + return value; + } + + bool getBoolByKey(const char* key) const { + bool value; + if (!tryGetBoolByKey(&value, key)) + return {}; + return value; + } + private: const u8* mData = nullptr; const u8* mRootNode = nullptr;