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

Side by Side Diff: base/values.cc

Issue 2577563002: Add struct traits for base::Value. (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
« no previous file with comments | « base/values.h ('k') | chrome/browser/importer/external_process_importer_client.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 "base/values.h" 5 #include "base/values.h"
6 6
7 #include <string.h> 7 #include <string.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <cmath> 10 #include <cmath>
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 } 111 }
112 112
113 bool Value::GetAsString(string16* out_value) const { 113 bool Value::GetAsString(string16* out_value) const {
114 return false; 114 return false;
115 } 115 }
116 116
117 bool Value::GetAsString(const StringValue** out_value) const { 117 bool Value::GetAsString(const StringValue** out_value) const {
118 return false; 118 return false;
119 } 119 }
120 120
121 bool Value::GetAsString(StringPiece* out_value) const {
122 return false;
123 }
124
121 bool Value::GetAsList(ListValue** out_value) { 125 bool Value::GetAsList(ListValue** out_value) {
122 return false; 126 return false;
123 } 127 }
124 128
125 bool Value::GetAsList(const ListValue** out_value) const { 129 bool Value::GetAsList(const ListValue** out_value) const {
126 return false; 130 return false;
127 } 131 }
128 132
129 bool Value::GetAsDictionary(DictionaryValue** out_value) { 133 bool Value::GetAsDictionary(DictionaryValue** out_value) {
130 return false; 134 return false;
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 *out_value = UTF8ToUTF16(value_); 284 *out_value = UTF8ToUTF16(value_);
281 return true; 285 return true;
282 } 286 }
283 287
284 bool StringValue::GetAsString(const StringValue** out_value) const { 288 bool StringValue::GetAsString(const StringValue** out_value) const {
285 if (out_value) 289 if (out_value)
286 *out_value = this; 290 *out_value = this;
287 return true; 291 return true;
288 } 292 }
289 293
294 bool StringValue::GetAsString(StringPiece* out_value) const {
295 if (out_value)
296 *out_value = value_;
297 return true;
298 }
299
290 StringValue* StringValue::DeepCopy() const { 300 StringValue* StringValue::DeepCopy() const {
291 return new StringValue(value_); 301 return new StringValue(value_);
292 } 302 }
293 303
294 bool StringValue::Equals(const Value* other) const { 304 bool StringValue::Equals(const Value* other) const {
295 if (other->GetType() != GetType()) 305 if (other->GetType() != GetType())
296 return false; 306 return false;
297 std::string lhs, rhs; 307 std::string lhs, rhs;
298 return GetAsString(&lhs) && other->GetAsString(&rhs) && lhs == rhs; 308 return GetAsString(&lhs) && other->GetAsString(&rhs) && lhs == rhs;
299 } 309 }
(...skipping 865 matching lines...) Expand 10 before | Expand all | Expand 10 after
1165 } 1175 }
1166 1176
1167 std::ostream& operator<<(std::ostream& out, const Value::Type& type) { 1177 std::ostream& operator<<(std::ostream& out, const Value::Type& type) {
1168 if (static_cast<int>(type) < 0 || 1178 if (static_cast<int>(type) < 0 ||
1169 static_cast<size_t>(type) >= arraysize(kTypeNames)) 1179 static_cast<size_t>(type) >= arraysize(kTypeNames))
1170 return out << "Invalid Type (index = " << static_cast<int>(type) << ")"; 1180 return out << "Invalid Type (index = " << static_cast<int>(type) << ")";
1171 return out << Value::GetTypeName(type); 1181 return out << Value::GetTypeName(type);
1172 } 1182 }
1173 1183
1174 } // namespace base 1184 } // namespace base
OLDNEW
« no previous file with comments | « base/values.h ('k') | chrome/browser/importer/external_process_importer_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698