Chromium Code Reviews| 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)}}_Array_h | 5 #ifndef {{"_".join(config.protocol.namespace)}}_Array_h |
| 6 #define {{"_".join(config.protocol.namespace)}}_Array_h | 6 #define {{"_".join(config.protocol.namespace)}}_Array_h |
| 7 | 7 |
| 8 //#include "ErrorSupport.h" | 8 //#include "ErrorSupport.h" |
| 9 //#include "Forward.h" | 9 //#include "Forward.h" |
| 10 //#include "ValueConversions.h" | 10 //#include "ValueConversions.h" |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 50 size_t length() | 50 size_t length() |
| 51 { | 51 { |
| 52 return m_vector.size(); | 52 return m_vector.size(); |
| 53 } | 53 } |
| 54 | 54 |
| 55 T* get(size_t index) | 55 T* get(size_t index) |
| 56 { | 56 { |
| 57 return m_vector[index].get(); | 57 return m_vector[index].get(); |
| 58 } | 58 } |
| 59 | 59 |
| 60 std::unique_ptr<protocol::ListValue> serialize() | 60 std::unique_ptr<protocol::ListValue> serializeValue() |
|
dgozman
2016/11/22 19:39:24
Let's go for consistent naming:
- serialize which
kozy
2016/11/22 21:01:26
serialize - done.
toValue/fromValue - done.
| |
| 61 { | 61 { |
| 62 std::unique_ptr<protocol::ListValue> result = ListValue::create(); | 62 std::unique_ptr<protocol::ListValue> result = ListValue::create(); |
| 63 for (auto& item : m_vector) | 63 for (auto& item : m_vector) |
| 64 result->pushValue(ValueConversions<T>::serialize(item)); | 64 result->pushValue(ValueConversions<T>::serialize(item)); |
| 65 return result; | 65 return result; |
| 66 } | 66 } |
| 67 | 67 |
| 68 private: | 68 private: |
| 69 std::vector<std::unique_ptr<T>> m_vector; | 69 std::vector<std::unique_ptr<T>> m_vector; |
| 70 }; | 70 }; |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 105 size_t length() | 105 size_t length() |
| 106 { | 106 { |
| 107 return m_vector.size(); | 107 return m_vector.size(); |
| 108 } | 108 } |
| 109 | 109 |
| 110 T get(size_t index) | 110 T get(size_t index) |
| 111 { | 111 { |
| 112 return m_vector[index]; | 112 return m_vector[index]; |
| 113 } | 113 } |
| 114 | 114 |
| 115 std::unique_ptr<protocol::ListValue> serialize() | 115 std::unique_ptr<protocol::ListValue> serializeValue() |
| 116 { | 116 { |
| 117 std::unique_ptr<protocol::ListValue> result = ListValue::create(); | 117 std::unique_ptr<protocol::ListValue> result = ListValue::create(); |
| 118 for (auto& item : m_vector) | 118 for (auto& item : m_vector) |
| 119 result->pushValue(ValueConversions<T>::serialize(item)); | 119 result->pushValue(ValueConversions<T>::serialize(item)); |
| 120 return result; | 120 return result; |
| 121 } | 121 } |
| 122 | 122 |
| 123 private: | 123 private: |
| 124 std::vector<T> m_vector; | 124 std::vector<T> m_vector; |
| 125 }; | 125 }; |
| 126 | 126 |
| 127 template<> class Array<String> : public ArrayBase<String> {}; | 127 template<> class Array<String> : public ArrayBase<String> {}; |
| 128 template<> class Array<int> : public ArrayBase<int> {}; | 128 template<> class Array<int> : public ArrayBase<int> {}; |
| 129 template<> class Array<double> : public ArrayBase<double> {}; | 129 template<> class Array<double> : public ArrayBase<double> {}; |
| 130 template<> class Array<bool> : public ArrayBase<bool> {}; | 130 template<> class Array<bool> : public ArrayBase<bool> {}; |
| 131 | 131 |
| 132 {% for namespace in config.protocol.namespace %} | 132 {% for namespace in config.protocol.namespace %} |
| 133 } // namespace {{namespace}} | 133 } // namespace {{namespace}} |
| 134 {% endfor %} | 134 {% endfor %} |
| 135 | 135 |
| 136 #endif // !defined({{"_".join(config.protocol.namespace)}}_Array_h) | 136 #endif // !defined({{"_".join(config.protocol.namespace)}}_Array_h) |
| OLD | NEW |