Mercurial > hg > orthanc-stone
annotate Resources/CodeGeneration/template.in.h.j2 @ 676:1b47f17863ba am-dev
codegen: using an ordereddict loader instead of sort the keys -> the delcared ordered in the yaml is preserved in the generated code which is more meaningfull than the alphabetical order
author | Alain Mazy <alain@mazy.be> |
---|---|
date | Thu, 16 May 2019 09:49:30 +0200 |
parents | 5dd496343fad |
children | e8b83fe55a33 |
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 |
507 | 5 Generated on {{currentDatetime}} by stonegentool |
6 | |
490 | 7 */ |
507 | 8 #pragma once |
490 | 9 |
507 | 10 #include <exception> |
490 | 11 #include <iostream> |
12 #include <string> | |
13 #include <sstream> | |
14 #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
|
15 #include <memory> |
543
75664eeacae5
added sets in code generation (not tested yet in TS)
Alain Mazy <alain@mazy.be>
parents:
524
diff
changeset
|
16 #include <set> |
490 | 17 #include <json/json.h> |
18 | |
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
|
19 //#define STONEGEN_NO_CPP11 1 |
490 | 20 |
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
|
21 #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
|
22 #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
|
23 #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
|
24 #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
|
25 #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
|
26 |
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 namespace {{rootName}} |
490 | 28 { |
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
|
29 /** Throws in case of problem */ |
507 | 30 inline void _StoneDeserializeValue(int32_t& destValue, const Json::Value& jsonValue) |
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
|
31 { |
628
84af39146e76
CodeGeneration: support default values
Alain Mazy <alain@mazy.be>
parents:
601
diff
changeset
|
32 if (!jsonValue.isNull()) |
84af39146e76
CodeGeneration: support default values
Alain Mazy <alain@mazy.be>
parents:
601
diff
changeset
|
33 { |
84af39146e76
CodeGeneration: support default values
Alain Mazy <alain@mazy.be>
parents:
601
diff
changeset
|
34 destValue = jsonValue.asInt(); |
84af39146e76
CodeGeneration: support default values
Alain Mazy <alain@mazy.be>
parents:
601
diff
changeset
|
35 } |
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
|
36 } |
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
|
37 |
507 | 38 inline Json::Value _StoneSerializeValue(int32_t value) |
490 | 39 { |
40 Json::Value result(value); | |
41 return result; | |
42 } | |
43 | |
601
8432926e9db9
codegen tools: support for int64, uint32, uint64
Alain Mazy <alain@mazy.be>
parents:
543
diff
changeset
|
44 inline void _StoneDeserializeValue(int64_t& destValue, const Json::Value& jsonValue) |
8432926e9db9
codegen tools: support for int64, uint32, uint64
Alain Mazy <alain@mazy.be>
parents:
543
diff
changeset
|
45 { |
628
84af39146e76
CodeGeneration: support default values
Alain Mazy <alain@mazy.be>
parents:
601
diff
changeset
|
46 if (!jsonValue.isNull()) |
84af39146e76
CodeGeneration: support default values
Alain Mazy <alain@mazy.be>
parents:
601
diff
changeset
|
47 { |
84af39146e76
CodeGeneration: support default values
Alain Mazy <alain@mazy.be>
parents:
601
diff
changeset
|
48 destValue = jsonValue.asInt64(); |
84af39146e76
CodeGeneration: support default values
Alain Mazy <alain@mazy.be>
parents:
601
diff
changeset
|
49 } |
601
8432926e9db9
codegen tools: support for int64, uint32, uint64
Alain Mazy <alain@mazy.be>
parents:
543
diff
changeset
|
50 } |
8432926e9db9
codegen tools: support for int64, uint32, uint64
Alain Mazy <alain@mazy.be>
parents:
543
diff
changeset
|
51 |
8432926e9db9
codegen tools: support for int64, uint32, uint64
Alain Mazy <alain@mazy.be>
parents:
543
diff
changeset
|
52 inline Json::Value _StoneSerializeValue(int64_t value) |
8432926e9db9
codegen tools: support for int64, uint32, uint64
Alain Mazy <alain@mazy.be>
parents:
543
diff
changeset
|
53 { |
8432926e9db9
codegen tools: support for int64, uint32, uint64
Alain Mazy <alain@mazy.be>
parents:
543
diff
changeset
|
54 Json::Value result(value); |
8432926e9db9
codegen tools: support for int64, uint32, uint64
Alain Mazy <alain@mazy.be>
parents:
543
diff
changeset
|
55 return result; |
8432926e9db9
codegen tools: support for int64, uint32, uint64
Alain Mazy <alain@mazy.be>
parents:
543
diff
changeset
|
56 } |
8432926e9db9
codegen tools: support for int64, uint32, uint64
Alain Mazy <alain@mazy.be>
parents:
543
diff
changeset
|
57 |
8432926e9db9
codegen tools: support for int64, uint32, uint64
Alain Mazy <alain@mazy.be>
parents:
543
diff
changeset
|
58 inline void _StoneDeserializeValue(uint32_t& destValue, const Json::Value& jsonValue) |
8432926e9db9
codegen tools: support for int64, uint32, uint64
Alain Mazy <alain@mazy.be>
parents:
543
diff
changeset
|
59 { |
628
84af39146e76
CodeGeneration: support default values
Alain Mazy <alain@mazy.be>
parents:
601
diff
changeset
|
60 if (!jsonValue.isNull()) |
84af39146e76
CodeGeneration: support default values
Alain Mazy <alain@mazy.be>
parents:
601
diff
changeset
|
61 { |
84af39146e76
CodeGeneration: support default values
Alain Mazy <alain@mazy.be>
parents:
601
diff
changeset
|
62 destValue = jsonValue.asUInt(); |
84af39146e76
CodeGeneration: support default values
Alain Mazy <alain@mazy.be>
parents:
601
diff
changeset
|
63 } |
601
8432926e9db9
codegen tools: support for int64, uint32, uint64
Alain Mazy <alain@mazy.be>
parents:
543
diff
changeset
|
64 } |
8432926e9db9
codegen tools: support for int64, uint32, uint64
Alain Mazy <alain@mazy.be>
parents:
543
diff
changeset
|
65 |
8432926e9db9
codegen tools: support for int64, uint32, uint64
Alain Mazy <alain@mazy.be>
parents:
543
diff
changeset
|
66 inline Json::Value _StoneSerializeValue(uint32_t value) |
8432926e9db9
codegen tools: support for int64, uint32, uint64
Alain Mazy <alain@mazy.be>
parents:
543
diff
changeset
|
67 { |
8432926e9db9
codegen tools: support for int64, uint32, uint64
Alain Mazy <alain@mazy.be>
parents:
543
diff
changeset
|
68 Json::Value result(value); |
8432926e9db9
codegen tools: support for int64, uint32, uint64
Alain Mazy <alain@mazy.be>
parents:
543
diff
changeset
|
69 return result; |
8432926e9db9
codegen tools: support for int64, uint32, uint64
Alain Mazy <alain@mazy.be>
parents:
543
diff
changeset
|
70 } |
8432926e9db9
codegen tools: support for int64, uint32, uint64
Alain Mazy <alain@mazy.be>
parents:
543
diff
changeset
|
71 |
8432926e9db9
codegen tools: support for int64, uint32, uint64
Alain Mazy <alain@mazy.be>
parents:
543
diff
changeset
|
72 inline void _StoneDeserializeValue(uint64_t& destValue, const Json::Value& jsonValue) |
8432926e9db9
codegen tools: support for int64, uint32, uint64
Alain Mazy <alain@mazy.be>
parents:
543
diff
changeset
|
73 { |
628
84af39146e76
CodeGeneration: support default values
Alain Mazy <alain@mazy.be>
parents:
601
diff
changeset
|
74 if (!jsonValue.isNull()) |
84af39146e76
CodeGeneration: support default values
Alain Mazy <alain@mazy.be>
parents:
601
diff
changeset
|
75 { |
84af39146e76
CodeGeneration: support default values
Alain Mazy <alain@mazy.be>
parents:
601
diff
changeset
|
76 destValue = jsonValue.asUInt64(); |
84af39146e76
CodeGeneration: support default values
Alain Mazy <alain@mazy.be>
parents:
601
diff
changeset
|
77 } |
601
8432926e9db9
codegen tools: support for int64, uint32, uint64
Alain Mazy <alain@mazy.be>
parents:
543
diff
changeset
|
78 } |
8432926e9db9
codegen tools: support for int64, uint32, uint64
Alain Mazy <alain@mazy.be>
parents:
543
diff
changeset
|
79 |
8432926e9db9
codegen tools: support for int64, uint32, uint64
Alain Mazy <alain@mazy.be>
parents:
543
diff
changeset
|
80 inline Json::Value _StoneSerializeValue(uint64_t value) |
8432926e9db9
codegen tools: support for int64, uint32, uint64
Alain Mazy <alain@mazy.be>
parents:
543
diff
changeset
|
81 { |
8432926e9db9
codegen tools: support for int64, uint32, uint64
Alain Mazy <alain@mazy.be>
parents:
543
diff
changeset
|
82 Json::Value result(value); |
8432926e9db9
codegen tools: support for int64, uint32, uint64
Alain Mazy <alain@mazy.be>
parents:
543
diff
changeset
|
83 return result; |
8432926e9db9
codegen tools: support for int64, uint32, uint64
Alain Mazy <alain@mazy.be>
parents:
543
diff
changeset
|
84 } |
8432926e9db9
codegen tools: support for int64, uint32, uint64
Alain Mazy <alain@mazy.be>
parents:
543
diff
changeset
|
85 |
508
7105a0bad250
- Added HandleSerializedMessage to IStoneApplication (empty impl)
Benjamin Golinvaux <bgo@osimis.io>
parents:
507
diff
changeset
|
86 inline void _StoneDeserializeValue(Json::Value& destValue, const Json::Value& jsonValue) |
7105a0bad250
- Added HandleSerializedMessage to IStoneApplication (empty impl)
Benjamin Golinvaux <bgo@osimis.io>
parents:
507
diff
changeset
|
87 { |
7105a0bad250
- Added HandleSerializedMessage to IStoneApplication (empty impl)
Benjamin Golinvaux <bgo@osimis.io>
parents:
507
diff
changeset
|
88 destValue = jsonValue; |
7105a0bad250
- Added HandleSerializedMessage to IStoneApplication (empty impl)
Benjamin Golinvaux <bgo@osimis.io>
parents:
507
diff
changeset
|
89 } |
7105a0bad250
- Added HandleSerializedMessage to IStoneApplication (empty impl)
Benjamin Golinvaux <bgo@osimis.io>
parents:
507
diff
changeset
|
90 |
7105a0bad250
- Added HandleSerializedMessage to IStoneApplication (empty impl)
Benjamin Golinvaux <bgo@osimis.io>
parents:
507
diff
changeset
|
91 inline Json::Value _StoneSerializeValue(Json::Value value) |
7105a0bad250
- Added HandleSerializedMessage to IStoneApplication (empty impl)
Benjamin Golinvaux <bgo@osimis.io>
parents:
507
diff
changeset
|
92 { |
7105a0bad250
- Added HandleSerializedMessage to IStoneApplication (empty impl)
Benjamin Golinvaux <bgo@osimis.io>
parents:
507
diff
changeset
|
93 return value; |
7105a0bad250
- Added HandleSerializedMessage to IStoneApplication (empty impl)
Benjamin Golinvaux <bgo@osimis.io>
parents:
507
diff
changeset
|
94 } |
7105a0bad250
- Added HandleSerializedMessage to IStoneApplication (empty impl)
Benjamin Golinvaux <bgo@osimis.io>
parents:
507
diff
changeset
|
95 |
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
|
96 /** Throws in case of problem */ |
507 | 97 inline void _StoneDeserializeValue(double& destValue, const Json::Value& jsonValue) |
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
|
98 { |
628
84af39146e76
CodeGeneration: support default values
Alain Mazy <alain@mazy.be>
parents:
601
diff
changeset
|
99 if (!jsonValue.isNull()) |
84af39146e76
CodeGeneration: support default values
Alain Mazy <alain@mazy.be>
parents:
601
diff
changeset
|
100 { |
84af39146e76
CodeGeneration: support default values
Alain Mazy <alain@mazy.be>
parents:
601
diff
changeset
|
101 destValue = jsonValue.asDouble(); |
84af39146e76
CodeGeneration: support default values
Alain Mazy <alain@mazy.be>
parents:
601
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 } |
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
|
104 |
507 | 105 inline Json::Value _StoneSerializeValue(double value) |
490 | 106 { |
107 Json::Value result(value); | |
108 return result; | |
109 } | |
110 | |
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
|
111 /** Throws in case of problem */ |
507 | 112 inline void _StoneDeserializeValue(bool& destValue, const Json::Value& jsonValue) |
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
|
113 { |
628
84af39146e76
CodeGeneration: support default values
Alain Mazy <alain@mazy.be>
parents:
601
diff
changeset
|
114 if (!jsonValue.isNull()) |
84af39146e76
CodeGeneration: support default values
Alain Mazy <alain@mazy.be>
parents:
601
diff
changeset
|
115 { |
84af39146e76
CodeGeneration: support default values
Alain Mazy <alain@mazy.be>
parents:
601
diff
changeset
|
116 destValue = jsonValue.asBool(); |
84af39146e76
CodeGeneration: support default values
Alain Mazy <alain@mazy.be>
parents:
601
diff
changeset
|
117 } |
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
|
118 } |
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 |
507 | 120 inline Json::Value _StoneSerializeValue(bool value) |
490 | 121 { |
122 Json::Value result(value); | |
123 return result; | |
124 } | |
125 | |
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
|
126 /** Throws in case of problem */ |
507 | 127 inline void _StoneDeserializeValue( |
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
|
128 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
|
129 , 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
|
130 { |
628
84af39146e76
CodeGeneration: support default values
Alain Mazy <alain@mazy.be>
parents:
601
diff
changeset
|
131 if (!jsonValue.isNull()) |
84af39146e76
CodeGeneration: support default values
Alain Mazy <alain@mazy.be>
parents:
601
diff
changeset
|
132 { |
84af39146e76
CodeGeneration: support default values
Alain Mazy <alain@mazy.be>
parents:
601
diff
changeset
|
133 destValue = jsonValue.asString(); |
84af39146e76
CodeGeneration: support default values
Alain Mazy <alain@mazy.be>
parents:
601
diff
changeset
|
134 } |
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
|
135 } |
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
|
136 |
507 | 137 inline Json::Value _StoneSerializeValue(const std::string& value) |
490 | 138 { |
139 // the following is better than | |
140 Json::Value result(value.data(),value.data()+value.size()); | |
141 return result; | |
142 } | |
495
6405435480ae
Fixed template to add dump capabilities + started work on an integrated TS/WASM test
bgo-osimis
parents:
494
diff
changeset
|
143 |
524 | 144 inline std::string MakeIndent(size_t indent) |
495
6405435480ae
Fixed template to add dump capabilities + started work on an integrated TS/WASM test
bgo-osimis
parents:
494
diff
changeset
|
145 { |
6405435480ae
Fixed template to add dump capabilities + started work on an integrated TS/WASM test
bgo-osimis
parents:
494
diff
changeset
|
146 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
|
147 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
|
148 txt[i] = ' '; |
6405435480ae
Fixed template to add dump capabilities + started work on an integrated TS/WASM test
bgo-osimis
parents:
494
diff
changeset
|
149 txt[indent] = 0; |
6405435480ae
Fixed template to add dump capabilities + started work on an integrated TS/WASM test
bgo-osimis
parents:
494
diff
changeset
|
150 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
|
151 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
|
152 return retVal; |
6405435480ae
Fixed template to add dump capabilities + started work on an integrated TS/WASM test
bgo-osimis
parents:
494
diff
changeset
|
153 } |
6405435480ae
Fixed template to add dump capabilities + started work on an integrated TS/WASM test
bgo-osimis
parents:
494
diff
changeset
|
154 |
6405435480ae
Fixed template to add dump capabilities + started work on an integrated TS/WASM test
bgo-osimis
parents:
494
diff
changeset
|
155 // generic dumper |
6405435480ae
Fixed template to add dump capabilities + started work on an integrated TS/WASM test
bgo-osimis
parents:
494
diff
changeset
|
156 template<typename T> |
524 | 157 std::ostream& StoneDumpValue(std::ostream& out, const T& value, size_t indent) |
495
6405435480ae
Fixed template to add dump capabilities + started work on an integrated TS/WASM test
bgo-osimis
parents:
494
diff
changeset
|
158 { |
6405435480ae
Fixed template to add dump capabilities + started work on an integrated TS/WASM test
bgo-osimis
parents:
494
diff
changeset
|
159 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
|
160 return out; |
6405435480ae
Fixed template to add dump capabilities + started work on an integrated TS/WASM test
bgo-osimis
parents:
494
diff
changeset
|
161 } |
6405435480ae
Fixed template to add dump capabilities + started work on an integrated TS/WASM test
bgo-osimis
parents:
494
diff
changeset
|
162 |
6405435480ae
Fixed template to add dump capabilities + started work on an integrated TS/WASM test
bgo-osimis
parents:
494
diff
changeset
|
163 // string dumper |
524 | 164 inline std::ostream& StoneDumpValue(std::ostream& out, const std::string& value, size_t indent) |
495
6405435480ae
Fixed template to add dump capabilities + started work on an integrated TS/WASM test
bgo-osimis
parents:
494
diff
changeset
|
165 { |
6405435480ae
Fixed template to add dump capabilities + started work on an integrated TS/WASM test
bgo-osimis
parents:
494
diff
changeset
|
166 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
|
167 return out; |
6405435480ae
Fixed template to add dump capabilities + started work on an integrated TS/WASM test
bgo-osimis
parents:
494
diff
changeset
|
168 } |
6405435480ae
Fixed template to add dump capabilities + started work on an integrated TS/WASM test
bgo-osimis
parents:
494
diff
changeset
|
169 |
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
|
170 /** Throws in case of problem */ |
490 | 171 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
|
172 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
|
173 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
|
174 { |
628
84af39146e76
CodeGeneration: support default values
Alain Mazy <alain@mazy.be>
parents:
601
diff
changeset
|
175 if (!jsonValue.isNull()) |
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
|
176 { |
628
84af39146e76
CodeGeneration: support default values
Alain Mazy <alain@mazy.be>
parents:
601
diff
changeset
|
177 destValue.clear(); |
84af39146e76
CodeGeneration: support default values
Alain Mazy <alain@mazy.be>
parents:
601
diff
changeset
|
178 for ( |
84af39146e76
CodeGeneration: support default values
Alain Mazy <alain@mazy.be>
parents:
601
diff
changeset
|
179 Json::Value::const_iterator itr = jsonValue.begin(); |
84af39146e76
CodeGeneration: support default values
Alain Mazy <alain@mazy.be>
parents:
601
diff
changeset
|
180 itr != jsonValue.end(); |
84af39146e76
CodeGeneration: support default values
Alain Mazy <alain@mazy.be>
parents:
601
diff
changeset
|
181 itr++) |
84af39146e76
CodeGeneration: support default values
Alain Mazy <alain@mazy.be>
parents:
601
diff
changeset
|
182 { |
84af39146e76
CodeGeneration: support default values
Alain Mazy <alain@mazy.be>
parents:
601
diff
changeset
|
183 std::string key; |
84af39146e76
CodeGeneration: support default values
Alain Mazy <alain@mazy.be>
parents:
601
diff
changeset
|
184 _StoneDeserializeValue(key, itr.key()); |
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
|
185 |
628
84af39146e76
CodeGeneration: support default values
Alain Mazy <alain@mazy.be>
parents:
601
diff
changeset
|
186 T innerDestValue; |
84af39146e76
CodeGeneration: support default values
Alain Mazy <alain@mazy.be>
parents:
601
diff
changeset
|
187 _StoneDeserializeValue(innerDestValue, *itr); |
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
|
188 |
628
84af39146e76
CodeGeneration: support default values
Alain Mazy <alain@mazy.be>
parents:
601
diff
changeset
|
189 destValue[key] = innerDestValue; |
84af39146e76
CodeGeneration: support default values
Alain Mazy <alain@mazy.be>
parents:
601
diff
changeset
|
190 } |
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
|
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 } |
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 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
|
195 Json::Value _StoneSerializeValue(const std::map<std::string,T>& value) |
490 | 196 { |
197 Json::Value result(Json::objectValue); | |
198 | |
499 | 199 for (typename std::map<std::string, T>::const_iterator it = value.cbegin(); |
490 | 200 it != value.cend(); ++it) |
201 { | |
202 // 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
|
203 result[it->first] = _StoneSerializeValue(it->second); |
490 | 204 } |
205 return result; | |
206 } | |
207 | |
495
6405435480ae
Fixed template to add dump capabilities + started work on an integrated TS/WASM test
bgo-osimis
parents:
494
diff
changeset
|
208 template<typename T> |
524 | 209 std::ostream& StoneDumpValue(std::ostream& out, const std::map<std::string,T>& value, size_t indent) |
495
6405435480ae
Fixed template to add dump capabilities + started work on an integrated TS/WASM test
bgo-osimis
parents:
494
diff
changeset
|
210 { |
6405435480ae
Fixed template to add dump capabilities + started work on an integrated TS/WASM test
bgo-osimis
parents:
494
diff
changeset
|
211 out << MakeIndent(indent) << "{\n"; |
499 | 212 for (typename std::map<std::string, T>::const_iterator it = value.cbegin(); |
495
6405435480ae
Fixed template to add dump capabilities + started work on an integrated TS/WASM test
bgo-osimis
parents:
494
diff
changeset
|
213 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
|
214 { |
6405435480ae
Fixed template to add dump capabilities + started work on an integrated TS/WASM test
bgo-osimis
parents:
494
diff
changeset
|
215 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
|
216 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
|
217 } |
6405435480ae
Fixed template to add dump capabilities + started work on an integrated TS/WASM test
bgo-osimis
parents:
494
diff
changeset
|
218 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
|
219 return out; |
6405435480ae
Fixed template to add dump capabilities + started work on an integrated TS/WASM test
bgo-osimis
parents:
494
diff
changeset
|
220 } |
6405435480ae
Fixed template to add dump capabilities + started work on an integrated TS/WASM test
bgo-osimis
parents:
494
diff
changeset
|
221 |
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
|
222 /** Throws in case of problem */ |
490 | 223 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
|
224 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
|
225 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
|
226 { |
628
84af39146e76
CodeGeneration: support default values
Alain Mazy <alain@mazy.be>
parents:
601
diff
changeset
|
227 if (!jsonValue.isNull()) |
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
|
228 { |
628
84af39146e76
CodeGeneration: support default values
Alain Mazy <alain@mazy.be>
parents:
601
diff
changeset
|
229 destValue.clear(); |
84af39146e76
CodeGeneration: support default values
Alain Mazy <alain@mazy.be>
parents:
601
diff
changeset
|
230 destValue.reserve(jsonValue.size()); |
84af39146e76
CodeGeneration: support default values
Alain Mazy <alain@mazy.be>
parents:
601
diff
changeset
|
231 for (Json::Value::ArrayIndex i = 0; i != jsonValue.size(); i++) |
84af39146e76
CodeGeneration: support default values
Alain Mazy <alain@mazy.be>
parents:
601
diff
changeset
|
232 { |
84af39146e76
CodeGeneration: support default values
Alain Mazy <alain@mazy.be>
parents:
601
diff
changeset
|
233 T innerDestValue; |
84af39146e76
CodeGeneration: support default values
Alain Mazy <alain@mazy.be>
parents:
601
diff
changeset
|
234 _StoneDeserializeValue(innerDestValue, jsonValue[i]); |
84af39146e76
CodeGeneration: support default values
Alain Mazy <alain@mazy.be>
parents:
601
diff
changeset
|
235 destValue.push_back(innerDestValue); |
84af39146e76
CodeGeneration: support default values
Alain Mazy <alain@mazy.be>
parents:
601
diff
changeset
|
236 } |
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
|
237 } |
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
|
238 } |
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
|
239 |
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
|
240 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
|
241 Json::Value _StoneSerializeValue(const std::vector<T>& value) |
490 | 242 { |
243 Json::Value result(Json::arrayValue); | |
244 for (size_t i = 0; i < value.size(); ++i) | |
245 { | |
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
|
246 result.append(_StoneSerializeValue(value[i])); |
490 | 247 } |
248 return result; | |
249 } | |
250 | |
495
6405435480ae
Fixed template to add dump capabilities + started work on an integrated TS/WASM test
bgo-osimis
parents:
494
diff
changeset
|
251 template<typename T> |
524 | 252 std::ostream& StoneDumpValue(std::ostream& out, const std::vector<T>& value, size_t indent) |
495
6405435480ae
Fixed template to add dump capabilities + started work on an integrated TS/WASM test
bgo-osimis
parents:
494
diff
changeset
|
253 { |
6405435480ae
Fixed template to add dump capabilities + started work on an integrated TS/WASM test
bgo-osimis
parents:
494
diff
changeset
|
254 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
|
255 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
|
256 { |
6405435480ae
Fixed template to add dump capabilities + started work on an integrated TS/WASM test
bgo-osimis
parents:
494
diff
changeset
|
257 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
|
258 } |
6405435480ae
Fixed template to add dump capabilities + started work on an integrated TS/WASM test
bgo-osimis
parents:
494
diff
changeset
|
259 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
|
260 return out; |
6405435480ae
Fixed template to add dump capabilities + started work on an integrated TS/WASM test
bgo-osimis
parents:
494
diff
changeset
|
261 } |
6405435480ae
Fixed template to add dump capabilities + started work on an integrated TS/WASM test
bgo-osimis
parents:
494
diff
changeset
|
262 |
543
75664eeacae5
added sets in code generation (not tested yet in TS)
Alain Mazy <alain@mazy.be>
parents:
524
diff
changeset
|
263 /** Throws in case of problem */ |
75664eeacae5
added sets in code generation (not tested yet in TS)
Alain Mazy <alain@mazy.be>
parents:
524
diff
changeset
|
264 template<typename T> |
75664eeacae5
added sets in code generation (not tested yet in TS)
Alain Mazy <alain@mazy.be>
parents:
524
diff
changeset
|
265 void _StoneDeserializeValue( |
75664eeacae5
added sets in code generation (not tested yet in TS)
Alain Mazy <alain@mazy.be>
parents:
524
diff
changeset
|
266 std::set<T>& destValue, const Json::Value& jsonValue) |
75664eeacae5
added sets in code generation (not tested yet in TS)
Alain Mazy <alain@mazy.be>
parents:
524
diff
changeset
|
267 { |
628
84af39146e76
CodeGeneration: support default values
Alain Mazy <alain@mazy.be>
parents:
601
diff
changeset
|
268 if (!jsonValue.isNull()) |
543
75664eeacae5
added sets in code generation (not tested yet in TS)
Alain Mazy <alain@mazy.be>
parents:
524
diff
changeset
|
269 { |
628
84af39146e76
CodeGeneration: support default values
Alain Mazy <alain@mazy.be>
parents:
601
diff
changeset
|
270 destValue.clear(); |
84af39146e76
CodeGeneration: support default values
Alain Mazy <alain@mazy.be>
parents:
601
diff
changeset
|
271 for (Json::Value::ArrayIndex i = 0; i != jsonValue.size(); i++) |
84af39146e76
CodeGeneration: support default values
Alain Mazy <alain@mazy.be>
parents:
601
diff
changeset
|
272 { |
84af39146e76
CodeGeneration: support default values
Alain Mazy <alain@mazy.be>
parents:
601
diff
changeset
|
273 T innerDestValue; |
84af39146e76
CodeGeneration: support default values
Alain Mazy <alain@mazy.be>
parents:
601
diff
changeset
|
274 _StoneDeserializeValue(innerDestValue, jsonValue[i]); |
84af39146e76
CodeGeneration: support default values
Alain Mazy <alain@mazy.be>
parents:
601
diff
changeset
|
275 destValue.insert(innerDestValue); |
84af39146e76
CodeGeneration: support default values
Alain Mazy <alain@mazy.be>
parents:
601
diff
changeset
|
276 } |
543
75664eeacae5
added sets in code generation (not tested yet in TS)
Alain Mazy <alain@mazy.be>
parents:
524
diff
changeset
|
277 } |
75664eeacae5
added sets in code generation (not tested yet in TS)
Alain Mazy <alain@mazy.be>
parents:
524
diff
changeset
|
278 } |
75664eeacae5
added sets in code generation (not tested yet in TS)
Alain Mazy <alain@mazy.be>
parents:
524
diff
changeset
|
279 |
75664eeacae5
added sets in code generation (not tested yet in TS)
Alain Mazy <alain@mazy.be>
parents:
524
diff
changeset
|
280 template<typename T> |
75664eeacae5
added sets in code generation (not tested yet in TS)
Alain Mazy <alain@mazy.be>
parents:
524
diff
changeset
|
281 Json::Value _StoneSerializeValue(const std::set<T>& value) |
75664eeacae5
added sets in code generation (not tested yet in TS)
Alain Mazy <alain@mazy.be>
parents:
524
diff
changeset
|
282 { |
75664eeacae5
added sets in code generation (not tested yet in TS)
Alain Mazy <alain@mazy.be>
parents:
524
diff
changeset
|
283 Json::Value result(Json::arrayValue); |
75664eeacae5
added sets in code generation (not tested yet in TS)
Alain Mazy <alain@mazy.be>
parents:
524
diff
changeset
|
284 for (typename std::set<T>::const_iterator it = value.begin(); it != value.end(); ++it) |
75664eeacae5
added sets in code generation (not tested yet in TS)
Alain Mazy <alain@mazy.be>
parents:
524
diff
changeset
|
285 { |
75664eeacae5
added sets in code generation (not tested yet in TS)
Alain Mazy <alain@mazy.be>
parents:
524
diff
changeset
|
286 result.append(_StoneSerializeValue(*it)); |
75664eeacae5
added sets in code generation (not tested yet in TS)
Alain Mazy <alain@mazy.be>
parents:
524
diff
changeset
|
287 } |
75664eeacae5
added sets in code generation (not tested yet in TS)
Alain Mazy <alain@mazy.be>
parents:
524
diff
changeset
|
288 return result; |
75664eeacae5
added sets in code generation (not tested yet in TS)
Alain Mazy <alain@mazy.be>
parents:
524
diff
changeset
|
289 } |
75664eeacae5
added sets in code generation (not tested yet in TS)
Alain Mazy <alain@mazy.be>
parents:
524
diff
changeset
|
290 |
75664eeacae5
added sets in code generation (not tested yet in TS)
Alain Mazy <alain@mazy.be>
parents:
524
diff
changeset
|
291 template<typename T> |
75664eeacae5
added sets in code generation (not tested yet in TS)
Alain Mazy <alain@mazy.be>
parents:
524
diff
changeset
|
292 std::ostream& StoneDumpValue(std::ostream& out, const std::set<T>& value, size_t indent) |
75664eeacae5
added sets in code generation (not tested yet in TS)
Alain Mazy <alain@mazy.be>
parents:
524
diff
changeset
|
293 { |
75664eeacae5
added sets in code generation (not tested yet in TS)
Alain Mazy <alain@mazy.be>
parents:
524
diff
changeset
|
294 out << MakeIndent(indent) << "[\n"; |
75664eeacae5
added sets in code generation (not tested yet in TS)
Alain Mazy <alain@mazy.be>
parents:
524
diff
changeset
|
295 for (typename std::set<T>::const_iterator it = value.begin(); it != value.end(); ++it) |
75664eeacae5
added sets in code generation (not tested yet in TS)
Alain Mazy <alain@mazy.be>
parents:
524
diff
changeset
|
296 { |
75664eeacae5
added sets in code generation (not tested yet in TS)
Alain Mazy <alain@mazy.be>
parents:
524
diff
changeset
|
297 StoneDumpValue(out, *it, indent+2); |
75664eeacae5
added sets in code generation (not tested yet in TS)
Alain Mazy <alain@mazy.be>
parents:
524
diff
changeset
|
298 } |
75664eeacae5
added sets in code generation (not tested yet in TS)
Alain Mazy <alain@mazy.be>
parents:
524
diff
changeset
|
299 out << MakeIndent(indent) << "]\n"; |
75664eeacae5
added sets in code generation (not tested yet in TS)
Alain Mazy <alain@mazy.be>
parents:
524
diff
changeset
|
300 return out; |
75664eeacae5
added sets in code generation (not tested yet in TS)
Alain Mazy <alain@mazy.be>
parents:
524
diff
changeset
|
301 } |
75664eeacae5
added sets in code generation (not tested yet in TS)
Alain Mazy <alain@mazy.be>
parents:
524
diff
changeset
|
302 |
507 | 303 inline void StoneCheckSerializedValueTypeGeneric(const Json::Value& 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
|
304 { |
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 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
|
306 { |
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
|
307 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
|
308 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
|
309 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
|
310 } |
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 } |
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
|
312 |
507 | 313 inline void StoneCheckSerializedValueType( |
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
|
314 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
|
315 { |
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 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
|
317 |
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 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
|
319 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
|
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 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
|
322 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
|
323 << "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
|
324 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
|
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 } |
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 |
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
|
328 // 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
|
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 // 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
|
331 {% 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
|
332 enum {{enum['name']}} { |
507 | 333 {% for key in enum['fields']%} {{enum['name']}}_{{key}}, |
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
|
334 {%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
|
335 |
507 | 336 inline std::string ToString(const {{enum['name']}}& value) |
337 { | |
338 {% for key in enum['fields']%} if( value == {{enum['name']}}_{{key}}) | |
339 { | |
340 return std::string("{{key}}"); | |
341 } | |
508
7105a0bad250
- Added HandleSerializedMessage to IStoneApplication (empty impl)
Benjamin Golinvaux <bgo@osimis.io>
parents:
507
diff
changeset
|
342 {%endfor%} std::stringstream ss; |
7105a0bad250
- Added HandleSerializedMessage to IStoneApplication (empty impl)
Benjamin Golinvaux <bgo@osimis.io>
parents:
507
diff
changeset
|
343 ss << "Value \"" << value << "\" cannot be converted to {{enum['name']}}. Possible values are: " |
7105a0bad250
- Added HandleSerializedMessage to IStoneApplication (empty impl)
Benjamin Golinvaux <bgo@osimis.io>
parents:
507
diff
changeset
|
344 {% for key in enum['fields']%} << " {{key}} = " << static_cast<int64_t>({{enum['name']}}_{{key}}) << ", " |
7105a0bad250
- Added HandleSerializedMessage to IStoneApplication (empty impl)
Benjamin Golinvaux <bgo@osimis.io>
parents:
507
diff
changeset
|
345 {% endfor %} << std::endl; |
7105a0bad250
- Added HandleSerializedMessage to IStoneApplication (empty impl)
Benjamin Golinvaux <bgo@osimis.io>
parents:
507
diff
changeset
|
346 std::string msg = ss.str(); |
7105a0bad250
- Added HandleSerializedMessage to IStoneApplication (empty impl)
Benjamin Golinvaux <bgo@osimis.io>
parents:
507
diff
changeset
|
347 throw std::runtime_error(msg); |
507 | 348 } |
349 | |
350 inline void FromString({{enum['name']}}& value, std::string strValue) | |
495
6405435480ae
Fixed template to add dump capabilities + started work on an integrated TS/WASM test
bgo-osimis
parents:
494
diff
changeset
|
351 { |
507 | 352 {% for key in enum['fields']%} if( strValue == std::string("{{key}}") ) |
353 { | |
354 value = {{enum['name']}}_{{key}}; | |
519
17106b29ed6d
Changed the metadata system for structs. A __handler entry is now required
Benjamin Golinvaux <bgo@osimis.io>
parents:
515
diff
changeset
|
355 return; |
507 | 356 } |
357 {%endfor%} | |
358 std::stringstream ss; | |
519
17106b29ed6d
Changed the metadata system for structs. A __handler entry is now required
Benjamin Golinvaux <bgo@osimis.io>
parents:
515
diff
changeset
|
359 ss << "String \"" << strValue << "\" cannot be converted to {{enum['name']}}. Possible values are: {% for key in enum['fields']%}{{key}} {% endfor %}"; |
507 | 360 std::string msg = ss.str(); |
361 throw std::runtime_error(msg); | |
362 } | |
363 | |
519
17106b29ed6d
Changed the metadata system for structs. A __handler entry is now required
Benjamin Golinvaux <bgo@osimis.io>
parents:
515
diff
changeset
|
364 |
17106b29ed6d
Changed the metadata system for structs. A __handler entry is now required
Benjamin Golinvaux <bgo@osimis.io>
parents:
515
diff
changeset
|
365 inline void _StoneDeserializeValue( |
17106b29ed6d
Changed the metadata system for structs. A __handler entry is now required
Benjamin Golinvaux <bgo@osimis.io>
parents:
515
diff
changeset
|
366 {{enum['name']}}& destValue, const Json::Value& jsonValue) |
17106b29ed6d
Changed the metadata system for structs. A __handler entry is now required
Benjamin Golinvaux <bgo@osimis.io>
parents:
515
diff
changeset
|
367 { |
628
84af39146e76
CodeGeneration: support default values
Alain Mazy <alain@mazy.be>
parents:
601
diff
changeset
|
368 if (!jsonValue.isNull()) |
84af39146e76
CodeGeneration: support default values
Alain Mazy <alain@mazy.be>
parents:
601
diff
changeset
|
369 { |
84af39146e76
CodeGeneration: support default values
Alain Mazy <alain@mazy.be>
parents:
601
diff
changeset
|
370 FromString(destValue, jsonValue.asString()); |
84af39146e76
CodeGeneration: support default values
Alain Mazy <alain@mazy.be>
parents:
601
diff
changeset
|
371 } |
519
17106b29ed6d
Changed the metadata system for structs. A __handler entry is now required
Benjamin Golinvaux <bgo@osimis.io>
parents:
515
diff
changeset
|
372 } |
17106b29ed6d
Changed the metadata system for structs. A __handler entry is now required
Benjamin Golinvaux <bgo@osimis.io>
parents:
515
diff
changeset
|
373 |
17106b29ed6d
Changed the metadata system for structs. A __handler entry is now required
Benjamin Golinvaux <bgo@osimis.io>
parents:
515
diff
changeset
|
374 inline Json::Value _StoneSerializeValue(const {{enum['name']}}& value) |
17106b29ed6d
Changed the metadata system for structs. A __handler entry is now required
Benjamin Golinvaux <bgo@osimis.io>
parents:
515
diff
changeset
|
375 { |
17106b29ed6d
Changed the metadata system for structs. A __handler entry is now required
Benjamin Golinvaux <bgo@osimis.io>
parents:
515
diff
changeset
|
376 std::string strValue = ToString(value); |
17106b29ed6d
Changed the metadata system for structs. A __handler entry is now required
Benjamin Golinvaux <bgo@osimis.io>
parents:
515
diff
changeset
|
377 return Json::Value(strValue); |
17106b29ed6d
Changed the metadata system for structs. A __handler entry is now required
Benjamin Golinvaux <bgo@osimis.io>
parents:
515
diff
changeset
|
378 } |
17106b29ed6d
Changed the metadata system for structs. A __handler entry is now required
Benjamin Golinvaux <bgo@osimis.io>
parents:
515
diff
changeset
|
379 |
524 | 380 inline std::ostream& StoneDumpValue(std::ostream& out, const {{enum['name']}}& value, size_t indent = 0) |
507 | 381 { |
382 {% for key in enum['fields']%} if( value == {{enum['name']}}_{{key}}) | |
495
6405435480ae
Fixed template to add dump capabilities + started work on an integrated TS/WASM test
bgo-osimis
parents:
494
diff
changeset
|
383 { |
6405435480ae
Fixed template to add dump capabilities + started work on an integrated TS/WASM test
bgo-osimis
parents:
494
diff
changeset
|
384 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
|
385 } |
6405435480ae
Fixed template to add dump capabilities + started work on an integrated TS/WASM test
bgo-osimis
parents:
494
diff
changeset
|
386 {%endfor%} return out; |
6405435480ae
Fixed template to add dump capabilities + started work on an integrated TS/WASM test
bgo-osimis
parents:
494
diff
changeset
|
387 } |
6405435480ae
Fixed template to add dump capabilities + started work on an integrated TS/WASM test
bgo-osimis
parents:
494
diff
changeset
|
388 |
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
|
389 {%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
|
390 {% 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
|
391 #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
|
392 #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
|
393 #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
|
394 |
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
|
395 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
|
396 { |
676
1b47f17863ba
codegen: using an ordereddict loader instead of sort the keys -> the delcared ordered in the yaml is preserved in the generated code which is more meaningfull than the alphabetical order
Alain Mazy <alain@mazy.be>
parents:
670
diff
changeset
|
397 {% if struct %}{% if struct['fields'] %}{% for key in struct['fields'] %} {{CanonToCpp(struct['fields'][key]['type'])}} {{key}}; |
507 | 398 {% endfor %}{% endif %}{% endif %} |
676
1b47f17863ba
codegen: using an ordereddict loader instead of sort the keys -> the delcared ordered in the yaml is preserved in the generated code which is more meaningfull than the alphabetical order
Alain Mazy <alain@mazy.be>
parents:
670
diff
changeset
|
399 {{struct['name']}}({% if struct %}{% if struct['fields'] %}{% for key in struct['fields'] %}{{CanonToCpp(struct['fields'][key]['type'])}} {{key}} = {% if struct['fields'][key]['defaultValue'] %}{{DefaultValueToCpp(rootName,enums,struct['fields'][key])}} {%else%} {{CanonToCpp(struct['fields'][key]['type'])}}() {%endif%} {{ ", " if not loop.last }}{% endfor %}{% endif %}{% endif %}) |
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
|
400 { |
507 | 401 {% if struct %}{% if struct['fields'] %}{% for key in struct['fields']%} this->{{key}} = {{key}}; |
402 {% endfor %}{% endif %}{% endif %} } | |
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
|
403 }; |
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
|
404 |
507 | 405 inline void _StoneDeserializeValue({{struct['name']}}& destValue, const Json::Value& 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
|
406 { |
628
84af39146e76
CodeGeneration: support default values
Alain Mazy <alain@mazy.be>
parents:
601
diff
changeset
|
407 if (!value.isNull()) |
84af39146e76
CodeGeneration: support default values
Alain Mazy <alain@mazy.be>
parents:
601
diff
changeset
|
408 { |
84af39146e76
CodeGeneration: support default values
Alain Mazy <alain@mazy.be>
parents:
601
diff
changeset
|
409 {% if struct %}{% if struct['fields'] %}{% for key in struct['fields']%} _StoneDeserializeValue(destValue.{{key}}, value["{{key}}"]); |
507 | 410 {% endfor %}{% endif %}{% endif %} } |
628
84af39146e76
CodeGeneration: support default values
Alain Mazy <alain@mazy.be>
parents:
601
diff
changeset
|
411 } |
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
|
412 |
507 | 413 inline Json::Value _StoneSerializeValue(const {{struct['name']}}& 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
|
414 { |
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
|
415 Json::Value result(Json::objectValue); |
507 | 416 {% if struct %}{% if struct['fields'] %}{% for key in struct['fields']%} result["{{key}}"] = _StoneSerializeValue(value.{{key}}); |
417 {% endfor %}{% endif %}{% endif %} | |
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
|
418 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
|
419 } |
490 | 420 |
524 | 421 inline std::ostream& StoneDumpValue(std::ostream& out, const {{struct['name']}}& value, size_t indent = 0) |
495
6405435480ae
Fixed template to add dump capabilities + started work on an integrated TS/WASM test
bgo-osimis
parents:
494
diff
changeset
|
422 { |
6405435480ae
Fixed template to add dump capabilities + started work on an integrated TS/WASM test
bgo-osimis
parents:
494
diff
changeset
|
423 out << MakeIndent(indent) << "{\n"; |
507 | 424 {% if struct %}{% if struct['fields'] %}{% for key in struct['fields']%} out << MakeIndent(indent) << "{{key}}:\n"; |
495
6405435480ae
Fixed template to add dump capabilities + started work on an integrated TS/WASM test
bgo-osimis
parents:
494
diff
changeset
|
425 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
|
426 out << "\n"; |
507 | 427 {% endfor %}{% endif %}{% endif %} |
495
6405435480ae
Fixed template to add dump capabilities + started work on an integrated TS/WASM test
bgo-osimis
parents:
494
diff
changeset
|
428 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
|
429 return out; |
6405435480ae
Fixed template to add dump capabilities + started work on an integrated TS/WASM test
bgo-osimis
parents:
494
diff
changeset
|
430 } |
6405435480ae
Fixed template to add dump capabilities + started work on an integrated TS/WASM test
bgo-osimis
parents:
494
diff
changeset
|
431 |
507 | 432 inline void StoneDeserialize({{struct['name']}}& destValue, const Json::Value& 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
|
433 { |
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
|
434 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
|
435 _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
|
436 } |
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
|
437 |
507 | 438 inline Json::Value StoneSerializeToJson(const {{struct['name']}}& 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
|
439 { |
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
|
440 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
|
441 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
|
442 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
|
443 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
|
444 } |
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
|
445 |
507 | 446 inline std::string StoneSerialize(const {{struct['name']}}& value) |
447 { | |
448 Json::Value resultJson = StoneSerializeToJson(value); | |
449 std::string resultStr = resultJson.toStyledString(); | |
450 return resultStr; | |
451 } | |
452 | |
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
|
453 #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
|
454 #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
|
455 #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
|
456 {% 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
|
457 #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
|
458 #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
|
459 #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
|
460 |
495
6405435480ae
Fixed template to add dump capabilities + started work on an integrated TS/WASM test
bgo-osimis
parents:
494
diff
changeset
|
461 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
|
462 { |
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
|
463 public: |
513
dea3787a8f4b
Added support for struct metadata, to disable/enable handler support in Typescript or C++
Benjamin Golinvaux <bgo@osimis.io>
parents:
508
diff
changeset
|
464 {% for struct in structs%}{% if struct['__meta__'].handleInCpp %} virtual bool Handle(const {{struct['name']}}& value) = 0; |
dea3787a8f4b
Added support for struct metadata, to disable/enable handler support in Typescript or C++
Benjamin Golinvaux <bgo@osimis.io>
parents:
508
diff
changeset
|
465 {% endif %}{% endfor %} }; |
490 | 466 |
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
|
467 /** Service function for StoneDispatchToHandler */ |
507 | 468 inline bool StoneDispatchJsonToHandler( |
495
6405435480ae
Fixed template to add dump capabilities + started work on an integrated TS/WASM test
bgo-osimis
parents:
494
diff
changeset
|
469 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
|
470 { |
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
|
471 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
|
472 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
|
473 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
|
474 { |
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
|
475 // 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
|
476 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
|
477 } |
513
dea3787a8f4b
Added support for struct metadata, to disable/enable handler support in Typescript or C++
Benjamin Golinvaux <bgo@osimis.io>
parents:
508
diff
changeset
|
478 {% for struct in structs%}{% if struct['__meta__'].handleInCpp %} else if (type == "{{rootName}}.{{struct['name']}}") |
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
|
479 { |
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
|
480 {{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
|
481 _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
|
482 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
|
483 } |
513
dea3787a8f4b
Added support for struct metadata, to disable/enable handler support in Typescript or C++
Benjamin Golinvaux <bgo@osimis.io>
parents:
508
diff
changeset
|
484 {% endif %}{% endfor %} else |
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
|
485 { |
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
|
486 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
|
487 } |
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
|
488 } |
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
|
489 |
495
6405435480ae
Fixed template to add dump capabilities + started work on an integrated TS/WASM test
bgo-osimis
parents:
494
diff
changeset
|
490 /** Takes a serialized type and passes this to the handler */ |
507 | 491 inline 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
|
492 { |
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
|
493 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
|
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
|
495 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
|
496 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
|
497 |
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
|
498 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
|
499 |
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
|
500 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
|
501 |
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
|
502 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
|
503 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
|
504 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
|
505 &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
|
506 &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
|
507 ); |
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
|
508 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
|
509 { |
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
|
510 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
|
511 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
|
512 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
|
513 } |
495
6405435480ae
Fixed template to add dump capabilities + started work on an integrated TS/WASM test
bgo-osimis
parents:
494
diff
changeset
|
514 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
|
515 } |
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
|
516 |
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
|
517 #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
|
518 #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
|
519 #endif //_MSC_VER |
490 | 520 } |