annotate Applications/Samples/StoneSampleCommands_generated.hpp @ 527:b1377625e4ba bgo-commands-codegen

Removed ICommand and friends + fixed warnings + added missing header files in solution (in CMakeLists.txt file)
author Benjamin Golinvaux <bgo@osimis.io>
date Sun, 17 Mar 2019 20:14:20 +0100
parents
children 79bb0a02d1cc
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
527
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
1 /*
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
2 1 2 3 4 5 6 7
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
3 12345678901234567890123456789012345678901234567890123456789012345678901234567890
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
4
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
5 Generated on 2019-03-15 10:00:48.763392 by stonegentool
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
6
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
7 */
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
8 #pragma once
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
9
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
10 #include <exception>
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
11 #include <iostream>
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
12 #include <string>
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
13 #include <sstream>
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
14 #include <assert.h>
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
15 #include <memory>
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
16 #include <json/json.h>
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
17
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
18 //#define STONEGEN_NO_CPP11 1
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
19
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
20 #ifdef STONEGEN_NO_CPP11
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
21 #define StoneSmartPtr std::auto_ptr
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
22 #else
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
23 #define StoneSmartPtr std::unique_ptr
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
24 #endif
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
25
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
26 namespace StoneSampleCommands
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
27 {
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
28 /** Throws in case of problem */
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
29 inline void _StoneDeserializeValue(int32_t& destValue, const Json::Value& jsonValue)
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
30 {
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
31 destValue = jsonValue.asInt();
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
32 }
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
33
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
34 inline Json::Value _StoneSerializeValue(int32_t value)
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
35 {
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
36 Json::Value result(value);
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
37 return result;
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
38 }
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
39
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
40 inline void _StoneDeserializeValue(Json::Value& destValue, const Json::Value& jsonValue)
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
41 {
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
42 destValue = jsonValue;
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
43 }
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
44
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
45 inline Json::Value _StoneSerializeValue(Json::Value value)
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
46 {
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
47 return value;
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
48 }
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
49
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
50 /** Throws in case of problem */
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
51 inline void _StoneDeserializeValue(double& destValue, const Json::Value& jsonValue)
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
52 {
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
53 destValue = jsonValue.asDouble();
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
54 }
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
55
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
56 inline Json::Value _StoneSerializeValue(double value)
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
57 {
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
58 Json::Value result(value);
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
59 return result;
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
60 }
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
61
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
62 /** Throws in case of problem */
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
63 inline void _StoneDeserializeValue(bool& destValue, const Json::Value& jsonValue)
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
64 {
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
65 destValue = jsonValue.asBool();
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
66 }
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
67
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
68 inline Json::Value _StoneSerializeValue(bool value)
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
69 {
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
70 Json::Value result(value);
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
71 return result;
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
72 }
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
73
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
74 /** Throws in case of problem */
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
75 inline void _StoneDeserializeValue(
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
76 std::string& destValue
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
77 , const Json::Value& jsonValue)
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
78 {
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
79 destValue = jsonValue.asString();
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
80 }
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
81
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
82 inline Json::Value _StoneSerializeValue(const std::string& value)
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
83 {
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
84 // the following is better than
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
85 Json::Value result(value.data(),value.data()+value.size());
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
86 return result;
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
87 }
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
88
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
89 inline std::string MakeIndent(int indent)
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
90 {
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
91 char* txt = reinterpret_cast<char*>(malloc(indent+1)); // NO EXCEPTION BELOW!!!!!!!!!!!!
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
92 for(size_t i = 0; i < indent; ++i)
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
93 txt[i] = ' ';
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
94 txt[indent] = 0;
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
95 std::string retVal(txt);
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
96 free(txt); // NO EXCEPTION ABOVE !!!!!!!!!!
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
97 return retVal;
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
98 }
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
99
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
100 // generic dumper
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
101 template<typename T>
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
102 std::ostream& StoneDumpValue(std::ostream& out, const T& value, int indent)
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
103 {
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
104 out << MakeIndent(indent) << value;
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
105 return out;
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
106 }
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
107
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
108 // string dumper
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
109 inline std::ostream& StoneDumpValue(std::ostream& out, const std::string& value, int indent)
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
110 {
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
111 out << MakeIndent(indent) << "\"" << value << "\"";
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
112 return out;
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
113 }
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
114
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
115 /** Throws in case of problem */
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
116 template<typename T>
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
117 void _StoneDeserializeValue(
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
118 std::map<std::string, T>& destValue, const Json::Value& jsonValue)
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
119 {
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
120 destValue.clear();
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
121 for (
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
122 Json::Value::const_iterator itr = jsonValue.begin();
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
123 itr != jsonValue.end();
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
124 itr++)
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
125 {
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
126 std::string key;
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
127 _StoneDeserializeValue(key, itr.key());
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
128
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
129 T innerDestValue;
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
130 _StoneDeserializeValue(innerDestValue, *itr);
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
131
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
132 destValue[key] = innerDestValue;
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
133 }
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
134 }
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
135
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
136 template<typename T>
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
137 Json::Value _StoneSerializeValue(const std::map<std::string,T>& value)
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
138 {
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
139 Json::Value result(Json::objectValue);
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
140
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
141 for (typename std::map<std::string, T>::const_iterator it = value.cbegin();
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
142 it != value.cend(); ++it)
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
143 {
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
144 // it->first it->second
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
145 result[it->first] = _StoneSerializeValue(it->second);
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
146 }
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
147 return result;
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
148 }
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
149
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
150 template<typename T>
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
151 std::ostream& StoneDumpValue(std::ostream& out, const std::map<std::string,T>& value, int indent)
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
152 {
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
153 out << MakeIndent(indent) << "{\n";
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
154 for (typename std::map<std::string, T>::const_iterator it = value.cbegin();
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
155 it != value.cend(); ++it)
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
156 {
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
157 out << MakeIndent(indent+2) << "\"" << it->first << "\" : ";
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
158 StoneDumpValue(out, it->second, indent+2);
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
159 }
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
160 out << MakeIndent(indent) << "}\n";
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
161 return out;
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
162 }
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
163
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
164 /** Throws in case of problem */
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
165 template<typename T>
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
166 void _StoneDeserializeValue(
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
167 std::vector<T>& destValue, const Json::Value& jsonValue)
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
168 {
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
169 destValue.clear();
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
170 destValue.reserve(jsonValue.size());
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
171 for (Json::Value::ArrayIndex i = 0; i != jsonValue.size(); i++)
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
172 {
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
173 T innerDestValue;
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
174 _StoneDeserializeValue(innerDestValue, jsonValue[i]);
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
175 destValue.push_back(innerDestValue);
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
176 }
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
177 }
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
178
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
179 template<typename T>
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
180 Json::Value _StoneSerializeValue(const std::vector<T>& value)
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
181 {
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
182 Json::Value result(Json::arrayValue);
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
183 for (size_t i = 0; i < value.size(); ++i)
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
184 {
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
185 result.append(_StoneSerializeValue(value[i]));
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
186 }
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
187 return result;
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
188 }
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
189
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
190 template<typename T>
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
191 std::ostream& StoneDumpValue(std::ostream& out, const std::vector<T>& value, int indent)
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
192 {
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
193 out << MakeIndent(indent) << "[\n";
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
194 for (size_t i = 0; i < value.size(); ++i)
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
195 {
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
196 StoneDumpValue(out, value[i], indent+2);
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
197 }
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
198 out << MakeIndent(indent) << "]\n";
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
199 return out;
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
200 }
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
201
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
202 inline void StoneCheckSerializedValueTypeGeneric(const Json::Value& value)
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
203 {
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
204 if ((!value.isMember("type")) || (!value["type"].isString()))
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
205 {
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
206 std::stringstream ss;
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
207 ss << "Cannot deserialize value ('type' key invalid)";
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
208 throw std::runtime_error(ss.str());
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
209 }
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
210 }
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
211
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
212 inline void StoneCheckSerializedValueType(
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
213 const Json::Value& value, std::string typeStr)
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
214 {
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
215 StoneCheckSerializedValueTypeGeneric(value);
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
216
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
217 std::string actTypeStr = value["type"].asString();
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
218 if (actTypeStr != typeStr)
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
219 {
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
220 std::stringstream ss;
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
221 ss << "Cannot deserialize type" << actTypeStr
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
222 << "into " << typeStr;
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
223 throw std::runtime_error(ss.str());
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
224 }
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
225 }
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
226
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
227 // end of generic methods
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
228
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
229 // end of generic methods
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
230
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
231 enum Tool {
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
232 Tool_LineMeasure,
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
233 Tool_CircleMeasure,
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
234 Tool_Crop,
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
235 Tool_Windowing,
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
236 Tool_Zoom,
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
237 Tool_Pan,
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
238 Tool_Move,
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
239 Tool_Rotate,
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
240 Tool_Resize,
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
241 Tool_Mask,
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
242 };
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
243
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
244 inline std::string ToString(const Tool& value)
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
245 {
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
246 if( value == Tool_LineMeasure)
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
247 {
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
248 return std::string("LineMeasure");
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
249 }
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
250 if( value == Tool_CircleMeasure)
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
251 {
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
252 return std::string("CircleMeasure");
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
253 }
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
254 if( value == Tool_Crop)
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
255 {
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
256 return std::string("Crop");
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
257 }
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
258 if( value == Tool_Windowing)
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
259 {
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
260 return std::string("Windowing");
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
261 }
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
262 if( value == Tool_Zoom)
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
263 {
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
264 return std::string("Zoom");
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
265 }
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
266 if( value == Tool_Pan)
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
267 {
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
268 return std::string("Pan");
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
269 }
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
270 if( value == Tool_Move)
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
271 {
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
272 return std::string("Move");
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
273 }
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
274 if( value == Tool_Rotate)
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
275 {
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
276 return std::string("Rotate");
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
277 }
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
278 if( value == Tool_Resize)
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
279 {
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
280 return std::string("Resize");
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
281 }
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
282 if( value == Tool_Mask)
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
283 {
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
284 return std::string("Mask");
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
285 }
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
286 std::stringstream ss;
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
287 ss << "Value \"" << value << "\" cannot be converted to Tool. Possible values are: "
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
288 << " LineMeasure = " << static_cast<int64_t>(Tool_LineMeasure) << ", "
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
289 << " CircleMeasure = " << static_cast<int64_t>(Tool_CircleMeasure) << ", "
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
290 << " Crop = " << static_cast<int64_t>(Tool_Crop) << ", "
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
291 << " Windowing = " << static_cast<int64_t>(Tool_Windowing) << ", "
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
292 << " Zoom = " << static_cast<int64_t>(Tool_Zoom) << ", "
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
293 << " Pan = " << static_cast<int64_t>(Tool_Pan) << ", "
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
294 << " Move = " << static_cast<int64_t>(Tool_Move) << ", "
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
295 << " Rotate = " << static_cast<int64_t>(Tool_Rotate) << ", "
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
296 << " Resize = " << static_cast<int64_t>(Tool_Resize) << ", "
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
297 << " Mask = " << static_cast<int64_t>(Tool_Mask) << ", "
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
298 << std::endl;
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
299 std::string msg = ss.str();
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
300 throw std::runtime_error(msg);
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
301 }
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
302
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
303 inline void FromString(Tool& value, std::string strValue)
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
304 {
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
305 if( strValue == std::string("LineMeasure") )
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
306 {
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
307 value = Tool_LineMeasure;
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
308 return;
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
309 }
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
310 if( strValue == std::string("CircleMeasure") )
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
311 {
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
312 value = Tool_CircleMeasure;
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
313 return;
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
314 }
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
315 if( strValue == std::string("Crop") )
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
316 {
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
317 value = Tool_Crop;
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
318 return;
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
319 }
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
320 if( strValue == std::string("Windowing") )
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
321 {
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
322 value = Tool_Windowing;
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
323 return;
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
324 }
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
325 if( strValue == std::string("Zoom") )
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
326 {
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
327 value = Tool_Zoom;
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
328 return;
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
329 }
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
330 if( strValue == std::string("Pan") )
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
331 {
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
332 value = Tool_Pan;
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
333 return;
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
334 }
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
335 if( strValue == std::string("Move") )
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
336 {
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
337 value = Tool_Move;
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
338 return;
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
339 }
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
340 if( strValue == std::string("Rotate") )
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
341 {
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
342 value = Tool_Rotate;
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
343 return;
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
344 }
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
345 if( strValue == std::string("Resize") )
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
346 {
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
347 value = Tool_Resize;
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
348 return;
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
349 }
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
350 if( strValue == std::string("Mask") )
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
351 {
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
352 value = Tool_Mask;
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
353 return;
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
354 }
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
355
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
356 std::stringstream ss;
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
357 ss << "String \"" << strValue << "\" cannot be converted to Tool. Possible values are: LineMeasure CircleMeasure Crop Windowing Zoom Pan Move Rotate Resize Mask ";
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
358 std::string msg = ss.str();
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
359 throw std::runtime_error(msg);
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
360 }
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
361
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
362
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
363 inline void _StoneDeserializeValue(
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
364 Tool& destValue, const Json::Value& jsonValue)
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
365 {
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
366 FromString(destValue, jsonValue.asString());
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
367 }
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
368
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
369 inline Json::Value _StoneSerializeValue(const Tool& value)
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
370 {
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
371 std::string strValue = ToString(value);
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
372 return Json::Value(strValue);
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
373 }
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
374
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
375 inline std::ostream& StoneDumpValue(std::ostream& out, const Tool& value, int indent = 0)
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
376 {
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
377 if( value == Tool_LineMeasure)
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
378 {
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
379 out << MakeIndent(indent) << "LineMeasure" << std::endl;
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
380 }
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
381 if( value == Tool_CircleMeasure)
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
382 {
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
383 out << MakeIndent(indent) << "CircleMeasure" << std::endl;
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
384 }
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
385 if( value == Tool_Crop)
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
386 {
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
387 out << MakeIndent(indent) << "Crop" << std::endl;
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
388 }
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
389 if( value == Tool_Windowing)
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
390 {
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
391 out << MakeIndent(indent) << "Windowing" << std::endl;
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
392 }
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
393 if( value == Tool_Zoom)
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
394 {
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
395 out << MakeIndent(indent) << "Zoom" << std::endl;
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
396 }
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
397 if( value == Tool_Pan)
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
398 {
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
399 out << MakeIndent(indent) << "Pan" << std::endl;
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
400 }
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
401 if( value == Tool_Move)
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
402 {
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
403 out << MakeIndent(indent) << "Move" << std::endl;
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
404 }
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
405 if( value == Tool_Rotate)
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
406 {
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
407 out << MakeIndent(indent) << "Rotate" << std::endl;
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
408 }
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
409 if( value == Tool_Resize)
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
410 {
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
411 out << MakeIndent(indent) << "Resize" << std::endl;
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
412 }
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
413 if( value == Tool_Mask)
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
414 {
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
415 out << MakeIndent(indent) << "Mask" << std::endl;
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
416 }
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
417 return out;
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
418 }
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
419
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
420
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
421 enum ActionType {
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
422 ActionType_UndoCrop,
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
423 ActionType_Rotate,
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
424 ActionType_Invert,
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
425 };
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
426
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
427 inline std::string ToString(const ActionType& value)
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
428 {
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
429 if( value == ActionType_UndoCrop)
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
430 {
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
431 return std::string("UndoCrop");
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
432 }
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
433 if( value == ActionType_Rotate)
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
434 {
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
435 return std::string("Rotate");
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
436 }
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
437 if( value == ActionType_Invert)
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
438 {
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
439 return std::string("Invert");
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
440 }
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
441 std::stringstream ss;
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
442 ss << "Value \"" << value << "\" cannot be converted to ActionType. Possible values are: "
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
443 << " UndoCrop = " << static_cast<int64_t>(ActionType_UndoCrop) << ", "
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
444 << " Rotate = " << static_cast<int64_t>(ActionType_Rotate) << ", "
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
445 << " Invert = " << static_cast<int64_t>(ActionType_Invert) << ", "
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
446 << std::endl;
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
447 std::string msg = ss.str();
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
448 throw std::runtime_error(msg);
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
449 }
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
450
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
451 inline void FromString(ActionType& value, std::string strValue)
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
452 {
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
453 if( strValue == std::string("UndoCrop") )
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
454 {
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
455 value = ActionType_UndoCrop;
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
456 return;
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
457 }
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
458 if( strValue == std::string("Rotate") )
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
459 {
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
460 value = ActionType_Rotate;
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
461 return;
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
462 }
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
463 if( strValue == std::string("Invert") )
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
464 {
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
465 value = ActionType_Invert;
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
466 return;
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
467 }
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
468
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
469 std::stringstream ss;
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
470 ss << "String \"" << strValue << "\" cannot be converted to ActionType. Possible values are: UndoCrop Rotate Invert ";
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
471 std::string msg = ss.str();
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
472 throw std::runtime_error(msg);
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
473 }
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
474
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
475
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
476 inline void _StoneDeserializeValue(
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
477 ActionType& destValue, const Json::Value& jsonValue)
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
478 {
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
479 FromString(destValue, jsonValue.asString());
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
480 }
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
481
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
482 inline Json::Value _StoneSerializeValue(const ActionType& value)
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
483 {
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
484 std::string strValue = ToString(value);
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
485 return Json::Value(strValue);
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
486 }
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
487
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
488 inline std::ostream& StoneDumpValue(std::ostream& out, const ActionType& value, int indent = 0)
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
489 {
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
490 if( value == ActionType_UndoCrop)
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
491 {
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
492 out << MakeIndent(indent) << "UndoCrop" << std::endl;
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
493 }
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
494 if( value == ActionType_Rotate)
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
495 {
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
496 out << MakeIndent(indent) << "Rotate" << std::endl;
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
497 }
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
498 if( value == ActionType_Invert)
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
499 {
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
500 out << MakeIndent(indent) << "Invert" << std::endl;
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
501 }
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
502 return out;
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
503 }
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
504
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
505
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
506
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
507 #ifdef _MSC_VER
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
508 #pragma region SelectTool
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
509 #endif //_MSC_VER
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
510
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
511 struct SelectTool
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
512 {
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
513 Tool tool;
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
514
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
515 SelectTool(Tool tool = Tool())
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
516 {
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
517 this->tool = tool;
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
518 }
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
519 };
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
520
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
521 inline void _StoneDeserializeValue(SelectTool& destValue, const Json::Value& value)
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
522 {
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
523 _StoneDeserializeValue(destValue.tool, value["tool"]);
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
524 }
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
525
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
526 inline Json::Value _StoneSerializeValue(const SelectTool& value)
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
527 {
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
528 Json::Value result(Json::objectValue);
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
529 result["tool"] = _StoneSerializeValue(value.tool);
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
530
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
531 return result;
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
532 }
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
533
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
534 inline std::ostream& StoneDumpValue(std::ostream& out, const SelectTool& value, int indent = 0)
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
535 {
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
536 out << MakeIndent(indent) << "{\n";
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
537 out << MakeIndent(indent) << "tool:\n";
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
538 StoneDumpValue(out, value.tool,indent+2);
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
539 out << "\n";
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
540
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
541 out << MakeIndent(indent) << "}\n";
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
542 return out;
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
543 }
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
544
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
545 inline void StoneDeserialize(SelectTool& destValue, const Json::Value& value)
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
546 {
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
547 StoneCheckSerializedValueType(value, "StoneSampleCommands.SelectTool");
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
548 _StoneDeserializeValue(destValue, value["value"]);
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
549 }
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
550
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
551 inline Json::Value StoneSerializeToJson(const SelectTool& value)
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
552 {
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
553 Json::Value result(Json::objectValue);
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
554 result["type"] = "StoneSampleCommands.SelectTool";
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
555 result["value"] = _StoneSerializeValue(value);
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
556 return result;
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
557 }
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
558
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
559 inline std::string StoneSerialize(const SelectTool& value)
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
560 {
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
561 Json::Value resultJson = StoneSerializeToJson(value);
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
562 std::string resultStr = resultJson.toStyledString();
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
563 return resultStr;
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
564 }
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
565
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
566 #ifdef _MSC_VER
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
567 #pragma endregion SelectTool
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
568 #endif //_MSC_VER
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
569
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
570 #ifdef _MSC_VER
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
571 #pragma region Action
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
572 #endif //_MSC_VER
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
573
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
574 struct Action
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
575 {
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
576 ActionType type;
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
577
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
578 Action(ActionType type = ActionType())
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
579 {
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
580 this->type = type;
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
581 }
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
582 };
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
583
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
584 inline void _StoneDeserializeValue(Action& destValue, const Json::Value& value)
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
585 {
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
586 _StoneDeserializeValue(destValue.type, value["type"]);
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
587 }
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
588
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
589 inline Json::Value _StoneSerializeValue(const Action& value)
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
590 {
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
591 Json::Value result(Json::objectValue);
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
592 result["type"] = _StoneSerializeValue(value.type);
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
593
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
594 return result;
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
595 }
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
596
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
597 inline std::ostream& StoneDumpValue(std::ostream& out, const Action& value, int indent = 0)
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
598 {
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
599 out << MakeIndent(indent) << "{\n";
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
600 out << MakeIndent(indent) << "type:\n";
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
601 StoneDumpValue(out, value.type,indent+2);
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
602 out << "\n";
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
603
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
604 out << MakeIndent(indent) << "}\n";
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
605 return out;
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
606 }
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
607
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
608 inline void StoneDeserialize(Action& destValue, const Json::Value& value)
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
609 {
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
610 StoneCheckSerializedValueType(value, "StoneSampleCommands.Action");
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
611 _StoneDeserializeValue(destValue, value["value"]);
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
612 }
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
613
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
614 inline Json::Value StoneSerializeToJson(const Action& value)
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
615 {
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
616 Json::Value result(Json::objectValue);
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
617 result["type"] = "StoneSampleCommands.Action";
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
618 result["value"] = _StoneSerializeValue(value);
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
619 return result;
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
620 }
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
621
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
622 inline std::string StoneSerialize(const Action& value)
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
623 {
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
624 Json::Value resultJson = StoneSerializeToJson(value);
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
625 std::string resultStr = resultJson.toStyledString();
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
626 return resultStr;
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
627 }
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
628
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
629 #ifdef _MSC_VER
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
630 #pragma endregion Action
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
631 #endif //_MSC_VER
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
632
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
633 #ifdef _MSC_VER
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
634 #pragma region Dispatching code
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
635 #endif //_MSC_VER
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
636
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
637 class IHandler
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
638 {
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
639 public:
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
640 virtual bool Handle(const SelectTool& value) = 0;
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
641 };
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
642
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
643 /** Service function for StoneDispatchToHandler */
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
644 inline bool StoneDispatchJsonToHandler(
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
645 const Json::Value& jsonValue, IHandler* handler)
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
646 {
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
647 StoneCheckSerializedValueTypeGeneric(jsonValue);
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
648 std::string type = jsonValue["type"].asString();
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
649 if (type == "")
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
650 {
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
651 // this should never ever happen
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
652 throw std::runtime_error("Caught empty type while dispatching");
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
653 }
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
654 else if (type == "StoneSampleCommands.SelectTool")
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
655 {
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
656 SelectTool value;
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
657 _StoneDeserializeValue(value, jsonValue["value"]);
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
658 return handler->Handle(value);
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
659 }
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
660 else
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
661 {
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
662 return false;
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
663 }
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
664 }
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
665
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
666 /** Takes a serialized type and passes this to the handler */
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
667 inline bool StoneDispatchToHandler(std::string strValue, IHandler* handler)
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
668 {
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
669 Json::Value readValue;
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
670
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
671 Json::CharReaderBuilder builder;
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
672 Json::CharReader* reader = builder.newCharReader();
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
673
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
674 StoneSmartPtr<Json::CharReader> ptr(reader);
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
675
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
676 std::string errors;
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
677
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
678 bool ok = reader->parse(
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
679 strValue.c_str(),
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
680 strValue.c_str() + strValue.size(),
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
681 &readValue,
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
682 &errors
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
683 );
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
684 if (!ok)
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
685 {
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
686 std::stringstream ss;
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
687 ss << "Jsoncpp parsing error: " << errors;
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
688 throw std::runtime_error(ss.str());
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
689 }
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
690 return StoneDispatchJsonToHandler(readValue, handler);
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
691 }
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
692
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
693 #ifdef _MSC_VER
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
694 #pragma endregion Dispatching code
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
695 #endif //_MSC_VER
b1377625e4ba Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
696 }