OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 TOOLS_JSON_SCHEMA_COMPILER_UTIL_H__ | 5 #ifndef TOOLS_JSON_SCHEMA_COMPILER_UTIL_H__ |
6 #define TOOLS_JSON_SCHEMA_COMPILER_UTIL_H__ | 6 #define TOOLS_JSON_SCHEMA_COMPILER_UTIL_H__ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
165 return scoped_ptr<base::Value>(list); | 165 return scoped_ptr<base::Value>(list); |
166 } | 166 } |
167 | 167 |
168 template <class T> | 168 template <class T> |
169 scoped_ptr<base::Value> CreateValueFromOptionalArray( | 169 scoped_ptr<base::Value> CreateValueFromOptionalArray( |
170 const scoped_ptr<std::vector<T> >& from) { | 170 const scoped_ptr<std::vector<T> >& from) { |
171 if (from.get()) | 171 if (from.get()) |
172 return CreateValueFromArray(*from); | 172 return CreateValueFromArray(*from); |
173 return scoped_ptr<base::Value>(); | 173 return scoped_ptr<base::Value>(); |
174 } | 174 } |
175 | 175 |
wjywbs
2014/05/09 14:13:21
sorry for "reverting" your changes... but ToString
not at google - send to devlin
2014/05/12 21:46:13
Yes. I should have reverted this earlier :)
| |
176 template <class TParent, class T> | |
177 scoped_ptr<base::Value> CreateValueFromEnumArray(const std::vector<T>& from) { | |
178 base::ListValue* list = new base::ListValue(); | |
179 for (typename std::vector<T>::const_iterator it = from.begin(); | |
180 it != from.end(); ++it) { | |
181 list->AppendString(TParent::ToString(*it)); | |
182 } | |
183 return scoped_ptr<base::Value>(list); | |
184 } | |
185 | |
186 template <class TParent, class T> | |
187 scoped_ptr<base::Value> CreateValueFromOptionalEnumArray( | |
188 const scoped_ptr<std::vector<T> >& from) { | |
189 if (from.get()) | |
190 return CreateValueFromEnumArray<TParent>(*from); | |
191 return scoped_ptr<base::Value>(); | |
192 } | |
193 | |
194 std::string ValueTypeToString(base::Value::Type type); | 176 std::string ValueTypeToString(base::Value::Type type); |
195 | 177 |
196 } // namespace util | 178 } // namespace util |
197 } // namespace json_schema_compiler | 179 } // namespace json_schema_compiler |
198 | 180 |
199 #endif // TOOLS_JSON_SCHEMA_COMPILER_UTIL_H__ | 181 #endif // TOOLS_JSON_SCHEMA_COMPILER_UTIL_H__ |
OLD | NEW |