Mercurial > hg > orthanc-stone
annotate Resources/CodeGeneration/template.in.h @ 497:d79f78971fae bgo-commands-codegen
Fixed cmake (removed missing useless file)
author | bgo-osimis |
---|---|
date | Sun, 24 Feb 2019 10:11:38 +0100 |
parents | 6405435480ae |
children | baa9e1e932db |
rev | line source |
---|---|
490 | 1 /* |
2 1 2 3 4 5 6 7 | |
3 12345678901234567890123456789012345678901234567890123456789012345678901234567890 | |
495
6405435480ae
Fixed template to add dump capabilities + started work on an integrated TS/WASM test
bgo-osimis
parents:
494
diff
changeset
|
4 |
490 | 5 */ |
6 | |
7 #include <iostream> | |
8 #include <string> | |
9 #include <sstream> | |
10 #include <assert.h> | |
494
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
11 #include <memory> |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
12 #include <optional> |
490 | 13 #include <json/json.h> |
494
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
14 #include <gtest/gtest.h> |
490 | 15 |
494
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
16 //#define STONEGEN_NO_CPP11 1 |
490 | 17 |
494
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
18 #ifdef STONEGEN_NO_CPP11 |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
19 #define StoneSmartPtr std::auto_ptr |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
20 #else |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
21 #define StoneSmartPtr std::unique_ptr |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
22 #endif |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
23 |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
24 namespace {{rootName}} |
490 | 25 { |
494
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
26 /** Throws in case of problem */ |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
27 void _StoneDeserializeValue(int32_t& destValue, const Json::Value& jsonValue) |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
28 { |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
29 destValue = jsonValue.asInt(); |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
30 } |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
31 |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
32 Json::Value _StoneSerializeValue(int32_t value) |
490 | 33 { |
34 Json::Value result(value); | |
35 return result; | |
36 } | |
37 | |
494
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
38 /** Throws in case of problem */ |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
39 void _StoneDeserializeValue(double& destValue, const Json::Value& jsonValue) |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
40 { |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
41 destValue = jsonValue.asDouble(); |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
42 } |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
43 |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
44 Json::Value _StoneSerializeValue(double value) |
490 | 45 { |
46 Json::Value result(value); | |
47 return result; | |
48 } | |
49 | |
494
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
50 /** Throws in case of problem */ |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
51 void _StoneDeserializeValue(bool& destValue, const Json::Value& jsonValue) |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
52 { |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
53 destValue = jsonValue.asBool(); |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
54 } |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
55 |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
56 Json::Value _StoneSerializeValue(bool value) |
490 | 57 { |
58 Json::Value result(value); | |
59 return result; | |
60 } | |
61 | |
494
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
62 /** Throws in case of problem */ |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
63 void _StoneDeserializeValue( |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
64 std::string& destValue |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
65 , const Json::Value& jsonValue) |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
66 { |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
67 destValue = jsonValue.asString(); |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
68 } |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
69 |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
70 Json::Value _StoneSerializeValue(const std::string& value) |
490 | 71 { |
72 // the following is better than | |
73 Json::Value result(value.data(),value.data()+value.size()); | |
74 return result; | |
75 } | |
495
6405435480ae
Fixed template to add dump capabilities + started work on an integrated TS/WASM test
bgo-osimis
parents:
494
diff
changeset
|
76 |
6405435480ae
Fixed template to add dump capabilities + started work on an integrated TS/WASM test
bgo-osimis
parents:
494
diff
changeset
|
77 std::string MakeIndent(int indent) |
6405435480ae
Fixed template to add dump capabilities + started work on an integrated TS/WASM test
bgo-osimis
parents:
494
diff
changeset
|
78 { |
6405435480ae
Fixed template to add dump capabilities + started work on an integrated TS/WASM test
bgo-osimis
parents:
494
diff
changeset
|
79 char* txt = reinterpret_cast<char*>(malloc(indent+1)); // NO EXCEPTION BELOW!!!!!!!!!!!! |
6405435480ae
Fixed template to add dump capabilities + started work on an integrated TS/WASM test
bgo-osimis
parents:
494
diff
changeset
|
80 for(size_t i = 0; i < indent; ++i) |
6405435480ae
Fixed template to add dump capabilities + started work on an integrated TS/WASM test
bgo-osimis
parents:
494
diff
changeset
|
81 txt[i] = ' '; |
6405435480ae
Fixed template to add dump capabilities + started work on an integrated TS/WASM test
bgo-osimis
parents:
494
diff
changeset
|
82 txt[indent] = 0; |
6405435480ae
Fixed template to add dump capabilities + started work on an integrated TS/WASM test
bgo-osimis
parents:
494
diff
changeset
|
83 std::string retVal(txt); |
6405435480ae
Fixed template to add dump capabilities + started work on an integrated TS/WASM test
bgo-osimis
parents:
494
diff
changeset
|
84 free(txt); // NO EXCEPTION ABOVE !!!!!!!!!! |
6405435480ae
Fixed template to add dump capabilities + started work on an integrated TS/WASM test
bgo-osimis
parents:
494
diff
changeset
|
85 return retVal; |
6405435480ae
Fixed template to add dump capabilities + started work on an integrated TS/WASM test
bgo-osimis
parents:
494
diff
changeset
|
86 } |
6405435480ae
Fixed template to add dump capabilities + started work on an integrated TS/WASM test
bgo-osimis
parents:
494
diff
changeset
|
87 |
6405435480ae
Fixed template to add dump capabilities + started work on an integrated TS/WASM test
bgo-osimis
parents:
494
diff
changeset
|
88 // generic dumper |
6405435480ae
Fixed template to add dump capabilities + started work on an integrated TS/WASM test
bgo-osimis
parents:
494
diff
changeset
|
89 template<typename T> |
6405435480ae
Fixed template to add dump capabilities + started work on an integrated TS/WASM test
bgo-osimis
parents:
494
diff
changeset
|
90 std::ostream& StoneDumpValue(std::ostream& out, const T& value, int indent) |
6405435480ae
Fixed template to add dump capabilities + started work on an integrated TS/WASM test
bgo-osimis
parents:
494
diff
changeset
|
91 { |
6405435480ae
Fixed template to add dump capabilities + started work on an integrated TS/WASM test
bgo-osimis
parents:
494
diff
changeset
|
92 out << MakeIndent(indent) << value; |
6405435480ae
Fixed template to add dump capabilities + started work on an integrated TS/WASM test
bgo-osimis
parents:
494
diff
changeset
|
93 return out; |
6405435480ae
Fixed template to add dump capabilities + started work on an integrated TS/WASM test
bgo-osimis
parents:
494
diff
changeset
|
94 } |
6405435480ae
Fixed template to add dump capabilities + started work on an integrated TS/WASM test
bgo-osimis
parents:
494
diff
changeset
|
95 |
6405435480ae
Fixed template to add dump capabilities + started work on an integrated TS/WASM test
bgo-osimis
parents:
494
diff
changeset
|
96 // string dumper |
6405435480ae
Fixed template to add dump capabilities + started work on an integrated TS/WASM test
bgo-osimis
parents:
494
diff
changeset
|
97 std::ostream& StoneDumpValue(std::ostream& out, const std::string& value, int indent) |
6405435480ae
Fixed template to add dump capabilities + started work on an integrated TS/WASM test
bgo-osimis
parents:
494
diff
changeset
|
98 { |
6405435480ae
Fixed template to add dump capabilities + started work on an integrated TS/WASM test
bgo-osimis
parents:
494
diff
changeset
|
99 out << MakeIndent(indent) << "\"" << value << "\""; |
6405435480ae
Fixed template to add dump capabilities + started work on an integrated TS/WASM test
bgo-osimis
parents:
494
diff
changeset
|
100 return out; |
6405435480ae
Fixed template to add dump capabilities + started work on an integrated TS/WASM test
bgo-osimis
parents:
494
diff
changeset
|
101 } |
6405435480ae
Fixed template to add dump capabilities + started work on an integrated TS/WASM test
bgo-osimis
parents:
494
diff
changeset
|
102 |
494
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
103 /** Throws in case of problem */ |
490 | 104 template<typename T> |
494
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
105 void _StoneDeserializeValue( |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
106 std::map<std::string, T>& destValue, const Json::Value& jsonValue) |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
107 { |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
108 destValue.clear(); |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
109 for ( |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
110 Json::Value::const_iterator itr = jsonValue.begin(); |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
111 itr != jsonValue.end(); |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
112 itr++) |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
113 { |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
114 std::string key; |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
115 _StoneDeserializeValue(key, itr.key()); |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
116 |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
117 T innerDestValue; |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
118 _StoneDeserializeValue(innerDestValue, *itr); |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
119 |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
120 destValue[key] = innerDestValue; |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
121 } |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
122 } |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
123 |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
124 template<typename T> |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
125 Json::Value _StoneSerializeValue(const std::map<std::string,T>& value) |
490 | 126 { |
127 Json::Value result(Json::objectValue); | |
128 | |
129 for (std::map<std::string, T>::const_iterator it = value.cbegin(); | |
130 it != value.cend(); ++it) | |
131 { | |
132 // it->first it->second | |
494
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
133 result[it->first] = _StoneSerializeValue(it->second); |
490 | 134 } |
135 return result; | |
136 } | |
137 | |
495
6405435480ae
Fixed template to add dump capabilities + started work on an integrated TS/WASM test
bgo-osimis
parents:
494
diff
changeset
|
138 template<typename T> |
6405435480ae
Fixed template to add dump capabilities + started work on an integrated TS/WASM test
bgo-osimis
parents:
494
diff
changeset
|
139 std::ostream& StoneDumpValue(std::ostream& out, const std::map<std::string,T>& value, int indent) |
6405435480ae
Fixed template to add dump capabilities + started work on an integrated TS/WASM test
bgo-osimis
parents:
494
diff
changeset
|
140 { |
6405435480ae
Fixed template to add dump capabilities + started work on an integrated TS/WASM test
bgo-osimis
parents:
494
diff
changeset
|
141 out << MakeIndent(indent) << "{\n"; |
6405435480ae
Fixed template to add dump capabilities + started work on an integrated TS/WASM test
bgo-osimis
parents:
494
diff
changeset
|
142 for (std::map<std::string, T>::const_iterator it = value.cbegin(); |
6405435480ae
Fixed template to add dump capabilities + started work on an integrated TS/WASM test
bgo-osimis
parents:
494
diff
changeset
|
143 it != value.cend(); ++it) |
6405435480ae
Fixed template to add dump capabilities + started work on an integrated TS/WASM test
bgo-osimis
parents:
494
diff
changeset
|
144 { |
6405435480ae
Fixed template to add dump capabilities + started work on an integrated TS/WASM test
bgo-osimis
parents:
494
diff
changeset
|
145 out << MakeIndent(indent+2) << "\"" << it->first << "\" : "; |
6405435480ae
Fixed template to add dump capabilities + started work on an integrated TS/WASM test
bgo-osimis
parents:
494
diff
changeset
|
146 StoneDumpValue(out, it->second, indent+2); |
6405435480ae
Fixed template to add dump capabilities + started work on an integrated TS/WASM test
bgo-osimis
parents:
494
diff
changeset
|
147 } |
6405435480ae
Fixed template to add dump capabilities + started work on an integrated TS/WASM test
bgo-osimis
parents:
494
diff
changeset
|
148 out << MakeIndent(indent) << "}\n"; |
6405435480ae
Fixed template to add dump capabilities + started work on an integrated TS/WASM test
bgo-osimis
parents:
494
diff
changeset
|
149 return out; |
6405435480ae
Fixed template to add dump capabilities + started work on an integrated TS/WASM test
bgo-osimis
parents:
494
diff
changeset
|
150 } |
6405435480ae
Fixed template to add dump capabilities + started work on an integrated TS/WASM test
bgo-osimis
parents:
494
diff
changeset
|
151 |
494
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
152 /** Throws in case of problem */ |
490 | 153 template<typename T> |
494
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
154 void _StoneDeserializeValue( |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
155 std::vector<T>& destValue, const Json::Value& jsonValue) |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
156 { |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
157 destValue.clear(); |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
158 destValue.reserve(jsonValue.size()); |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
159 for (Json::Value::ArrayIndex i = 0; i != jsonValue.size(); i++) |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
160 { |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
161 T innerDestValue; |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
162 _StoneDeserializeValue(innerDestValue, jsonValue[i]); |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
163 destValue.push_back(innerDestValue); |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
164 } |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
165 } |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
166 |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
167 template<typename T> |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
168 Json::Value _StoneSerializeValue(const std::vector<T>& value) |
490 | 169 { |
170 Json::Value result(Json::arrayValue); | |
171 for (size_t i = 0; i < value.size(); ++i) | |
172 { | |
494
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
173 result.append(_StoneSerializeValue(value[i])); |
490 | 174 } |
175 return result; | |
176 } | |
177 | |
495
6405435480ae
Fixed template to add dump capabilities + started work on an integrated TS/WASM test
bgo-osimis
parents:
494
diff
changeset
|
178 template<typename T> |
6405435480ae
Fixed template to add dump capabilities + started work on an integrated TS/WASM test
bgo-osimis
parents:
494
diff
changeset
|
179 std::ostream& StoneDumpValue(std::ostream& out, const std::vector<T>& value, int indent) |
6405435480ae
Fixed template to add dump capabilities + started work on an integrated TS/WASM test
bgo-osimis
parents:
494
diff
changeset
|
180 { |
6405435480ae
Fixed template to add dump capabilities + started work on an integrated TS/WASM test
bgo-osimis
parents:
494
diff
changeset
|
181 out << MakeIndent(indent) << "[\n"; |
6405435480ae
Fixed template to add dump capabilities + started work on an integrated TS/WASM test
bgo-osimis
parents:
494
diff
changeset
|
182 for (size_t i = 0; i < value.size(); ++i) |
6405435480ae
Fixed template to add dump capabilities + started work on an integrated TS/WASM test
bgo-osimis
parents:
494
diff
changeset
|
183 { |
6405435480ae
Fixed template to add dump capabilities + started work on an integrated TS/WASM test
bgo-osimis
parents:
494
diff
changeset
|
184 StoneDumpValue(out, value[i], indent+2); |
6405435480ae
Fixed template to add dump capabilities + started work on an integrated TS/WASM test
bgo-osimis
parents:
494
diff
changeset
|
185 } |
6405435480ae
Fixed template to add dump capabilities + started work on an integrated TS/WASM test
bgo-osimis
parents:
494
diff
changeset
|
186 out << MakeIndent(indent) << "]\n"; |
6405435480ae
Fixed template to add dump capabilities + started work on an integrated TS/WASM test
bgo-osimis
parents:
494
diff
changeset
|
187 return out; |
6405435480ae
Fixed template to add dump capabilities + started work on an integrated TS/WASM test
bgo-osimis
parents:
494
diff
changeset
|
188 } |
6405435480ae
Fixed template to add dump capabilities + started work on an integrated TS/WASM test
bgo-osimis
parents:
494
diff
changeset
|
189 |
494
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
190 void StoneCheckSerializedValueTypeGeneric(const Json::Value& value) |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
191 { |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
192 if ((!value.isMember("type")) || (!value["type"].isString())) |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
193 { |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
194 std::stringstream ss; |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
195 ss << "Cannot deserialize value ('type' key invalid)"; |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
196 throw std::runtime_error(ss.str()); |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
197 } |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
198 } |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
199 |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
200 void StoneCheckSerializedValueType( |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
201 const Json::Value& value, std::string typeStr) |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
202 { |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
203 StoneCheckSerializedValueTypeGeneric(value); |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
204 |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
205 std::string actTypeStr = value["type"].asString(); |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
206 if (actTypeStr != typeStr) |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
207 { |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
208 std::stringstream ss; |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
209 ss << "Cannot deserialize type" << actTypeStr |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
210 << "into " << typeStr; |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
211 throw std::runtime_error(ss.str()); |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
212 } |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
213 } |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
214 |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
215 // end of generic methods |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
216 |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
217 // end of generic methods |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
218 {% for enum in enums%} |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
219 enum {{enum['name']}} { |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
220 {% for key in enum['fields']%} {{key}}, |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
221 {%endfor%} }; |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
222 |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
223 void _StoneDeserializeValue( |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
224 {{enum['name']}}& destValue, const Json::Value& jsonValue) |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
225 { |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
226 destValue = static_cast<{{enum['name']}}>(jsonValue.asInt64()); |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
227 } |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
228 |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
229 Json::Value _StoneSerializeValue(const {{enum['name']}}& value) |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
230 { |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
231 return Json::Value(static_cast<int64_t>(value)); |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
232 } |
495
6405435480ae
Fixed template to add dump capabilities + started work on an integrated TS/WASM test
bgo-osimis
parents:
494
diff
changeset
|
233 |
6405435480ae
Fixed template to add dump capabilities + started work on an integrated TS/WASM test
bgo-osimis
parents:
494
diff
changeset
|
234 std::ostream& StoneDumpValue(std::ostream& out, const {{enum['name']}}& value, int indent = 0) |
6405435480ae
Fixed template to add dump capabilities + started work on an integrated TS/WASM test
bgo-osimis
parents:
494
diff
changeset
|
235 { |
6405435480ae
Fixed template to add dump capabilities + started work on an integrated TS/WASM test
bgo-osimis
parents:
494
diff
changeset
|
236 {% for key in enum['fields']%} if( value == {{key}}) |
6405435480ae
Fixed template to add dump capabilities + started work on an integrated TS/WASM test
bgo-osimis
parents:
494
diff
changeset
|
237 { |
6405435480ae
Fixed template to add dump capabilities + started work on an integrated TS/WASM test
bgo-osimis
parents:
494
diff
changeset
|
238 out << MakeIndent(indent) << "{{key}}" << std::endl; |
6405435480ae
Fixed template to add dump capabilities + started work on an integrated TS/WASM test
bgo-osimis
parents:
494
diff
changeset
|
239 } |
6405435480ae
Fixed template to add dump capabilities + started work on an integrated TS/WASM test
bgo-osimis
parents:
494
diff
changeset
|
240 {%endfor%} return out; |
6405435480ae
Fixed template to add dump capabilities + started work on an integrated TS/WASM test
bgo-osimis
parents:
494
diff
changeset
|
241 } |
6405435480ae
Fixed template to add dump capabilities + started work on an integrated TS/WASM test
bgo-osimis
parents:
494
diff
changeset
|
242 |
494
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
243 {%endfor%} |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
244 {% for struct in structs%} |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
245 #ifdef _MSC_VER |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
246 #pragma region {{struct['name']}} |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
247 #endif //_MSC_VER |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
248 |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
249 struct {{struct['name']}} |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
250 { |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
251 {% for key in struct['fields']%} {{CanonToCpp(struct['fields'][key])}} {{key}}; |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
252 {% endfor %} |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
253 {{struct['name']}}() |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
254 { |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
255 {% for key in struct['fields']%} {{key}} = {{CanonToCpp(struct['fields'][key])}}(); |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
256 {% endfor %} |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
257 } |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
258 }; |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
259 |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
260 void _StoneDeserializeValue({{struct['name']}}& destValue, const Json::Value& value) |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
261 { |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
262 {% for key in struct['fields']%} _StoneDeserializeValue(destValue.{{key}}, value["{{key}}"]); |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
263 {% endfor %} |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
264 } |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
265 |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
266 Json::Value _StoneSerializeValue(const {{struct['name']}}& value) |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
267 { |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
268 Json::Value result(Json::objectValue); |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
269 {% for key in struct['fields']%} result["{{key}}"] = _StoneSerializeValue(value.{{key}}); |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
270 {% endfor %} |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
271 return result; |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
272 } |
490 | 273 |
495
6405435480ae
Fixed template to add dump capabilities + started work on an integrated TS/WASM test
bgo-osimis
parents:
494
diff
changeset
|
274 std::ostream& StoneDumpValue(std::ostream& out, const {{struct['name']}}& value, int indent = 0) |
6405435480ae
Fixed template to add dump capabilities + started work on an integrated TS/WASM test
bgo-osimis
parents:
494
diff
changeset
|
275 { |
6405435480ae
Fixed template to add dump capabilities + started work on an integrated TS/WASM test
bgo-osimis
parents:
494
diff
changeset
|
276 out << MakeIndent(indent) << "{\n"; |
6405435480ae
Fixed template to add dump capabilities + started work on an integrated TS/WASM test
bgo-osimis
parents:
494
diff
changeset
|
277 {% for key in struct['fields']%} out << MakeIndent(indent) << "{{key}}:\n"; |
6405435480ae
Fixed template to add dump capabilities + started work on an integrated TS/WASM test
bgo-osimis
parents:
494
diff
changeset
|
278 StoneDumpValue(out, value.{{key}},indent+2); |
6405435480ae
Fixed template to add dump capabilities + started work on an integrated TS/WASM test
bgo-osimis
parents:
494
diff
changeset
|
279 out << "\n"; |
6405435480ae
Fixed template to add dump capabilities + started work on an integrated TS/WASM test
bgo-osimis
parents:
494
diff
changeset
|
280 {% endfor %} |
6405435480ae
Fixed template to add dump capabilities + started work on an integrated TS/WASM test
bgo-osimis
parents:
494
diff
changeset
|
281 out << MakeIndent(indent) << "}\n"; |
6405435480ae
Fixed template to add dump capabilities + started work on an integrated TS/WASM test
bgo-osimis
parents:
494
diff
changeset
|
282 return out; |
6405435480ae
Fixed template to add dump capabilities + started work on an integrated TS/WASM test
bgo-osimis
parents:
494
diff
changeset
|
283 } |
6405435480ae
Fixed template to add dump capabilities + started work on an integrated TS/WASM test
bgo-osimis
parents:
494
diff
changeset
|
284 |
494
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
285 void StoneDeserialize({{struct['name']}}& destValue, const Json::Value& value) |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
286 { |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
287 StoneCheckSerializedValueType(value, "{{rootName}}.{{struct['name']}}"); |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
288 _StoneDeserializeValue(destValue, value["value"]); |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
289 } |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
290 |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
291 Json::Value StoneSerialize(const {{struct['name']}}& value) |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
292 { |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
293 Json::Value result(Json::objectValue); |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
294 result["type"] = "{{rootName}}.{{struct['name']}}"; |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
295 result["value"] = _StoneSerializeValue(value); |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
296 return result; |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
297 } |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
298 |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
299 #ifdef _MSC_VER |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
300 #pragma endregion {{struct['name']}} |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
301 #endif //_MSC_VER |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
302 {% endfor %} |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
303 #ifdef _MSC_VER |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
304 #pragma region Dispatching code |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
305 #endif //_MSC_VER |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
306 |
495
6405435480ae
Fixed template to add dump capabilities + started work on an integrated TS/WASM test
bgo-osimis
parents:
494
diff
changeset
|
307 class IHandler |
494
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
308 { |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
309 public: |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
310 {% for struct in structs%} virtual bool Handle(const {{struct['name']}}& value) = 0; |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
311 {% endfor %} }; |
490 | 312 |
494
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
313 /** Service function for StoneDispatchToHandler */ |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
314 bool StoneDispatchJsonToHandler( |
495
6405435480ae
Fixed template to add dump capabilities + started work on an integrated TS/WASM test
bgo-osimis
parents:
494
diff
changeset
|
315 const Json::Value& jsonValue, IHandler* handler) |
494
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
316 { |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
317 StoneCheckSerializedValueTypeGeneric(jsonValue); |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
318 std::string type = jsonValue["type"].asString(); |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
319 if (type == "") |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
320 { |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
321 // this should never ever happen |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
322 throw std::runtime_error("Caught empty type while dispatching"); |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
323 } |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
324 {% for struct in structs%} else if (type == "{{rootName}}.{{struct['name']}}") |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
325 { |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
326 {{struct['name']}} value; |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
327 _StoneDeserializeValue(value, jsonValue["value"]); |
495
6405435480ae
Fixed template to add dump capabilities + started work on an integrated TS/WASM test
bgo-osimis
parents:
494
diff
changeset
|
328 return handler->Handle(value); |
494
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
329 } |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
330 {% endfor %} else |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
331 { |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
332 return false; |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
333 } |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
334 } |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
335 |
495
6405435480ae
Fixed template to add dump capabilities + started work on an integrated TS/WASM test
bgo-osimis
parents:
494
diff
changeset
|
336 /** Takes a serialized type and passes this to the handler */ |
6405435480ae
Fixed template to add dump capabilities + started work on an integrated TS/WASM test
bgo-osimis
parents:
494
diff
changeset
|
337 bool StoneDispatchToHandler(std::string strValue, IHandler* handler) |
494
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
338 { |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
339 Json::Value readValue; |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
340 |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
341 Json::CharReaderBuilder builder; |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
342 Json::CharReader* reader = builder.newCharReader(); |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
343 |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
344 StoneSmartPtr<Json::CharReader> ptr(reader); |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
345 |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
346 std::string errors; |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
347 |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
348 bool ok = reader->parse( |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
349 strValue.c_str(), |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
350 strValue.c_str() + strValue.size(), |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
351 &readValue, |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
352 &errors |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
353 ); |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
354 if (!ok) |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
355 { |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
356 std::stringstream ss; |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
357 ss << "Jsoncpp parsing error: " << errors; |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
358 throw std::runtime_error(ss.str()); |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
359 } |
495
6405435480ae
Fixed template to add dump capabilities + started work on an integrated TS/WASM test
bgo-osimis
parents:
494
diff
changeset
|
360 return StoneDispatchJsonToHandler(readValue, handler); |
494
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
361 } |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
362 |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
363 #ifdef _MSC_VER |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
364 #pragma endregion Dispatching code |
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
490
diff
changeset
|
365 #endif //_MSC_VER |
490 | 366 } |