Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(200)

Side by Side Diff: tools/json_schema_compiler/util.h

Issue 260893013: JSON Schema Compiler: Following r267534, properly convert arrays of enums (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: better Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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__
OLDNEW
« no previous file with comments | « tools/json_schema_compiler/cc_generator.py ('k') | tools/json_schema_compiler/util_cc_helper.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698