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

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

Issue 2539363004: Make base::Value::TYPE a scoped enum. (Closed)
Patch Set: Rebase Created 4 years 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
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/strings/stringprintf.h" 7 #include "base/strings/stringprintf.h"
8 #include "base/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
9 #include "base/values.h" 9 #include "base/values.h"
10 10
(...skipping 14 matching lines...) Expand all
25 } 25 }
26 26
27 } // namespace 27 } // namespace
28 28
29 bool PopulateItem(const base::Value& from, int* out) { 29 bool PopulateItem(const base::Value& from, int* out) {
30 return from.GetAsInteger(out); 30 return from.GetAsInteger(out);
31 } 31 }
32 32
33 bool PopulateItem(const base::Value& from, int* out, base::string16* error) { 33 bool PopulateItem(const base::Value& from, int* out, base::string16* error) {
34 if (!from.GetAsInteger(out)) 34 if (!from.GetAsInteger(out))
35 return ReportError(from, base::Value::TYPE_INTEGER, error); 35 return ReportError(from, base::Value::Type::INTEGER, error);
36 return true; 36 return true;
37 } 37 }
38 38
39 bool PopulateItem(const base::Value& from, bool* out) { 39 bool PopulateItem(const base::Value& from, bool* out) {
40 return from.GetAsBoolean(out); 40 return from.GetAsBoolean(out);
41 } 41 }
42 42
43 bool PopulateItem(const base::Value& from, bool* out, base::string16* error) { 43 bool PopulateItem(const base::Value& from, bool* out, base::string16* error) {
44 if (!from.GetAsBoolean(out)) 44 if (!from.GetAsBoolean(out))
45 return ReportError(from, base::Value::TYPE_BOOLEAN, error); 45 return ReportError(from, base::Value::Type::BOOLEAN, error);
46 return true; 46 return true;
47 } 47 }
48 48
49 bool PopulateItem(const base::Value& from, double* out) { 49 bool PopulateItem(const base::Value& from, double* out) {
50 return from.GetAsDouble(out); 50 return from.GetAsDouble(out);
51 } 51 }
52 52
53 bool PopulateItem(const base::Value& from, double* out, base::string16* error) { 53 bool PopulateItem(const base::Value& from, double* out, base::string16* error) {
54 if (!from.GetAsDouble(out)) 54 if (!from.GetAsDouble(out))
55 return ReportError(from, base::Value::TYPE_DOUBLE, error); 55 return ReportError(from, base::Value::Type::DOUBLE, error);
56 return true; 56 return true;
57 } 57 }
58 58
59 bool PopulateItem(const base::Value& from, std::string* out) { 59 bool PopulateItem(const base::Value& from, std::string* out) {
60 return from.GetAsString(out); 60 return from.GetAsString(out);
61 } 61 }
62 62
63 bool PopulateItem(const base::Value& from, 63 bool PopulateItem(const base::Value& from,
64 std::string* out, 64 std::string* out,
65 base::string16* error) { 65 base::string16* error) {
66 if (!from.GetAsString(out)) 66 if (!from.GetAsString(out))
67 return ReportError(from, base::Value::TYPE_STRING, error); 67 return ReportError(from, base::Value::Type::STRING, error);
68 return true; 68 return true;
69 } 69 }
70 70
71 bool PopulateItem(const base::Value& from, std::vector<char>* out) { 71 bool PopulateItem(const base::Value& from, std::vector<char>* out) {
72 const base::BinaryValue* binary = nullptr; 72 const base::BinaryValue* binary = nullptr;
73 if (!from.GetAsBinary(&binary)) 73 if (!from.GetAsBinary(&binary))
74 return false; 74 return false;
75 out->assign(binary->GetBuffer(), binary->GetBuffer() + binary->GetSize()); 75 out->assign(binary->GetBuffer(), binary->GetBuffer() + binary->GetSize());
76 return true; 76 return true;
77 } 77 }
78 78
79 bool PopulateItem(const base::Value& from, 79 bool PopulateItem(const base::Value& from,
80 std::vector<char>* out, 80 std::vector<char>* out,
81 base::string16* error) { 81 base::string16* error) {
82 const base::BinaryValue* binary = nullptr; 82 const base::BinaryValue* binary = nullptr;
83 if (!from.GetAsBinary(&binary)) 83 if (!from.GetAsBinary(&binary))
84 return ReportError(from, base::Value::TYPE_BINARY, error); 84 return ReportError(from, base::Value::Type::BINARY, error);
85 out->assign(binary->GetBuffer(), binary->GetBuffer() + binary->GetSize()); 85 out->assign(binary->GetBuffer(), binary->GetBuffer() + binary->GetSize());
86 return true; 86 return true;
87 } 87 }
88 88
89 bool PopulateItem(const base::Value& from, std::unique_ptr<base::Value>* out) { 89 bool PopulateItem(const base::Value& from, std::unique_ptr<base::Value>* out) {
90 *out = from.CreateDeepCopy(); 90 *out = from.CreateDeepCopy();
91 return true; 91 return true;
92 } 92 }
93 93
94 bool PopulateItem(const base::Value& from, 94 bool PopulateItem(const base::Value& from,
(...skipping 10 matching lines...) Expand all
105 return false; 105 return false;
106 *out = dict->CreateDeepCopy(); 106 *out = dict->CreateDeepCopy();
107 return true; 107 return true;
108 } 108 }
109 109
110 bool PopulateItem(const base::Value& from, 110 bool PopulateItem(const base::Value& from,
111 std::unique_ptr<base::DictionaryValue>* out, 111 std::unique_ptr<base::DictionaryValue>* out,
112 base::string16* error) { 112 base::string16* error) {
113 const base::DictionaryValue* dict = nullptr; 113 const base::DictionaryValue* dict = nullptr;
114 if (!from.GetAsDictionary(&dict)) 114 if (!from.GetAsDictionary(&dict))
115 return ReportError(from, base::Value::TYPE_DICTIONARY, error); 115 return ReportError(from, base::Value::Type::DICTIONARY, error);
116 *out = dict->CreateDeepCopy(); 116 *out = dict->CreateDeepCopy();
117 return true; 117 return true;
118 } 118 }
119 119
120 void AddItemToList(const int from, base::ListValue* out) { 120 void AddItemToList(const int from, base::ListValue* out) {
121 out->AppendInteger(from); 121 out->AppendInteger(from);
122 } 122 }
123 123
124 void AddItemToList(const bool from, base::ListValue* out) { 124 void AddItemToList(const bool from, base::ListValue* out) {
125 out->AppendBoolean(from); 125 out->AppendBoolean(from);
(...skipping 17 matching lines...) Expand all
143 out->Append(from->CreateDeepCopy()); 143 out->Append(from->CreateDeepCopy());
144 } 144 }
145 145
146 void AddItemToList(const std::unique_ptr<base::DictionaryValue>& from, 146 void AddItemToList(const std::unique_ptr<base::DictionaryValue>& from,
147 base::ListValue* out) { 147 base::ListValue* out) {
148 out->Append(from->CreateDeepCopy()); 148 out->Append(from->CreateDeepCopy());
149 } 149 }
150 150
151 } // namespace util 151 } // namespace util
152 } // namespace json_schema_compiler 152 } // namespace json_schema_compiler
OLDNEW
« no previous file with comments | « tools/json_schema_compiler/test/idl_schemas_unittest.cc ('k') | ui/compositor/layer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698