-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathConfig.h
61 lines (48 loc) · 1.25 KB
/
Config.h
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/*
* Config.h
*
* Created on: Jul 12, 2016
* Author: lieven
*/
#ifndef ACTOR_CONFIG_H_
#define ACTOR_CONFIG_H_
#define ARDUINOJSON_USE_LONG_LONG 1
//#define ARDUINOJSON_USE_INT64 1
#include <ArduinoJson.h>
#include <Str.h>
#include <Log.h>
class Config {
void initialize();
void initMagic();
bool checkMagic();
Str _strBuffer;
DynamicJsonBuffer _jsonBuffer;
JsonObject* _root;
Str _nameSpace;
bool _loaded;
JsonObject& nameSpace();
const char* clone(const char* s);
public:
Config();
virtual ~Config();
void clear();
void load();
void save();
void print(Str& str);
void printPretty(Str& str);
bool hasKey(const char* key);
void setNameSpace(const char* ns );
const char* getNameSpace();
void get(const char*, int32_t &, int32_t defaultValue);
void get(const char*, uint32_t &, uint32_t defaultValue);
void get(const char*, Str&, const char* defaultValue);
void get(const char* ,double& ,double defaultValue);
void remove(const char* key);
void set(const char*, uint32_t );
void set(const char*, int32_t );
void set(const char*, Str&);
void set(const char*, double);
void set(const char* key, const char* value);
};
extern Config config;
#endif /* ACTOR_CONFIG_H_ */