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

Side by Side Diff: base/values.cc

Issue 148463003: libaddressinput - reduce number of copies in storage class by 2 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: comment Created 6 years, 10 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 | « base/values.h ('k') | third_party/libaddressinput/chromium/chrome_storage_impl.h » ('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 <ostream> 10 #include <ostream>
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 } 127 }
128 128
129 bool Value::GetAsString(std::string* out_value) const { 129 bool Value::GetAsString(std::string* out_value) const {
130 return false; 130 return false;
131 } 131 }
132 132
133 bool Value::GetAsString(string16* out_value) const { 133 bool Value::GetAsString(string16* out_value) const {
134 return false; 134 return false;
135 } 135 }
136 136
137 bool Value::GetAsString(const StringValue** out_value) const {
138 return false;
139 }
140
137 bool Value::GetAsList(ListValue** out_value) { 141 bool Value::GetAsList(ListValue** out_value) {
138 return false; 142 return false;
139 } 143 }
140 144
141 bool Value::GetAsList(const ListValue** out_value) const { 145 bool Value::GetAsList(const ListValue** out_value) const {
142 return false; 146 return false;
143 } 147 }
144 148
145 bool Value::GetAsDictionary(DictionaryValue** out_value) { 149 bool Value::GetAsDictionary(DictionaryValue** out_value) {
146 return false; 150 return false;
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 } 275 }
272 276
273 StringValue::StringValue(const string16& in_value) 277 StringValue::StringValue(const string16& in_value)
274 : Value(TYPE_STRING), 278 : Value(TYPE_STRING),
275 value_(UTF16ToUTF8(in_value)) { 279 value_(UTF16ToUTF8(in_value)) {
276 } 280 }
277 281
278 StringValue::~StringValue() { 282 StringValue::~StringValue() {
279 } 283 }
280 284
285 std::string* StringValue::GetString() {
286 return &value_;
287 }
288
289 const std::string& StringValue::GetString() const {
290 return value_;
291 }
292
281 bool StringValue::GetAsString(std::string* out_value) const { 293 bool StringValue::GetAsString(std::string* out_value) const {
282 if (out_value) 294 if (out_value)
283 *out_value = value_; 295 *out_value = value_;
284 return true; 296 return true;
285 } 297 }
286 298
287 bool StringValue::GetAsString(string16* out_value) const { 299 bool StringValue::GetAsString(string16* out_value) const {
288 if (out_value) 300 if (out_value)
289 *out_value = UTF8ToUTF16(value_); 301 *out_value = UTF8ToUTF16(value_);
290 return true; 302 return true;
291 } 303 }
292 304
305 bool StringValue::GetAsString(const StringValue** out_value) const {
306 if (*out_value)
307 *out_value = this;
308 return true;
309 }
310
293 StringValue* StringValue::DeepCopy() const { 311 StringValue* StringValue::DeepCopy() const {
294 return new StringValue(value_); 312 return new StringValue(value_);
295 } 313 }
296 314
297 bool StringValue::Equals(const Value* other) const { 315 bool StringValue::Equals(const Value* other) const {
298 if (other->GetType() != GetType()) 316 if (other->GetType() != GetType())
299 return false; 317 return false;
300 std::string lhs, rhs; 318 std::string lhs, rhs;
301 return GetAsString(&lhs) && other->GetAsString(&rhs) && lhs == rhs; 319 return GetAsString(&lhs) && other->GetAsString(&rhs) && lhs == rhs;
302 } 320 }
(...skipping 829 matching lines...) Expand 10 before | Expand all | Expand 10 after
1132 1150
1133 std::ostream& operator<<(std::ostream& out, const Value& value) { 1151 std::ostream& operator<<(std::ostream& out, const Value& value) {
1134 std::string json; 1152 std::string json;
1135 JSONWriter::WriteWithOptions(&value, 1153 JSONWriter::WriteWithOptions(&value,
1136 JSONWriter::OPTIONS_PRETTY_PRINT, 1154 JSONWriter::OPTIONS_PRETTY_PRINT,
1137 &json); 1155 &json);
1138 return out << json; 1156 return out << json;
1139 } 1157 }
1140 1158
1141 } // namespace base 1159 } // namespace base
OLDNEW
« no previous file with comments | « base/values.h ('k') | third_party/libaddressinput/chromium/chrome_storage_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698