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 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 } | 184 } |
185 | 185 |
186 template <class TParent, class T> | 186 template <class TParent, class T> |
187 scoped_ptr<base::Value> CreateValueFromOptionalEnumArray( | 187 scoped_ptr<base::Value> CreateValueFromOptionalEnumArray( |
188 const scoped_ptr<std::vector<T> >& from) { | 188 const scoped_ptr<std::vector<T> >& from) { |
189 if (from.get()) | 189 if (from.get()) |
190 return CreateValueFromEnumArray<TParent>(*from); | 190 return CreateValueFromEnumArray<TParent>(*from); |
191 return scoped_ptr<base::Value>(); | 191 return scoped_ptr<base::Value>(); |
192 } | 192 } |
193 | 193 |
| 194 template <class T> |
| 195 scoped_ptr<base::Value> CreateValueFromEnumArrayWithoutNamespace( |
| 196 const std::vector<T>& from) { |
| 197 base::ListValue* list = new base::ListValue(); |
| 198 for (typename std::vector<T>::const_iterator it = from.begin(); |
| 199 it != from.end(); ++it) { |
| 200 list->AppendString(ToString(*it)); |
| 201 } |
| 202 return scoped_ptr<base::Value>(list); |
| 203 } |
| 204 |
| 205 template <class T> |
| 206 scoped_ptr<base::Value> CreateValueFromOptionalEnumArrayWithoutNamespace( |
| 207 const scoped_ptr<std::vector<T> >& from) { |
| 208 if (from.get()) |
| 209 return CreateValueFromEnumArrayWithoutNamespace(*from); |
| 210 return scoped_ptr<base::Value>(); |
| 211 } |
| 212 |
194 std::string ValueTypeToString(base::Value::Type type); | 213 std::string ValueTypeToString(base::Value::Type type); |
195 | 214 |
196 } // namespace util | 215 } // namespace util |
197 } // namespace json_schema_compiler | 216 } // namespace json_schema_compiler |
198 | 217 |
199 #endif // TOOLS_JSON_SCHEMA_COMPILER_UTIL_H__ | 218 #endif // TOOLS_JSON_SCHEMA_COMPILER_UTIL_H__ |
OLD | NEW |