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 24 matching lines...) Expand all Loading... | |
35 errors->setName(StringUtil::fromInteger(i)); | 35 errors->setName(StringUtil::fromInteger(i)); |
36 std::unique_ptr<T> item = ValueConversions<T>::parse(array->at(i), e rrors); | 36 std::unique_ptr<T> item = ValueConversions<T>::parse(array->at(i), e rrors); |
37 result->m_vector.push_back(std::move(item)); | 37 result->m_vector.push_back(std::move(item)); |
38 } | 38 } |
39 errors->pop(); | 39 errors->pop(); |
40 if (errors->hasErrors()) | 40 if (errors->hasErrors()) |
41 return nullptr; | 41 return nullptr; |
42 return result; | 42 return result; |
43 } | 43 } |
44 | 44 |
45 Array() {} | |
dgozman
2016/10/12 21:00:40
Why not Array::create() defined above?
alex clarke (OOO till 29th)
2016/10/13 20:25:10
I'm assuming you don't want this to be public?
dgozman
2016/10/14 01:32:33
Yes.
| |
46 explicit Array(std::vector<std::unique_ptr<T>> vector) : m_vector(std::move( vector)) { } | |
dgozman
2016/10/12 21:00:40
Let's do
static std::unique_ptr<Array<T>> fromVect
alex clarke (OOO till 29th)
2016/10/13 20:25:10
Done.
| |
47 | |
45 void addItem(std::unique_ptr<T> value) | 48 void addItem(std::unique_ptr<T> value) |
46 { | 49 { |
47 m_vector.push_back(std::move(value)); | 50 m_vector.push_back(std::move(value)); |
48 } | 51 } |
49 | 52 |
50 size_t length() | 53 size_t length() |
51 { | 54 { |
52 return m_vector.size(); | 55 return m_vector.size(); |
53 } | 56 } |
54 | 57 |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
127 template<> class Array<String> : public ArrayBase<String> {}; | 130 template<> class Array<String> : public ArrayBase<String> {}; |
128 template<> class Array<int> : public ArrayBase<int> {}; | 131 template<> class Array<int> : public ArrayBase<int> {}; |
129 template<> class Array<double> : public ArrayBase<double> {}; | 132 template<> class Array<double> : public ArrayBase<double> {}; |
130 template<> class Array<bool> : public ArrayBase<bool> {}; | 133 template<> class Array<bool> : public ArrayBase<bool> {}; |
131 | 134 |
132 {% for namespace in config.protocol.namespace %} | 135 {% for namespace in config.protocol.namespace %} |
133 } // namespace {{namespace}} | 136 } // namespace {{namespace}} |
134 {% endfor %} | 137 {% endfor %} |
135 | 138 |
136 #endif // !defined({{"_".join(config.protocol.namespace)}}_Array_h) | 139 #endif // !defined({{"_".join(config.protocol.namespace)}}_Array_h) |
OLD | NEW |