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

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

Issue 10837044: Correct const accessors in base/values.(h|cc), Part II (ListValue) (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: David's comments Created 8 years, 4 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
« no previous file with comments | « tools/json_schema_compiler/cc_generator.py ('k') | tools/json_schema_compiler/util.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 16 matching lines...) Expand all
27 bool GetItemFromList(const ListValue& from, int index, double* out); 27 bool GetItemFromList(const ListValue& from, int index, double* out);
28 bool GetItemFromList(const ListValue& from, int index, std::string* out); 28 bool GetItemFromList(const ListValue& from, int index, std::string* out);
29 bool GetItemFromList(const ListValue& from, int index, 29 bool GetItemFromList(const ListValue& from, int index,
30 linked_ptr<base::DictionaryValue>* out); 30 linked_ptr<base::DictionaryValue>* out);
31 bool GetItemFromList(const ListValue& from, int index, 31 bool GetItemFromList(const ListValue& from, int index,
32 linked_ptr<any::Any>* out); 32 linked_ptr<any::Any>* out);
33 33
34 // This template is used for types generated by tools/json_schema_compiler. 34 // This template is used for types generated by tools/json_schema_compiler.
35 template<class T> 35 template<class T>
36 bool GetItemFromList(const ListValue& from, int index, linked_ptr<T>* out) { 36 bool GetItemFromList(const ListValue& from, int index, linked_ptr<T>* out) {
37 DictionaryValue* dict; 37 const DictionaryValue* dict;
38 if (!from.GetDictionary(index, &dict)) 38 if (!from.GetDictionary(index, &dict))
39 return false; 39 return false;
40 scoped_ptr<T> obj(new T()); 40 scoped_ptr<T> obj(new T());
41 if (!T::Populate(*dict, obj.get())) 41 if (!T::Populate(*dict, obj.get()))
42 return false; 42 return false;
43 *out = linked_ptr<T>(obj.release()); 43 *out = linked_ptr<T>(obj.release());
44 return true; 44 return true;
45 } 45 }
46 46
47 // Populates |out| with |list|. Returns false if there is no list at the 47 // Populates |out| with |list|. Returns false if there is no list at the
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 const scoped_ptr<std::vector<T> >& from) { 171 const scoped_ptr<std::vector<T> >& from) {
172 if (from.get()) 172 if (from.get())
173 return CreateValueFromArray(*from); 173 return CreateValueFromArray(*from);
174 return scoped_ptr<Value>(); 174 return scoped_ptr<Value>();
175 } 175 }
176 176
177 } // namespace util 177 } // namespace util
178 } // namespace json_schema_compiler 178 } // namespace json_schema_compiler
179 179
180 #endif // TOOLS_JSON_SCHEMA_COMPILER_UTIL_H__ 180 #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 » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698