1#pragma once
2
3#include <basis/seadTypes.h>
4
5namespace al {
6class ByamlHashPair;
7
8enum ByamlDataType : const u8 {
9 TYPE_INVALID = 0,
10 TYPE_STRING = 0xA0,
11 TYPE_BINARY = 0xA1,
12 TYPE_ARRAY = 0xC0,
13 TYPE_HASH = 0xC1,
14 TYPE_STRING_TABLE = 0xC2,
15 TYPE_BOOL = 0xD0,
16 TYPE_INT = 0xD1,
17 TYPE_FLOAT = 0xD2,
18 TYPE_UINT = 0xD3,
19 TYPE_LONG = 0xD4,
20 TYPE_ULONG = 0xD5,
21 TYPE_DOUBLE = 0xD6,
22 TYPE_NULL = 0xFF
23};
24
25class ByamlData {
26public:
27 ByamlData();
28
29 void set(const ByamlHashPair* hash_pair, bool isRev);
30 void set(u8 type, u32 value, bool isRev);
31 ByamlDataType getType() const;
32 u32 getValue() const;
33
34 template <typename T = u32>
35 T getValue() const {
36 u32 val = getValue();
37 return *reinterpret_cast<const T*>(&val);
38 }
39
40private:
41 u32 mValue = 0;
42 ByamlDataType mType = ByamlDataType::TYPE_INVALID;
43};
44
45class ByamlHashPair {
46public:
47 s32 getKey(bool isRev) const;
48 ByamlDataType getType() const;
49 s32 getValue(bool isRev) const;
50
51private:
52 const s32 mData = 0;
53 const s32 mValue = 0;
54};
55
56class ByamlHashIter {
57public:
58 ByamlHashIter(const u8* data, bool isRev);
59 ByamlHashIter();
60
61 const ByamlHashPair* findPair(s32 key) const;
62 bool getDataByIndex(ByamlData* data, s32 index) const;
63 bool getDataByKey(ByamlData* data, s32 key) const;
64 const u8* getOffsetData(u32 off) const;
65 const ByamlHashPair* getPairByIndex(s32 index) const;
66 const ByamlHashPair* getPairTable() const;
67 u32 getSize() const;
68
69private:
70 const u8* mData;
71 bool mIsRev;
72};
73
74class ByamlArrayIter {
75public:
76 ByamlArrayIter(const u8* data, bool isRev);
77 ByamlArrayIter();
78
79 bool getDataByIndex(ByamlData* data, s32 index) const;
80 const u32* getDataTable() const;
81 const u8* getOffsetData(u32 off) const;
82 u32 getSize() const;
83 const u8* getTypeTable() const;
84
85private:
86 const u8* mData;
87 bool mIsRev;
88};
89} // namespace al
90