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

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

Issue 17034006: Add base namespace to more values in sync and elsewhere. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 6 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
« no previous file with comments | « tools/json_schema_compiler/util.h ('k') | ui/webui/jstemplate_builder.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 #include "tools/json_schema_compiler/util.h" 5 #include "tools/json_schema_compiler/util.h"
6 6
7 #include "base/values.h" 7 #include "base/values.h"
8 8
9 namespace json_schema_compiler { 9 namespace json_schema_compiler {
10 namespace util { 10 namespace util {
11 11
12 bool GetItemFromList(const ListValue& from, int index, int* out) { 12 bool GetItemFromList(const base::ListValue& from, int index, int* out) {
13 return from.GetInteger(index, out); 13 return from.GetInteger(index, out);
14 } 14 }
15 15
16 bool GetItemFromList(const ListValue& from, int index, bool* out) { 16 bool GetItemFromList(const base::ListValue& from, int index, bool* out) {
17 return from.GetBoolean(index, out); 17 return from.GetBoolean(index, out);
18 } 18 }
19 19
20 bool GetItemFromList(const ListValue& from, int index, double* out) { 20 bool GetItemFromList(const base::ListValue& from, int index, double* out) {
21 return from.GetDouble(index, out); 21 return from.GetDouble(index, out);
22 } 22 }
23 23
24 bool GetItemFromList(const ListValue& from, int index, std::string* out) { 24 bool GetItemFromList(const base::ListValue& from, int index, std::string* out) {
25 return from.GetString(index, out); 25 return from.GetString(index, out);
26 } 26 }
27 27
28 bool GetItemFromList(const ListValue& from, 28 bool GetItemFromList(const base::ListValue& from,
29 int index, 29 int index,
30 linked_ptr<base::Value>* out) { 30 linked_ptr<base::Value>* out) {
31 const base::Value* value = NULL; 31 const base::Value* value = NULL;
32 if (!from.Get(index, &value)) 32 if (!from.Get(index, &value))
33 return false; 33 return false;
34 *out = make_linked_ptr(value->DeepCopy()); 34 *out = make_linked_ptr(value->DeepCopy());
35 return true; 35 return true;
36 } 36 }
37 37
38 bool GetItemFromList(const ListValue& from, int index, 38 bool GetItemFromList(const base::ListValue& from, int index,
39 linked_ptr<base::DictionaryValue>* out) { 39 linked_ptr<base::DictionaryValue>* out) {
40 const DictionaryValue* dict = NULL; 40 const base::DictionaryValue* dict = NULL;
41 if (!from.GetDictionary(index, &dict)) 41 if (!from.GetDictionary(index, &dict))
42 return false; 42 return false;
43 *out = make_linked_ptr(dict->DeepCopy()); 43 *out = make_linked_ptr(dict->DeepCopy());
44 return true; 44 return true;
45 } 45 }
46 46
47 void AddItemToList(const int from, base::ListValue* out) { 47 void AddItemToList(const int from, base::ListValue* out) {
48 out->Append(base::Value::CreateIntegerValue(from)); 48 out->Append(base::Value::CreateIntegerValue(from));
49 } 49 }
50 50
51 void AddItemToList(const bool from, base::ListValue* out) { 51 void AddItemToList(const bool from, base::ListValue* out) {
52 out->Append(base::Value::CreateBooleanValue(from)); 52 out->Append(base::Value::CreateBooleanValue(from));
53 } 53 }
54 54
55 void AddItemToList(const double from, base::ListValue* out) { 55 void AddItemToList(const double from, base::ListValue* out) {
56 out->Append(base::Value::CreateDoubleValue(from)); 56 out->Append(base::Value::CreateDoubleValue(from));
57 } 57 }
58 58
59 void AddItemToList(const std::string& from, base::ListValue* out) { 59 void AddItemToList(const std::string& from, base::ListValue* out) {
60 out->Append(base::Value::CreateStringValue(from)); 60 out->Append(base::Value::CreateStringValue(from));
61 } 61 }
62 62
63 void AddItemToList(const linked_ptr<base::Value>& from, 63 void AddItemToList(const linked_ptr<base::Value>& from,
64 base::ListValue* out) { 64 base::ListValue* out) {
65 out->Append(from->DeepCopy()); 65 out->Append(from->DeepCopy());
66 } 66 }
67 67
68 void AddItemToList(const linked_ptr<base::DictionaryValue>& from, 68 void AddItemToList(const linked_ptr<base::DictionaryValue>& from,
69 base::ListValue* out) { 69 base::ListValue* out) {
70 out->Append(static_cast<Value*>(from->DeepCopy())); 70 out->Append(static_cast<base::Value*>(from->DeepCopy()));
71 } 71 }
72 72
73 } // namespace api_util 73 } // namespace api_util
74 } // namespace extensions 74 } // namespace extensions
OLDNEW
« no previous file with comments | « tools/json_schema_compiler/util.h ('k') | ui/webui/jstemplate_builder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698