include/mgba-util/configuration.h (view raw)
1/* Copyright (c) 2013-2014 Jeffrey Pfau
2 *
3 * This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6#ifndef CONFIGURATION_H
7#define CONFIGURATION_H
8
9#include <mgba-util/common.h>
10
11CXX_GUARD_START
12
13#include <mgba-util/table.h>
14
15struct VFile;
16
17struct Configuration {
18 struct Table sections;
19 struct Table root;
20};
21
22void ConfigurationInit(struct Configuration*);
23void ConfigurationDeinit(struct Configuration*);
24
25void ConfigurationSetValue(struct Configuration*, const char* section, const char* key, const char* value);
26void ConfigurationSetIntValue(struct Configuration*, const char* section, const char* key, int value);
27void ConfigurationSetUIntValue(struct Configuration*, const char* section, const char* key, unsigned value);
28void ConfigurationSetFloatValue(struct Configuration*, const char* section, const char* key, float value);
29
30bool ConfigurationHasSection(const struct Configuration*, const char* section);
31const char* ConfigurationGetValue(const struct Configuration*, const char* section, const char* key);
32
33void ConfigurationClearValue(struct Configuration*, const char* section, const char* key);
34
35bool ConfigurationRead(struct Configuration*, const char* path);
36bool ConfigurationReadVFile(struct Configuration*, struct VFile* vf);
37bool ConfigurationWrite(const struct Configuration*, const char* path);
38bool ConfigurationWriteSection(const struct Configuration*, const char* path, const char* section);
39
40void ConfigurationEnumerateSections(const struct Configuration* configuration, void (*handler)(const char* sectionName, void* user), void* user);
41void ConfigurationEnumerate(const struct Configuration* configuration, const char* section, void (*handler)(const char* key, const char* value, void* user), void* user);
42
43CXX_GUARD_END
44
45#endif