-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.hh
41 lines (37 loc) · 1.21 KB
/
config.hh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#ifndef CONFIG_HH
#define CONFIG_HH
#if NO_LUA
#error "config.hh doesn't function without Lua"
#endif
#include "teg.hh"
namespace Config {
enum Type {
String, Int32, Unsigned_Int32, Float, Double, Bool
};
struct Element {
private:
Element() {}
public:
/* name ought to be a valid Lua identifier */
inline Element(const char* name, std::string& ref)
: name(name), type(String), ptr((void*)&ref) {}
inline Element(const char* name, int32_t& ref)
: name(name), type(Int32), ptr((void*)&ref) {}
inline Element(const char* name, uint32_t& ref)
: name(name), type(Unsigned_Int32), ptr((void*)&ref) {}
inline Element(const char* name, float& ref)
: name(name), type(Float), ptr((void*)&ref) {}
inline Element(const char* name, double& ref)
: name(name), type(Double), ptr((void*)&ref) {}
inline Element(const char* name, bool& ref)
: name(name), type(Bool), ptr((void*)&ref) {}
const char* name;
Type type;
void* ptr;
};
extern void Read(const char* filename,
const Element* elements, size_t num_elements);
extern void Write(const char* filename,
const Element* elements, size_t num_elements);
}
#endif