OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef {{"_".join(config.protocol.namespace)}}_ValueConversions_h | 5 #ifndef {{"_".join(config.protocol.namespace)}}_ValueConversions_h |
6 #define {{"_".join(config.protocol.namespace)}}_ValueConversions_h | 6 #define {{"_".join(config.protocol.namespace)}}_ValueConversions_h |
7 | 7 |
8 //#include "ErrorSupport.h" | 8 //#include "ErrorSupport.h" |
9 //#include "Forward.h" | 9 //#include "Forward.h" |
10 //#include "Values.h" | 10 //#include "Values.h" |
11 | 11 |
12 {% for namespace in config.protocol.namespace %} | 12 {% for namespace in config.protocol.namespace %} |
13 namespace {{namespace}} { | 13 namespace {{namespace}} { |
14 {% endfor %} | 14 {% endfor %} |
15 | 15 |
16 template<typename T> | 16 template<typename T> |
17 struct ValueConversions { | 17 struct ValueConversions { |
18 static std::unique_ptr<T> parse(protocol::Value* value, ErrorSupport* errors
) | 18 static std::unique_ptr<T> parse(protocol::Value* value, ErrorSupport* errors
) |
19 { | 19 { |
20 return T::parse(value, errors); | 20 return T::parse(value, errors); |
21 } | 21 } |
22 | 22 |
23 static std::unique_ptr<protocol::Value> serialize(T* value) | 23 static std::unique_ptr<protocol::Value> serialize(T* value) |
24 { | 24 { |
25 return value->serialize(); | 25 return value->serializeValue(); |
26 } | 26 } |
27 | 27 |
28 static std::unique_ptr<protocol::Value> serialize(const std::unique_ptr<T>&
value) | 28 static std::unique_ptr<protocol::Value> serialize(const std::unique_ptr<T>&
value) |
29 { | 29 { |
30 return value->serialize(); | 30 return value->serializeValue(); |
31 } | 31 } |
32 }; | 32 }; |
33 | 33 |
34 template<> | 34 template<> |
35 struct ValueConversions<bool> { | 35 struct ValueConversions<bool> { |
36 static bool parse(protocol::Value* value, ErrorSupport* errors) | 36 static bool parse(protocol::Value* value, ErrorSupport* errors) |
37 { | 37 { |
38 bool result = false; | 38 bool result = false; |
39 bool success = value ? value->asBoolean(&result) : false; | 39 bool success = value ? value->asBoolean(&result) : false; |
40 if (!success) | 40 if (!success) |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 { | 162 { |
163 return value->clone(); | 163 return value->clone(); |
164 } | 164 } |
165 }; | 165 }; |
166 | 166 |
167 {% for namespace in config.protocol.namespace %} | 167 {% for namespace in config.protocol.namespace %} |
168 } // namespace {{namespace}} | 168 } // namespace {{namespace}} |
169 {% endfor %} | 169 {% endfor %} |
170 | 170 |
171 #endif // !defined({{"_".join(config.protocol.namespace)}}_ValueConversions_h) | 171 #endif // !defined({{"_".join(config.protocol.namespace)}}_ValueConversions_h) |
OLD | NEW |