@@ -86,62 +86,76 @@ class JsonDocument : public Visitable {
86
86
return add ().to <ArrayRef>();
87
87
}
88
88
89
- template <typename TKey>
90
- ArrayRef createNestedArray (TKey* key) {
89
+ // createNestedArray(char*)
90
+ // createNestedArray(const char*)
91
+ // createNestedArray(const __FlashStringHelper*)
92
+ template <typename TChar>
93
+ ArrayRef createNestedArray (TChar* key) {
91
94
return getOrCreate (key).template to <ArrayRef>();
92
95
}
93
96
94
- template <typename TKey>
95
- ArrayRef createNestedArray (const TKey& key) {
97
+ // createNestedArray(const std::string&)
98
+ // createNestedArray(const String&)
99
+ template <typename TString>
100
+ ArrayRef createNestedArray (const TString& key) {
96
101
return getOrCreate (key).template to <ArrayRef>();
97
102
}
98
103
99
104
ObjectRef createNestedObject () {
100
105
return add ().to <ObjectRef>();
101
106
}
102
107
103
- template <typename TKey>
104
- ObjectRef createNestedObject (TKey* key) {
108
+ // createNestedObject(char*)
109
+ // createNestedObject(const char*)
110
+ // createNestedObject(const __FlashStringHelper*)
111
+ template <typename TChar>
112
+ ObjectRef createNestedObject (TChar* key) {
105
113
return getOrCreate (key).template to <ObjectRef>();
106
114
}
107
115
108
- template <typename TKey>
109
- ObjectRef createNestedObject (const TKey& key) {
116
+ // createNestedObject(const std::string&)
117
+ // createNestedObject(const String&)
118
+ template <typename TString>
119
+ ObjectRef createNestedObject (const TString& key) {
110
120
return getOrCreate (key).template to <ObjectRef>();
111
121
}
112
122
113
- // MemberProxy operator[](TKey )
114
- // TKey = const std::string&, const String&
115
- template <typename TKey >
123
+ // operator[](const std::string& )
124
+ // operator[]( const String&)
125
+ template <typename TString >
116
126
FORCE_INLINE
117
- typename enable_if<IsString<TKey>::value,
118
- MemberProxy<JsonDocument&, const TKey&> >::type
119
- operator [](const TKey& key) {
120
- return MemberProxy<JsonDocument&, const TKey&>(*this , key);
121
- }
122
-
123
- // MemberProxy operator[](TKey);
124
- // TKey = const char*, const char[N], const __FlashStringHelper*
125
- template <typename TKey>
126
- FORCE_INLINE typename enable_if<IsString<TKey*>::value,
127
- MemberProxy<JsonDocument&, TKey*> >::type
128
- operator [](TKey* key) {
129
- return MemberProxy<JsonDocument&, TKey*>(*this , key);
130
- }
131
-
132
- // VariantConstRef operator[](TKey) const
133
- // TKey = const std::string&, const String&
134
- template <typename TKey>
135
- FORCE_INLINE typename enable_if<IsString<TKey>::value, VariantConstRef>::type
136
- operator [](const TKey& key) const {
127
+ typename enable_if<IsString<TString>::value,
128
+ MemberProxy<JsonDocument&, const TString&> >::type
129
+ operator [](const TString& key) {
130
+ return MemberProxy<JsonDocument&, const TString&>(*this , key);
131
+ }
132
+
133
+ // operator[](char*)
134
+ // operator[](const char*)
135
+ // operator[](const __FlashStringHelper*)
136
+ template <typename TChar>
137
+ FORCE_INLINE typename enable_if<IsString<TChar*>::value,
138
+ MemberProxy<JsonDocument&, TChar*> >::type
139
+ operator [](TChar* key) {
140
+ return MemberProxy<JsonDocument&, TChar*>(*this , key);
141
+ }
142
+
143
+ // operator[](const std::string&) const
144
+ // operator[](const String&) const
145
+ template <typename TString>
146
+ FORCE_INLINE
147
+ typename enable_if<IsString<TString>::value, VariantConstRef>::type
148
+ operator [](const TString& key) const {
137
149
return getVariant ()[key];
138
150
}
139
151
140
- // VariantConstRef operator[](TKey) const;
141
- // TKey = const char*, const char[N], const __FlashStringHelper*
142
- template <typename TKey>
143
- FORCE_INLINE typename enable_if<IsString<TKey*>::value, VariantConstRef>::type
144
- operator [](TKey* key) const {
152
+ // operator[](char*) const
153
+ // operator[](const char*) const
154
+ // operator[](const __FlashStringHelper*) const
155
+ template <typename TChar>
156
+ FORCE_INLINE
157
+ typename enable_if<IsString<TChar*>::value, VariantConstRef>::type
158
+ operator [](TChar* key) const {
145
159
return getVariant ()[key];
146
160
}
147
161
@@ -157,43 +171,51 @@ class JsonDocument : public Visitable {
157
171
return VariantRef (&_pool, _data.get (index));
158
172
}
159
173
160
- template <typename TKey>
161
- FORCE_INLINE VariantRef get (TKey* key) {
162
- return VariantRef (&_pool, _data.get (wrapString (key)));
174
+ // get(char*) const
175
+ // get(const char*) const
176
+ // get(const __FlashStringHelper*) const
177
+ template <typename TChar>
178
+ FORCE_INLINE VariantRef get (TChar* key) {
179
+ return VariantRef (&_pool, _data.get (adaptString (key)));
163
180
}
164
181
165
- template <typename TKey>
166
- FORCE_INLINE typename enable_if<IsString<TKey>::value, VariantRef>::type get (
167
- const TKey& key) {
168
- return VariantRef (&_pool, _data.get (wrapString (key)));
182
+ // get(const std::string&) const
183
+ // get(const String&) const
184
+ template <typename TString>
185
+ FORCE_INLINE typename enable_if<IsString<TString>::value, VariantRef>::type
186
+ get (const TString& key) {
187
+ return VariantRef (&_pool, _data.get (adaptString (key)));
169
188
}
170
189
171
- template <typename TKey>
172
- FORCE_INLINE VariantRef getOrCreate (TKey* key) {
173
- return VariantRef (&_pool, _data.getOrCreate (wrapString (key), &_pool));
190
+ // getOrCreate(char*)
191
+ // getOrCreate(const char*)
192
+ // getOrCreate(const __FlashStringHelper*)
193
+ template <typename TChar>
194
+ FORCE_INLINE VariantRef getOrCreate (TChar* key) {
195
+ return VariantRef (&_pool, _data.getOrCreate (adaptString (key), &_pool));
174
196
}
175
197
176
- template <typename TKey>
177
- FORCE_INLINE VariantRef getOrCreate (const TKey& key) {
178
- return VariantRef (&_pool, _data.getOrCreate (wrapString (key), &_pool));
198
+ // getOrCreate(const std::string&)
199
+ // getOrCreate(const String&)
200
+ template <typename TString>
201
+ FORCE_INLINE VariantRef getOrCreate (const TString& key) {
202
+ return VariantRef (&_pool, _data.getOrCreate (adaptString (key), &_pool));
179
203
}
180
204
181
205
FORCE_INLINE VariantRef add () {
182
206
return VariantRef (&_pool, _data.add (&_pool));
183
207
}
184
- //
185
- // bool add(TValue);
186
- // TValue = bool, long, int, short, float, double, serialized, VariantRef,
187
- // std::string, String, ObjectRef
188
- template <typename T>
189
- FORCE_INLINE bool add (const T& value) {
208
+
209
+ template <typename TValue>
210
+ FORCE_INLINE bool add (const TValue& value) {
190
211
return add ().set (value);
191
212
}
192
- //
193
- // bool add(TValue);
194
- // TValue = char*, const char*, const __FlashStringHelper*
195
- template <typename T>
196
- FORCE_INLINE bool add (T* value) {
213
+
214
+ // add(char*) const
215
+ // add(const char*) const
216
+ // add(const __FlashStringHelper*) const
217
+ template <typename TChar>
218
+ FORCE_INLINE bool add (TChar* value) {
197
219
return add ().set (value);
198
220
}
199
221
0 commit comments