comparison Resources/CodeGeneration/template.in.h.j2 @ 543:75664eeacae5 dev

added sets in code generation (not tested yet in TS)
author Alain Mazy <alain@mazy.be>
date Wed, 20 Mar 2019 15:27:04 +0100
parents 9e241cef32a4
children 8432926e9db9
comparison
equal deleted inserted replaced
541:b336dfa71f12 543:75664eeacae5
11 #include <iostream> 11 #include <iostream>
12 #include <string> 12 #include <string>
13 #include <sstream> 13 #include <sstream>
14 #include <assert.h> 14 #include <assert.h>
15 #include <memory> 15 #include <memory>
16 #include <set>
16 #include <json/json.h> 17 #include <json/json.h>
17 18
18 //#define STONEGEN_NO_CPP11 1 19 //#define STONEGEN_NO_CPP11 1
19 20
20 #ifdef STONEGEN_NO_CPP11 21 #ifdef STONEGEN_NO_CPP11
197 } 198 }
198 out << MakeIndent(indent) << "]\n"; 199 out << MakeIndent(indent) << "]\n";
199 return out; 200 return out;
200 } 201 }
201 202
203 /** Throws in case of problem */
204 template<typename T>
205 void _StoneDeserializeValue(
206 std::set<T>& destValue, const Json::Value& jsonValue)
207 {
208 destValue.clear();
209 for (Json::Value::ArrayIndex i = 0; i != jsonValue.size(); i++)
210 {
211 T innerDestValue;
212 _StoneDeserializeValue(innerDestValue, jsonValue[i]);
213 destValue.insert(innerDestValue);
214 }
215 }
216
217 template<typename T>
218 Json::Value _StoneSerializeValue(const std::set<T>& value)
219 {
220 Json::Value result(Json::arrayValue);
221 for (typename std::set<T>::const_iterator it = value.begin(); it != value.end(); ++it)
222 {
223 result.append(_StoneSerializeValue(*it));
224 }
225 return result;
226 }
227
228 template<typename T>
229 std::ostream& StoneDumpValue(std::ostream& out, const std::set<T>& value, size_t indent)
230 {
231 out << MakeIndent(indent) << "[\n";
232 for (typename std::set<T>::const_iterator it = value.begin(); it != value.end(); ++it)
233 {
234 StoneDumpValue(out, *it, indent+2);
235 }
236 out << MakeIndent(indent) << "]\n";
237 return out;
238 }
239
202 inline void StoneCheckSerializedValueTypeGeneric(const Json::Value& value) 240 inline void StoneCheckSerializedValueTypeGeneric(const Json::Value& value)
203 { 241 {
204 if ((!value.isMember("type")) || (!value["type"].isString())) 242 if ((!value.isMember("type")) || (!value["type"].isString()))
205 { 243 {
206 std::stringstream ss; 244 std::stringstream ss;