5
5
#ifndef _ConfigTool_h
6
6
#define _ConfigTool_h
7
7
8
- #include < Arduino.h>
9
8
#include < map>
10
9
#include < ArduinoJson.h>
11
10
12
11
13
12
struct BaseVar {
14
13
String name;
15
- virtual void serialize (JsonDocument) = 0;
16
- virtual void deserialize (JsonDocument) = 0;
14
+ virtual void serialize (JsonDocument* ) = 0;
15
+ virtual void deserialize (JsonDocument* ) = 0;
17
16
virtual void reset () = 0;
18
17
virtual String toString () = 0;
19
18
virtual void fromString (String) = 0;
@@ -23,9 +22,9 @@ template <typename T>
23
22
struct ConfigVar : BaseVar {
24
23
ConfigVar (String n, T* p) {};
25
24
26
- void deserialize (JsonDocument json) {};
25
+ void deserialize (JsonDocument* json) {};
27
26
28
- void serialize (JsonDocument json) {};
27
+ void serialize (JsonDocument* json) {};
29
28
30
29
void reset () {};
31
30
@@ -44,12 +43,12 @@ struct ConfigVar<String> : BaseVar {
44
43
defaultValue = *p;
45
44
};
46
45
47
- void deserialize (JsonDocument json) {
48
- *pointer = String{ json[name] | defaultValue };
46
+ void deserialize (JsonDocument* json) {
47
+ *pointer = String{ (* json) [name] | defaultValue };
49
48
}
50
49
51
- void serialize (JsonDocument json) {
52
- json[name] = *pointer;
50
+ void serialize (JsonDocument* json) {
51
+ (* json) [name] = *pointer;
53
52
}
54
53
55
54
void reset () {
@@ -75,14 +74,14 @@ struct ConfigVar<bool> : BaseVar {
75
74
defaultValue = *p;
76
75
};
77
76
78
- void deserialize (JsonDocument json) {
79
- if (!json[name].isNull ()) {
80
- *pointer = json[name];
77
+ void deserialize (JsonDocument* json) {
78
+ if (!(* json) [name].isNull ()) {
79
+ *pointer = (* json) [name];
81
80
}
82
81
}
83
82
84
- void serialize (JsonDocument json) {
85
- json[name] = *pointer;
83
+ void serialize (JsonDocument* json) {
84
+ (* json) [name] = *pointer;
86
85
}
87
86
88
87
void reset () {
@@ -108,14 +107,14 @@ struct ConfigVar<int> : BaseVar {
108
107
defaultValue = *p;
109
108
};
110
109
111
- void deserialize (JsonDocument json) {
112
- if (!json[name].isNull ()) {
113
- *pointer = json[name];
110
+ void deserialize (JsonDocument* json) {
111
+ if (!(* json) [name].isNull ()) {
112
+ *pointer = (* json) [name];
114
113
}
115
114
}
116
115
117
- void serialize (JsonDocument json) {
118
- json[name] = *pointer;
116
+ void serialize (JsonDocument* json) {
117
+ (* json) [name] = *pointer;
119
118
}
120
119
121
120
void reset () {
0 commit comments