annotate Resources/CodeGeneration/template.in.h.j2 @ 687:342f3e04bfa9 am-dev

CodeGen: test cleanup + all working again + using same yaml and stimuli files
author Alain Mazy <alain@mazy.be>
date Thu, 16 May 2019 17:51:17 +0200
parents e8b83fe55a33
children f185cfcb72a0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
490
6470248790db ongoing codegen work
bgo-osimis
parents:
diff changeset
1 /*
6470248790db ongoing codegen work
bgo-osimis
parents:
diff changeset
2 1 2 3 4 5 6 7
6470248790db ongoing codegen work
bgo-osimis
parents:
diff changeset
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
ce49eae4c887 Codegen + Warning fixes
Benjamin Golinvaux <bgo@osimis.io>
parents: 499
diff changeset
5 Generated on {{currentDatetime}} by stonegentool
ce49eae4c887 Codegen + Warning fixes
Benjamin Golinvaux <bgo@osimis.io>
parents: 499
diff changeset
6
490
6470248790db ongoing codegen work
bgo-osimis
parents:
diff changeset
7 */
507
ce49eae4c887 Codegen + Warning fixes
Benjamin Golinvaux <bgo@osimis.io>
parents: 499
diff changeset
8 #pragma once
490
6470248790db ongoing codegen work
bgo-osimis
parents:
diff changeset
9
507
ce49eae4c887 Codegen + Warning fixes
Benjamin Golinvaux <bgo@osimis.io>
parents: 499
diff changeset
10 #include <exception>
490
6470248790db ongoing codegen work
bgo-osimis
parents:
diff changeset
11 #include <iostream>
6470248790db ongoing codegen work
bgo-osimis
parents:
diff changeset
12 #include <string>
6470248790db ongoing codegen work
bgo-osimis
parents:
diff changeset
13 #include <sstream>
6470248790db ongoing codegen work
bgo-osimis
parents:
diff changeset
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
6470248790db ongoing codegen work
bgo-osimis
parents:
diff changeset
17 #include <json/json.h>
6470248790db ongoing codegen work
bgo-osimis
parents:
diff changeset
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
6470248790db ongoing codegen work
bgo-osimis
parents:
diff changeset
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
6470248790db ongoing codegen work
bgo-osimis
parents:
diff changeset
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
ce49eae4c887 Codegen + Warning fixes
Benjamin Golinvaux <bgo@osimis.io>
parents: 499
diff changeset
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
ce49eae4c887 Codegen + Warning fixes
Benjamin Golinvaux <bgo@osimis.io>
parents: 499
diff changeset
38 inline Json::Value _StoneSerializeValue(int32_t value)
490
6470248790db ongoing codegen work
bgo-osimis
parents:
diff changeset
39 {
6470248790db ongoing codegen work
bgo-osimis
parents:
diff changeset
40 Json::Value result(value);
6470248790db ongoing codegen work
bgo-osimis
parents:
diff changeset
41 return result;
6470248790db ongoing codegen work
bgo-osimis
parents:
diff changeset
42 }
6470248790db ongoing codegen work
bgo-osimis
parents:
diff changeset
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
ce49eae4c887 Codegen + Warning fixes
Benjamin Golinvaux <bgo@osimis.io>
parents: 499
diff changeset
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
ce49eae4c887 Codegen + Warning fixes
Benjamin Golinvaux <bgo@osimis.io>
parents: 499
diff changeset
105 inline Json::Value _StoneSerializeValue(double value)
490
6470248790db ongoing codegen work
bgo-osimis
parents:
diff changeset
106 {
6470248790db ongoing codegen work
bgo-osimis
parents:
diff changeset
107 Json::Value result(value);
6470248790db ongoing codegen work
bgo-osimis
parents:
diff changeset
108 return result;
6470248790db ongoing codegen work
bgo-osimis
parents:
diff changeset
109 }
6470248790db ongoing codegen work
bgo-osimis
parents:
diff changeset
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 */
682
e8b83fe55a33 added support for float + map<TK, TV> instead of only map<string, T>
Alain Mazy <alain@mazy.be>
parents: 676
diff changeset
112 inline void _StoneDeserializeValue(float& destValue, const Json::Value& jsonValue)
e8b83fe55a33 added support for float + map<TK, TV> instead of only map<string, T>
Alain Mazy <alain@mazy.be>
parents: 676
diff changeset
113 {
e8b83fe55a33 added support for float + map<TK, TV> instead of only map<string, T>
Alain Mazy <alain@mazy.be>
parents: 676
diff changeset
114 if (!jsonValue.isNull())
e8b83fe55a33 added support for float + map<TK, TV> instead of only map<string, T>
Alain Mazy <alain@mazy.be>
parents: 676
diff changeset
115 {
e8b83fe55a33 added support for float + map<TK, TV> instead of only map<string, T>
Alain Mazy <alain@mazy.be>
parents: 676
diff changeset
116 destValue = jsonValue.asFloat();
e8b83fe55a33 added support for float + map<TK, TV> instead of only map<string, T>
Alain Mazy <alain@mazy.be>
parents: 676
diff changeset
117 }
e8b83fe55a33 added support for float + map<TK, TV> instead of only map<string, T>
Alain Mazy <alain@mazy.be>
parents: 676
diff changeset
118 }
e8b83fe55a33 added support for float + map<TK, TV> instead of only map<string, T>
Alain Mazy <alain@mazy.be>
parents: 676
diff changeset
119
e8b83fe55a33 added support for float + map<TK, TV> instead of only map<string, T>
Alain Mazy <alain@mazy.be>
parents: 676
diff changeset
120 inline Json::Value _StoneSerializeValue(float value)
e8b83fe55a33 added support for float + map<TK, TV> instead of only map<string, T>
Alain Mazy <alain@mazy.be>
parents: 676
diff changeset
121 {
e8b83fe55a33 added support for float + map<TK, TV> instead of only map<string, T>
Alain Mazy <alain@mazy.be>
parents: 676
diff changeset
122 Json::Value result(value);
e8b83fe55a33 added support for float + map<TK, TV> instead of only map<string, T>
Alain Mazy <alain@mazy.be>
parents: 676
diff changeset
123 return result;
e8b83fe55a33 added support for float + map<TK, TV> instead of only map<string, T>
Alain Mazy <alain@mazy.be>
parents: 676
diff changeset
124 }
e8b83fe55a33 added support for float + map<TK, TV> instead of only map<string, T>
Alain Mazy <alain@mazy.be>
parents: 676
diff changeset
125
e8b83fe55a33 added support for float + map<TK, TV> instead of only map<string, T>
Alain Mazy <alain@mazy.be>
parents: 676
diff changeset
126 /** Throws in case of problem */
507
ce49eae4c887 Codegen + Warning fixes
Benjamin Golinvaux <bgo@osimis.io>
parents: 499
diff changeset
127 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
128 {
628
84af39146e76 CodeGeneration: support default values
Alain Mazy <alain@mazy.be>
parents: 601
diff changeset
129 if (!jsonValue.isNull())
84af39146e76 CodeGeneration: support default values
Alain Mazy <alain@mazy.be>
parents: 601
diff changeset
130 {
84af39146e76 CodeGeneration: support default values
Alain Mazy <alain@mazy.be>
parents: 601
diff changeset
131 destValue = jsonValue.asBool();
84af39146e76 CodeGeneration: support default values
Alain Mazy <alain@mazy.be>
parents: 601
diff changeset
132 }
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 }
fc17251477d6 TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents: 490
diff changeset
134
507
ce49eae4c887 Codegen + Warning fixes
Benjamin Golinvaux <bgo@osimis.io>
parents: 499
diff changeset
135 inline Json::Value _StoneSerializeValue(bool value)
490
6470248790db ongoing codegen work
bgo-osimis
parents:
diff changeset
136 {
6470248790db ongoing codegen work
bgo-osimis
parents:
diff changeset
137 Json::Value result(value);
6470248790db ongoing codegen work
bgo-osimis
parents:
diff changeset
138 return result;
6470248790db ongoing codegen work
bgo-osimis
parents:
diff changeset
139 }
6470248790db ongoing codegen work
bgo-osimis
parents:
diff changeset
140
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
141 /** Throws in case of problem */
507
ce49eae4c887 Codegen + Warning fixes
Benjamin Golinvaux <bgo@osimis.io>
parents: 499
diff changeset
142 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
143 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
144 , 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
145 {
628
84af39146e76 CodeGeneration: support default values
Alain Mazy <alain@mazy.be>
parents: 601
diff changeset
146 if (!jsonValue.isNull())
84af39146e76 CodeGeneration: support default values
Alain Mazy <alain@mazy.be>
parents: 601
diff changeset
147 {
84af39146e76 CodeGeneration: support default values
Alain Mazy <alain@mazy.be>
parents: 601
diff changeset
148 destValue = jsonValue.asString();
84af39146e76 CodeGeneration: support default values
Alain Mazy <alain@mazy.be>
parents: 601
diff changeset
149 }
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
150 }
fc17251477d6 TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents: 490
diff changeset
151
507
ce49eae4c887 Codegen + Warning fixes
Benjamin Golinvaux <bgo@osimis.io>
parents: 499
diff changeset
152 inline Json::Value _StoneSerializeValue(const std::string& value)
490
6470248790db ongoing codegen work
bgo-osimis
parents:
diff changeset
153 {
6470248790db ongoing codegen work
bgo-osimis
parents:
diff changeset
154 // the following is better than
6470248790db ongoing codegen work
bgo-osimis
parents:
diff changeset
155 Json::Value result(value.data(),value.data()+value.size());
6470248790db ongoing codegen work
bgo-osimis
parents:
diff changeset
156 return result;
6470248790db ongoing codegen work
bgo-osimis
parents:
diff changeset
157 }
495
6405435480ae Fixed template to add dump capabilities + started work on an integrated TS/WASM test
bgo-osimis
parents: 494
diff changeset
158
524
9e241cef32a4 fix warning
amazy
parents: 519
diff changeset
159 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
160 {
6405435480ae Fixed template to add dump capabilities + started work on an integrated TS/WASM test
bgo-osimis
parents: 494
diff changeset
161 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
162 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
163 txt[i] = ' ';
6405435480ae Fixed template to add dump capabilities + started work on an integrated TS/WASM test
bgo-osimis
parents: 494
diff changeset
164 txt[indent] = 0;
6405435480ae Fixed template to add dump capabilities + started work on an integrated TS/WASM test
bgo-osimis
parents: 494
diff changeset
165 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
166 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
167 return retVal;
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
6405435480ae Fixed template to add dump capabilities + started work on an integrated TS/WASM test
bgo-osimis
parents: 494
diff changeset
170 // generic dumper
6405435480ae Fixed template to add dump capabilities + started work on an integrated TS/WASM test
bgo-osimis
parents: 494
diff changeset
171 template<typename T>
524
9e241cef32a4 fix warning
amazy
parents: 519
diff changeset
172 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
173 {
6405435480ae Fixed template to add dump capabilities + started work on an integrated TS/WASM test
bgo-osimis
parents: 494
diff changeset
174 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
175 return out;
6405435480ae Fixed template to add dump capabilities + started work on an integrated TS/WASM test
bgo-osimis
parents: 494
diff changeset
176 }
6405435480ae Fixed template to add dump capabilities + started work on an integrated TS/WASM test
bgo-osimis
parents: 494
diff changeset
177
6405435480ae Fixed template to add dump capabilities + started work on an integrated TS/WASM test
bgo-osimis
parents: 494
diff changeset
178 // string dumper
524
9e241cef32a4 fix warning
amazy
parents: 519
diff changeset
179 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
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) << "\"" << value << "\"";
6405435480ae Fixed template to add dump capabilities + started work on an integrated TS/WASM test
bgo-osimis
parents: 494
diff changeset
182 return out;
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
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 /** Throws in case of problem */
682
e8b83fe55a33 added support for float + map<TK, TV> instead of only map<string, T>
Alain Mazy <alain@mazy.be>
parents: 676
diff changeset
186 template<typename TK, typename TV>
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
187 void _StoneDeserializeValue(
682
e8b83fe55a33 added support for float + map<TK, TV> instead of only map<string, T>
Alain Mazy <alain@mazy.be>
parents: 676
diff changeset
188 std::map<TK, TV>& 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
189 {
628
84af39146e76 CodeGeneration: support default values
Alain Mazy <alain@mazy.be>
parents: 601
diff changeset
190 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
191 {
628
84af39146e76 CodeGeneration: support default values
Alain Mazy <alain@mazy.be>
parents: 601
diff changeset
192 destValue.clear();
84af39146e76 CodeGeneration: support default values
Alain Mazy <alain@mazy.be>
parents: 601
diff changeset
193 for (
84af39146e76 CodeGeneration: support default values
Alain Mazy <alain@mazy.be>
parents: 601
diff changeset
194 Json::Value::const_iterator itr = jsonValue.begin();
84af39146e76 CodeGeneration: support default values
Alain Mazy <alain@mazy.be>
parents: 601
diff changeset
195 itr != jsonValue.end();
84af39146e76 CodeGeneration: support default values
Alain Mazy <alain@mazy.be>
parents: 601
diff changeset
196 itr++)
84af39146e76 CodeGeneration: support default values
Alain Mazy <alain@mazy.be>
parents: 601
diff changeset
197 {
682
e8b83fe55a33 added support for float + map<TK, TV> instead of only map<string, T>
Alain Mazy <alain@mazy.be>
parents: 676
diff changeset
198 TK key;
628
84af39146e76 CodeGeneration: support default values
Alain Mazy <alain@mazy.be>
parents: 601
diff changeset
199 _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
200
682
e8b83fe55a33 added support for float + map<TK, TV> instead of only map<string, T>
Alain Mazy <alain@mazy.be>
parents: 676
diff changeset
201 TV innerDestValue;
628
84af39146e76 CodeGeneration: support default values
Alain Mazy <alain@mazy.be>
parents: 601
diff changeset
202 _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
203
628
84af39146e76 CodeGeneration: support default values
Alain Mazy <alain@mazy.be>
parents: 601
diff changeset
204 destValue[key] = innerDestValue;
84af39146e76 CodeGeneration: support default values
Alain Mazy <alain@mazy.be>
parents: 601
diff changeset
205 }
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
206 }
fc17251477d6 TS and CPP 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 }
682
e8b83fe55a33 added support for float + map<TK, TV> instead of only map<string, T>
Alain Mazy <alain@mazy.be>
parents: 676
diff changeset
208 template<typename TK, typename TV>
e8b83fe55a33 added support for float + map<TK, TV> instead of only map<string, T>
Alain Mazy <alain@mazy.be>
parents: 676
diff changeset
209 Json::Value _StoneSerializeValue(const std::map<TK, TV>& value)
490
6470248790db ongoing codegen work
bgo-osimis
parents:
diff changeset
210 {
6470248790db ongoing codegen work
bgo-osimis
parents:
diff changeset
211 Json::Value result(Json::objectValue);
6470248790db ongoing codegen work
bgo-osimis
parents:
diff changeset
212
682
e8b83fe55a33 added support for float + map<TK, TV> instead of only map<string, T>
Alain Mazy <alain@mazy.be>
parents: 676
diff changeset
213 for (typename std::map<TK, TV>::const_iterator it = value.cbegin();
490
6470248790db ongoing codegen work
bgo-osimis
parents:
diff changeset
214 it != value.cend(); ++it)
6470248790db ongoing codegen work
bgo-osimis
parents:
diff changeset
215 {
6470248790db ongoing codegen work
bgo-osimis
parents:
diff changeset
216 // 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
217 result[it->first] = _StoneSerializeValue(it->second);
490
6470248790db ongoing codegen work
bgo-osimis
parents:
diff changeset
218 }
6470248790db ongoing codegen work
bgo-osimis
parents:
diff changeset
219 return result;
6470248790db ongoing codegen work
bgo-osimis
parents:
diff changeset
220 }
6470248790db ongoing codegen work
bgo-osimis
parents:
diff changeset
221
682
e8b83fe55a33 added support for float + map<TK, TV> instead of only map<string, T>
Alain Mazy <alain@mazy.be>
parents: 676
diff changeset
222 template<typename TK, typename TV>
e8b83fe55a33 added support for float + map<TK, TV> instead of only map<string, T>
Alain Mazy <alain@mazy.be>
parents: 676
diff changeset
223 std::ostream& StoneDumpValue(std::ostream& out, const std::map<TK, TV>& 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
224 {
6405435480ae Fixed template to add dump capabilities + started work on an integrated TS/WASM test
bgo-osimis
parents: 494
diff changeset
225 out << MakeIndent(indent) << "{\n";
682
e8b83fe55a33 added support for float + map<TK, TV> instead of only map<string, T>
Alain Mazy <alain@mazy.be>
parents: 676
diff changeset
226 for (typename std::map<TK, TV>::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
227 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
228 {
6405435480ae Fixed template to add dump capabilities + started work on an integrated TS/WASM test
bgo-osimis
parents: 494
diff changeset
229 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
230 StoneDumpValue(out, it->second, indent+2);
687
342f3e04bfa9 CodeGen: test cleanup + all working again + using same yaml and stimuli files
Alain Mazy <alain@mazy.be>
parents: 682
diff changeset
231 out << ", \n";
495
6405435480ae Fixed template to add dump capabilities + started work on an integrated TS/WASM test
bgo-osimis
parents: 494
diff changeset
232 }
6405435480ae Fixed template to add dump capabilities + started work on an integrated TS/WASM test
bgo-osimis
parents: 494
diff changeset
233 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
234 return out;
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
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 /** Throws in case of problem */
490
6470248790db ongoing codegen work
bgo-osimis
parents:
diff changeset
238 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
239 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
240 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
241 {
628
84af39146e76 CodeGeneration: support default values
Alain Mazy <alain@mazy.be>
parents: 601
diff changeset
242 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
243 {
628
84af39146e76 CodeGeneration: support default values
Alain Mazy <alain@mazy.be>
parents: 601
diff changeset
244 destValue.clear();
84af39146e76 CodeGeneration: support default values
Alain Mazy <alain@mazy.be>
parents: 601
diff changeset
245 destValue.reserve(jsonValue.size());
84af39146e76 CodeGeneration: support default values
Alain Mazy <alain@mazy.be>
parents: 601
diff changeset
246 for (Json::Value::ArrayIndex i = 0; i != jsonValue.size(); i++)
84af39146e76 CodeGeneration: support default values
Alain Mazy <alain@mazy.be>
parents: 601
diff changeset
247 {
84af39146e76 CodeGeneration: support default values
Alain Mazy <alain@mazy.be>
parents: 601
diff changeset
248 T innerDestValue;
84af39146e76 CodeGeneration: support default values
Alain Mazy <alain@mazy.be>
parents: 601
diff changeset
249 _StoneDeserializeValue(innerDestValue, jsonValue[i]);
84af39146e76 CodeGeneration: support default values
Alain Mazy <alain@mazy.be>
parents: 601
diff changeset
250 destValue.push_back(innerDestValue);
84af39146e76 CodeGeneration: support default values
Alain Mazy <alain@mazy.be>
parents: 601
diff changeset
251 }
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
252 }
fc17251477d6 TS and CPP 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 }
fc17251477d6 TS and CPP 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 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
256 Json::Value _StoneSerializeValue(const std::vector<T>& value)
490
6470248790db ongoing codegen work
bgo-osimis
parents:
diff changeset
257 {
6470248790db ongoing codegen work
bgo-osimis
parents:
diff changeset
258 Json::Value result(Json::arrayValue);
6470248790db ongoing codegen work
bgo-osimis
parents:
diff changeset
259 for (size_t i = 0; i < value.size(); ++i)
6470248790db ongoing codegen work
bgo-osimis
parents:
diff changeset
260 {
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
261 result.append(_StoneSerializeValue(value[i]));
490
6470248790db ongoing codegen work
bgo-osimis
parents:
diff changeset
262 }
6470248790db ongoing codegen work
bgo-osimis
parents:
diff changeset
263 return result;
6470248790db ongoing codegen work
bgo-osimis
parents:
diff changeset
264 }
6470248790db ongoing codegen work
bgo-osimis
parents:
diff changeset
265
495
6405435480ae Fixed template to add dump capabilities + started work on an integrated TS/WASM test
bgo-osimis
parents: 494
diff changeset
266 template<typename T>
524
9e241cef32a4 fix warning
amazy
parents: 519
diff changeset
267 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
268 {
6405435480ae Fixed template to add dump capabilities + started work on an integrated TS/WASM test
bgo-osimis
parents: 494
diff changeset
269 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
270 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
271 {
6405435480ae Fixed template to add dump capabilities + started work on an integrated TS/WASM test
bgo-osimis
parents: 494
diff changeset
272 StoneDumpValue(out, value[i], indent+2);
687
342f3e04bfa9 CodeGen: test cleanup + all working again + using same yaml and stimuli files
Alain Mazy <alain@mazy.be>
parents: 682
diff changeset
273 out << ", \n";
495
6405435480ae Fixed template to add dump capabilities + started work on an integrated TS/WASM test
bgo-osimis
parents: 494
diff changeset
274 }
6405435480ae Fixed template to add dump capabilities + started work on an integrated TS/WASM test
bgo-osimis
parents: 494
diff changeset
275 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
276 return out;
6405435480ae Fixed template to add dump capabilities + started work on an integrated TS/WASM test
bgo-osimis
parents: 494
diff changeset
277 }
6405435480ae Fixed template to add dump capabilities + started work on an integrated TS/WASM test
bgo-osimis
parents: 494
diff changeset
278
543
75664eeacae5 added sets in code generation (not tested yet in TS)
Alain Mazy <alain@mazy.be>
parents: 524
diff changeset
279 /** 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
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 void _StoneDeserializeValue(
75664eeacae5 added sets in code generation (not tested yet in TS)
Alain Mazy <alain@mazy.be>
parents: 524
diff changeset
282 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
283 {
628
84af39146e76 CodeGeneration: support default values
Alain Mazy <alain@mazy.be>
parents: 601
diff changeset
284 if (!jsonValue.isNull())
543
75664eeacae5 added sets in code generation (not tested yet in TS)
Alain Mazy <alain@mazy.be>
parents: 524
diff changeset
285 {
628
84af39146e76 CodeGeneration: support default values
Alain Mazy <alain@mazy.be>
parents: 601
diff changeset
286 destValue.clear();
84af39146e76 CodeGeneration: support default values
Alain Mazy <alain@mazy.be>
parents: 601
diff changeset
287 for (Json::Value::ArrayIndex i = 0; i != jsonValue.size(); i++)
84af39146e76 CodeGeneration: support default values
Alain Mazy <alain@mazy.be>
parents: 601
diff changeset
288 {
84af39146e76 CodeGeneration: support default values
Alain Mazy <alain@mazy.be>
parents: 601
diff changeset
289 T innerDestValue;
84af39146e76 CodeGeneration: support default values
Alain Mazy <alain@mazy.be>
parents: 601
diff changeset
290 _StoneDeserializeValue(innerDestValue, jsonValue[i]);
84af39146e76 CodeGeneration: support default values
Alain Mazy <alain@mazy.be>
parents: 601
diff changeset
291 destValue.insert(innerDestValue);
84af39146e76 CodeGeneration: support default values
Alain Mazy <alain@mazy.be>
parents: 601
diff changeset
292 }
543
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 }
75664eeacae5 added sets in code generation (not tested yet in TS)
Alain Mazy <alain@mazy.be>
parents: 524
diff changeset
295
75664eeacae5 added sets in code generation (not tested yet in TS)
Alain Mazy <alain@mazy.be>
parents: 524
diff changeset
296 template<typename T>
75664eeacae5 added sets in code generation (not tested yet in TS)
Alain Mazy <alain@mazy.be>
parents: 524
diff changeset
297 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
298 {
75664eeacae5 added sets in code generation (not tested yet in TS)
Alain Mazy <alain@mazy.be>
parents: 524
diff changeset
299 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
300 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
301 {
75664eeacae5 added sets in code generation (not tested yet in TS)
Alain Mazy <alain@mazy.be>
parents: 524
diff changeset
302 result.append(_StoneSerializeValue(*it));
75664eeacae5 added sets in code generation (not tested yet in TS)
Alain Mazy <alain@mazy.be>
parents: 524
diff changeset
303 }
75664eeacae5 added sets in code generation (not tested yet in TS)
Alain Mazy <alain@mazy.be>
parents: 524
diff changeset
304 return result;
75664eeacae5 added sets in code generation (not tested yet in TS)
Alain Mazy <alain@mazy.be>
parents: 524
diff changeset
305 }
75664eeacae5 added sets in code generation (not tested yet in TS)
Alain Mazy <alain@mazy.be>
parents: 524
diff changeset
306
75664eeacae5 added sets in code generation (not tested yet in TS)
Alain Mazy <alain@mazy.be>
parents: 524
diff changeset
307 template<typename T>
75664eeacae5 added sets in code generation (not tested yet in TS)
Alain Mazy <alain@mazy.be>
parents: 524
diff changeset
308 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
309 {
75664eeacae5 added sets in code generation (not tested yet in TS)
Alain Mazy <alain@mazy.be>
parents: 524
diff changeset
310 out << MakeIndent(indent) << "[\n";
75664eeacae5 added sets in code generation (not tested yet in TS)
Alain Mazy <alain@mazy.be>
parents: 524
diff changeset
311 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
312 {
75664eeacae5 added sets in code generation (not tested yet in TS)
Alain Mazy <alain@mazy.be>
parents: 524
diff changeset
313 StoneDumpValue(out, *it, indent+2);
687
342f3e04bfa9 CodeGen: test cleanup + all working again + using same yaml and stimuli files
Alain Mazy <alain@mazy.be>
parents: 682
diff changeset
314 out << ", \n";
543
75664eeacae5 added sets in code generation (not tested yet in TS)
Alain Mazy <alain@mazy.be>
parents: 524
diff changeset
315 }
75664eeacae5 added sets in code generation (not tested yet in TS)
Alain Mazy <alain@mazy.be>
parents: 524
diff changeset
316 out << MakeIndent(indent) << "]\n";
75664eeacae5 added sets in code generation (not tested yet in TS)
Alain Mazy <alain@mazy.be>
parents: 524
diff changeset
317 return out;
75664eeacae5 added sets in code generation (not tested yet in TS)
Alain Mazy <alain@mazy.be>
parents: 524
diff changeset
318 }
75664eeacae5 added sets in code generation (not tested yet in TS)
Alain Mazy <alain@mazy.be>
parents: 524
diff changeset
319
507
ce49eae4c887 Codegen + Warning fixes
Benjamin Golinvaux <bgo@osimis.io>
parents: 499
diff changeset
320 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
321 {
fc17251477d6 TS and CPP 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 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
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 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
325 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
326 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
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 }
fc17251477d6 TS and CPP 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
507
ce49eae4c887 Codegen + Warning fixes
Benjamin Golinvaux <bgo@osimis.io>
parents: 499
diff changeset
330 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
331 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
332 {
fc17251477d6 TS and CPP 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 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
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 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
336 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
337 {
fc17251477d6 TS and CPP 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 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
339 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
340 << "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
341 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
342 }
fc17251477d6 TS and CPP 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
fc17251477d6 TS and CPP 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 // 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
346
fc17251477d6 TS and CPP 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 // 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
348 {% 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
349 enum {{enum['name']}} {
507
ce49eae4c887 Codegen + Warning fixes
Benjamin Golinvaux <bgo@osimis.io>
parents: 499
diff changeset
350 {% 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
351 {%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
352
507
ce49eae4c887 Codegen + Warning fixes
Benjamin Golinvaux <bgo@osimis.io>
parents: 499
diff changeset
353 inline std::string ToString(const {{enum['name']}}& value)
ce49eae4c887 Codegen + Warning fixes
Benjamin Golinvaux <bgo@osimis.io>
parents: 499
diff changeset
354 {
ce49eae4c887 Codegen + Warning fixes
Benjamin Golinvaux <bgo@osimis.io>
parents: 499
diff changeset
355 {% for key in enum['fields']%} if( value == {{enum['name']}}_{{key}})
ce49eae4c887 Codegen + Warning fixes
Benjamin Golinvaux <bgo@osimis.io>
parents: 499
diff changeset
356 {
ce49eae4c887 Codegen + Warning fixes
Benjamin Golinvaux <bgo@osimis.io>
parents: 499
diff changeset
357 return std::string("{{key}}");
ce49eae4c887 Codegen + Warning fixes
Benjamin Golinvaux <bgo@osimis.io>
parents: 499
diff changeset
358 }
508
7105a0bad250 - Added HandleSerializedMessage to IStoneApplication (empty impl)
Benjamin Golinvaux <bgo@osimis.io>
parents: 507
diff changeset
359 {%endfor%} std::stringstream ss;
7105a0bad250 - Added HandleSerializedMessage to IStoneApplication (empty impl)
Benjamin Golinvaux <bgo@osimis.io>
parents: 507
diff changeset
360 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
361 {% 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
362 {% endfor %} << std::endl;
7105a0bad250 - Added HandleSerializedMessage to IStoneApplication (empty impl)
Benjamin Golinvaux <bgo@osimis.io>
parents: 507
diff changeset
363 std::string msg = ss.str();
7105a0bad250 - Added HandleSerializedMessage to IStoneApplication (empty impl)
Benjamin Golinvaux <bgo@osimis.io>
parents: 507
diff changeset
364 throw std::runtime_error(msg);
507
ce49eae4c887 Codegen + Warning fixes
Benjamin Golinvaux <bgo@osimis.io>
parents: 499
diff changeset
365 }
ce49eae4c887 Codegen + Warning fixes
Benjamin Golinvaux <bgo@osimis.io>
parents: 499
diff changeset
366
ce49eae4c887 Codegen + Warning fixes
Benjamin Golinvaux <bgo@osimis.io>
parents: 499
diff changeset
367 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
368 {
507
ce49eae4c887 Codegen + Warning fixes
Benjamin Golinvaux <bgo@osimis.io>
parents: 499
diff changeset
369 {% for key in enum['fields']%} if( strValue == std::string("{{key}}") )
ce49eae4c887 Codegen + Warning fixes
Benjamin Golinvaux <bgo@osimis.io>
parents: 499
diff changeset
370 {
ce49eae4c887 Codegen + Warning fixes
Benjamin Golinvaux <bgo@osimis.io>
parents: 499
diff changeset
371 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
372 return;
507
ce49eae4c887 Codegen + Warning fixes
Benjamin Golinvaux <bgo@osimis.io>
parents: 499
diff changeset
373 }
ce49eae4c887 Codegen + Warning fixes
Benjamin Golinvaux <bgo@osimis.io>
parents: 499
diff changeset
374 {%endfor%}
ce49eae4c887 Codegen + Warning fixes
Benjamin Golinvaux <bgo@osimis.io>
parents: 499
diff changeset
375 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
376 ss << "String \"" << strValue << "\" cannot be converted to {{enum['name']}}. Possible values are: {% for key in enum['fields']%}{{key}} {% endfor %}";
507
ce49eae4c887 Codegen + Warning fixes
Benjamin Golinvaux <bgo@osimis.io>
parents: 499
diff changeset
377 std::string msg = ss.str();
ce49eae4c887 Codegen + Warning fixes
Benjamin Golinvaux <bgo@osimis.io>
parents: 499
diff changeset
378 throw std::runtime_error(msg);
ce49eae4c887 Codegen + Warning fixes
Benjamin Golinvaux <bgo@osimis.io>
parents: 499
diff changeset
379 }
ce49eae4c887 Codegen + Warning fixes
Benjamin Golinvaux <bgo@osimis.io>
parents: 499
diff changeset
380
519
17106b29ed6d Changed the metadata system for structs. A __handler entry is now required
Benjamin Golinvaux <bgo@osimis.io>
parents: 515
diff changeset
381
17106b29ed6d Changed the metadata system for structs. A __handler entry is now required
Benjamin Golinvaux <bgo@osimis.io>
parents: 515
diff changeset
382 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
383 {{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
384 {
628
84af39146e76 CodeGeneration: support default values
Alain Mazy <alain@mazy.be>
parents: 601
diff changeset
385 if (!jsonValue.isNull())
84af39146e76 CodeGeneration: support default values
Alain Mazy <alain@mazy.be>
parents: 601
diff changeset
386 {
84af39146e76 CodeGeneration: support default values
Alain Mazy <alain@mazy.be>
parents: 601
diff changeset
387 FromString(destValue, jsonValue.asString());
84af39146e76 CodeGeneration: support default values
Alain Mazy <alain@mazy.be>
parents: 601
diff changeset
388 }
519
17106b29ed6d Changed the metadata system for structs. A __handler entry is now required
Benjamin Golinvaux <bgo@osimis.io>
parents: 515
diff changeset
389 }
17106b29ed6d Changed the metadata system for structs. A __handler entry is now required
Benjamin Golinvaux <bgo@osimis.io>
parents: 515
diff changeset
390
17106b29ed6d Changed the metadata system for structs. A __handler entry is now required
Benjamin Golinvaux <bgo@osimis.io>
parents: 515
diff changeset
391 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
392 {
17106b29ed6d Changed the metadata system for structs. A __handler entry is now required
Benjamin Golinvaux <bgo@osimis.io>
parents: 515
diff changeset
393 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
394 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
395 }
17106b29ed6d Changed the metadata system for structs. A __handler entry is now required
Benjamin Golinvaux <bgo@osimis.io>
parents: 515
diff changeset
396
524
9e241cef32a4 fix warning
amazy
parents: 519
diff changeset
397 inline std::ostream& StoneDumpValue(std::ostream& out, const {{enum['name']}}& value, size_t indent = 0)
507
ce49eae4c887 Codegen + Warning fixes
Benjamin Golinvaux <bgo@osimis.io>
parents: 499
diff changeset
398 {
ce49eae4c887 Codegen + Warning fixes
Benjamin Golinvaux <bgo@osimis.io>
parents: 499
diff changeset
399 {% 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
400 {
687
342f3e04bfa9 CodeGen: test cleanup + all working again + using same yaml and stimuli files
Alain Mazy <alain@mazy.be>
parents: 682
diff changeset
401 out << MakeIndent(indent) << "{{key}}";
495
6405435480ae Fixed template to add dump capabilities + started work on an integrated TS/WASM test
bgo-osimis
parents: 494
diff changeset
402 }
6405435480ae Fixed template to add dump capabilities + started work on an integrated TS/WASM test
bgo-osimis
parents: 494
diff changeset
403 {%endfor%} return out;
6405435480ae Fixed template to add dump capabilities + started work on an integrated TS/WASM test
bgo-osimis
parents: 494
diff changeset
404 }
6405435480ae Fixed template to add dump capabilities + started work on an integrated TS/WASM test
bgo-osimis
parents: 494
diff changeset
405
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 {%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
407 {% 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
408 #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
409 #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
410 #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
411
fc17251477d6 TS and CPP 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 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
413 {
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
414 {% if struct %}{% if struct['fields'] %}{% for key in struct['fields'] %} {{CanonToCpp(struct['fields'][key]['type'])}} {{key}};
507
ce49eae4c887 Codegen + Warning fixes
Benjamin Golinvaux <bgo@osimis.io>
parents: 499
diff changeset
415 {% 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
416 {{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
417 {
507
ce49eae4c887 Codegen + Warning fixes
Benjamin Golinvaux <bgo@osimis.io>
parents: 499
diff changeset
418 {% if struct %}{% if struct['fields'] %}{% for key in struct['fields']%} this->{{key}} = {{key}};
ce49eae4c887 Codegen + Warning fixes
Benjamin Golinvaux <bgo@osimis.io>
parents: 499
diff changeset
419 {% 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
420 };
fc17251477d6 TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents: 490
diff changeset
421
507
ce49eae4c887 Codegen + Warning fixes
Benjamin Golinvaux <bgo@osimis.io>
parents: 499
diff changeset
422 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
423 {
628
84af39146e76 CodeGeneration: support default values
Alain Mazy <alain@mazy.be>
parents: 601
diff changeset
424 if (!value.isNull())
84af39146e76 CodeGeneration: support default values
Alain Mazy <alain@mazy.be>
parents: 601
diff changeset
425 {
84af39146e76 CodeGeneration: support default values
Alain Mazy <alain@mazy.be>
parents: 601
diff changeset
426 {% if struct %}{% if struct['fields'] %}{% for key in struct['fields']%} _StoneDeserializeValue(destValue.{{key}}, value["{{key}}"]);
507
ce49eae4c887 Codegen + Warning fixes
Benjamin Golinvaux <bgo@osimis.io>
parents: 499
diff changeset
427 {% endfor %}{% endif %}{% endif %} }
628
84af39146e76 CodeGeneration: support default values
Alain Mazy <alain@mazy.be>
parents: 601
diff changeset
428 }
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
429
507
ce49eae4c887 Codegen + Warning fixes
Benjamin Golinvaux <bgo@osimis.io>
parents: 499
diff changeset
430 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
431 {
fc17251477d6 TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents: 490
diff changeset
432 Json::Value result(Json::objectValue);
507
ce49eae4c887 Codegen + Warning fixes
Benjamin Golinvaux <bgo@osimis.io>
parents: 499
diff changeset
433 {% if struct %}{% if struct['fields'] %}{% for key in struct['fields']%} result["{{key}}"] = _StoneSerializeValue(value.{{key}});
ce49eae4c887 Codegen + Warning fixes
Benjamin Golinvaux <bgo@osimis.io>
parents: 499
diff changeset
434 {% 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
435 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
436 }
490
6470248790db ongoing codegen work
bgo-osimis
parents:
diff changeset
437
524
9e241cef32a4 fix warning
amazy
parents: 519
diff changeset
438 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
439 {
6405435480ae Fixed template to add dump capabilities + started work on an integrated TS/WASM test
bgo-osimis
parents: 494
diff changeset
440 out << MakeIndent(indent) << "{\n";
687
342f3e04bfa9 CodeGen: test cleanup + all working again + using same yaml and stimuli files
Alain Mazy <alain@mazy.be>
parents: 682
diff changeset
441 {% if struct %}{% if struct['fields'] %}{% for key in struct['fields']%} out << MakeIndent(indent+2) << "{{key}}: ";
495
6405435480ae Fixed template to add dump capabilities + started work on an integrated TS/WASM test
bgo-osimis
parents: 494
diff changeset
442 StoneDumpValue(out, value.{{key}},indent+2);
687
342f3e04bfa9 CodeGen: test cleanup + all working again + using same yaml and stimuli files
Alain Mazy <alain@mazy.be>
parents: 682
diff changeset
443 out << ", \n";
507
ce49eae4c887 Codegen + Warning fixes
Benjamin Golinvaux <bgo@osimis.io>
parents: 499
diff changeset
444 {% endfor %}{% endif %}{% endif %}
687
342f3e04bfa9 CodeGen: test cleanup + all working again + using same yaml and stimuli files
Alain Mazy <alain@mazy.be>
parents: 682
diff changeset
445 out << MakeIndent(indent) << "}";
495
6405435480ae Fixed template to add dump capabilities + started work on an integrated TS/WASM test
bgo-osimis
parents: 494
diff changeset
446 return out;
6405435480ae Fixed template to add dump capabilities + started work on an integrated TS/WASM test
bgo-osimis
parents: 494
diff changeset
447 }
6405435480ae Fixed template to add dump capabilities + started work on an integrated TS/WASM test
bgo-osimis
parents: 494
diff changeset
448
507
ce49eae4c887 Codegen + Warning fixes
Benjamin Golinvaux <bgo@osimis.io>
parents: 499
diff changeset
449 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
450 {
fc17251477d6 TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents: 490
diff changeset
451 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
452 _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
453 }
fc17251477d6 TS and CPP 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
507
ce49eae4c887 Codegen + Warning fixes
Benjamin Golinvaux <bgo@osimis.io>
parents: 499
diff changeset
455 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
456 {
fc17251477d6 TS and CPP 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 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
458 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
459 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
460 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
461 }
fc17251477d6 TS and CPP 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
507
ce49eae4c887 Codegen + Warning fixes
Benjamin Golinvaux <bgo@osimis.io>
parents: 499
diff changeset
463 inline std::string StoneSerialize(const {{struct['name']}}& value)
ce49eae4c887 Codegen + Warning fixes
Benjamin Golinvaux <bgo@osimis.io>
parents: 499
diff changeset
464 {
ce49eae4c887 Codegen + Warning fixes
Benjamin Golinvaux <bgo@osimis.io>
parents: 499
diff changeset
465 Json::Value resultJson = StoneSerializeToJson(value);
ce49eae4c887 Codegen + Warning fixes
Benjamin Golinvaux <bgo@osimis.io>
parents: 499
diff changeset
466 std::string resultStr = resultJson.toStyledString();
ce49eae4c887 Codegen + Warning fixes
Benjamin Golinvaux <bgo@osimis.io>
parents: 499
diff changeset
467 return resultStr;
ce49eae4c887 Codegen + Warning fixes
Benjamin Golinvaux <bgo@osimis.io>
parents: 499
diff changeset
468 }
ce49eae4c887 Codegen + Warning fixes
Benjamin Golinvaux <bgo@osimis.io>
parents: 499
diff changeset
469
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 #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
471 #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
472 #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
473 {% 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
474 #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
475 #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
476 #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
477
495
6405435480ae Fixed template to add dump capabilities + started work on an integrated TS/WASM test
bgo-osimis
parents: 494
diff changeset
478 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
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 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
481 {% 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
482 {% endif %}{% endfor %} };
490
6470248790db ongoing codegen work
bgo-osimis
parents:
diff changeset
483
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
484 /** Service function for StoneDispatchToHandler */
507
ce49eae4c887 Codegen + Warning fixes
Benjamin Golinvaux <bgo@osimis.io>
parents: 499
diff changeset
485 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
486 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
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 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
489 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
490 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
491 {
fc17251477d6 TS and CPP 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 // 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
493 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
494 }
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
495 {% 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
496 {
fc17251477d6 TS and CPP 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 {{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
498 _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
499 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
500 }
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
501 {% 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
502 {
fc17251477d6 TS and CPP 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 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
504 }
fc17251477d6 TS and CPP 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 }
fc17251477d6 TS and CPP 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
495
6405435480ae Fixed template to add dump capabilities + started work on an integrated TS/WASM test
bgo-osimis
parents: 494
diff changeset
507 /** Takes a serialized type and passes this to the handler */
507
ce49eae4c887 Codegen + Warning fixes
Benjamin Golinvaux <bgo@osimis.io>
parents: 499
diff changeset
508 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
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 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
511
fc17251477d6 TS and CPP 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 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
513 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
514
fc17251477d6 TS and CPP 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 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
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 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
518
fc17251477d6 TS and CPP 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 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
520 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
521 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
522 &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
523 &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
524 );
fc17251477d6 TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents: 490
diff changeset
525 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
526 {
fc17251477d6 TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents: 490
diff changeset
527 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
528 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
529 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
530 }
495
6405435480ae Fixed template to add dump capabilities + started work on an integrated TS/WASM test
bgo-osimis
parents: 494
diff changeset
531 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
532 }
fc17251477d6 TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents: 490
diff changeset
533
fc17251477d6 TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents: 490
diff changeset
534 #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
535 #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
536 #endif //_MSC_VER
490
6470248790db ongoing codegen work
bgo-osimis
parents:
diff changeset
537 }