Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-1-2-2013-Decompilation
Path: blob/main/RSDKv4/Ini.hpp
817 views
1
#ifndef INI_H
2
#define INI_H
3
4
#include <vector>
5
6
class IniParser
7
{
8
public:
9
enum ItemType {
10
INI_ITEM_STRING,
11
INI_ITEM_INT,
12
INI_ITEM_FLOAT,
13
INI_ITEM_BOOL,
14
INI_ITEM_COMMENT,
15
};
16
17
struct ConfigItem {
18
ConfigItem()
19
{
20
sprintf(section, "%s", "");
21
sprintf(key, "%s", "");
22
sprintf(value, "%s", "");
23
hasSection = false;
24
type = INI_ITEM_STRING;
25
}
26
char section[0x20];
27
bool hasSection = false;
28
char key[0x40];
29
char value[0x100];
30
byte type = INI_ITEM_STRING;
31
};
32
33
IniParser() { items.clear(); }
34
IniParser(const char *filename, bool addPath = true);
35
36
int GetString(const char *section, const char *key, char *dest);
37
int GetInteger(const char *section, const char *key, int *dest);
38
int GetFloat(const char *section, const char *key, float *dest);
39
int GetBool(const char *section, const char *key, bool *dest);
40
int SetString(const char *section, const char *key, char *value);
41
int SetInteger(const char *section, const char *key, int value);
42
int SetFloat(const char *section, const char *key, float value);
43
int SetBool(const char *section, const char *key, bool value);
44
int SetComment(const char *section, const char *key, const char *comment);
45
void Write(const char *filename, bool addPath = true);
46
47
std::vector<ConfigItem> items;
48
};
49
#endif // !INI_H
50
51