comparison Resources/CodeGeneration/template.in.h @ 490:6470248790db bgo-commands-codegen

ongoing codegen work
author bgo-osimis
date Mon, 18 Feb 2019 15:38:05 +0100
parents
children fc17251477d6
comparison
equal deleted inserted replaced
489:f6b7f113cf27 490:6470248790db
1 /*
2 1 2 3 4 5 6 7
3 12345678901234567890123456789012345678901234567890123456789012345678901234567890
4 */
5
6 #include <iostream>
7 #include <string>
8 #include <sstream>
9 #include <assert.h>
10 #include <json/json.h>
11
12
13 namespace VsolStuff
14 {
15 Json::Value StoneSerialize(int32_t value)
16 {
17 Json::Value result(value);
18 return result;
19 }
20
21 Json::Value StoneSerialize(double value)
22 {
23 Json::Value result(value);
24 return result;
25 }
26
27 Json::Value StoneSerialize(bool value)
28 {
29 Json::Value result(value);
30 return result;
31 }
32
33 Json::Value StoneSerialize(const std::string& value)
34 {
35 // the following is better than
36 Json::Value result(value.data(),value.data()+value.size());
37 return result;
38 }
39
40 template<typename T>
41 Json::Value StoneSerialize(const std::map<std::string,T>& value)
42 {
43 Json::Value result(Json::objectValue);
44
45 for (std::map<std::string, T>::const_iterator it = value.cbegin();
46 it != value.cend(); ++it)
47 {
48 // it->first it->second
49 result[it->first] = StoneSerialize(it->second);
50 }
51 return result;
52 }
53
54 template<typename T>
55 Json::Value StoneSerialize(const std::vector<T>& value)
56 {
57 Json::Value result(Json::arrayValue);
58 for (size_t i = 0; i < value.size(); ++i)
59 {
60 result.append(StoneSerialize(value[i]));
61 }
62 return result;
63 }
64
65 %enumerationscpp%
66
67 %structscpp%
68
69 }