summaryrefslogtreecommitdiff
path: root/src/KingSystem/Utils/Byaml/ByamlArrayIter.cpp
diff options
context:
space:
mode:
authorWildex999 <wildex999@gmail.com>2020-11-03 01:35:31 +0100
committerWildex999 <wildex999@gmail.com>2020-11-14 13:07:07 +0100
commit56f9c3ac0c2486c00d031ac1664fec6322a2762e (patch)
tree0e2b3b2605105c8dfcc52c48ca62fe96a057daa1 /src/KingSystem/Utils/Byaml/ByamlArrayIter.cpp
parentc639c70c5b0340136b7625a08d08ed9b7a47f64f (diff)
ksys/utils/byaml: First iteration of implementation.
4 Functions are still not fully matching with their inlined functions, and at least one function is still missing.
Diffstat (limited to 'src/KingSystem/Utils/Byaml/ByamlArrayIter.cpp')
-rw-r--r--src/KingSystem/Utils/Byaml/ByamlArrayIter.cpp29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/KingSystem/Utils/Byaml/ByamlArrayIter.cpp b/src/KingSystem/Utils/Byaml/ByamlArrayIter.cpp
new file mode 100644
index 00000000..fe5db205
--- /dev/null
+++ b/src/KingSystem/Utils/Byaml/ByamlArrayIter.cpp
@@ -0,0 +1,29 @@
+#include "KingSystem/Utils/Byaml/ByamlArrayIter.h"
+#include "KingSystem/Utils/Byaml/Byaml.h"
+#include "KingSystem/Utils/Byaml/ByamlData.h"
+#include "KingSystem/Utils/Byaml/ByamlLocal.h"
+
+namespace al {
+ByamlArrayIter::ByamlArrayIter(const u8* data) {
+ mData = data;
+}
+
+const u32* ByamlArrayIter::getDataTable() const {
+ return reinterpret_cast<const u32*>(&mData[TypeTableOffset + getDataOffset()]);
+}
+
+bool ByamlArrayIter::getDataByIndex(ByamlData* data, s32 index) {
+ if (index < 0) {
+ return false;
+ }
+
+ if (index >= ByamlLocalUtil::getContainerSize(mData)) {
+ return false;
+ }
+
+ data->setType(ByamlType(mData[TypeTableOffset + index]));
+ data->setValue(getDataTable()[index]);
+
+ return true;
+}
+} // namespace al \ No newline at end of file