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

Side by Side Diff: base/values.cc

Issue 2666093002: Remove base::FundamentalValue (Closed)
Patch Set: Rebase Created 3 years, 9 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 | « base/values.h ('k') | base/values_unittest.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 335 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 return is_dict(); 346 return is_dict();
347 } 347 }
348 348
349 Value* Value::DeepCopy() const { 349 Value* Value::DeepCopy() const {
350 // This method should only be getting called for null Values--all subclasses 350 // This method should only be getting called for null Values--all subclasses
351 // need to provide their own implementation;. 351 // need to provide their own implementation;.
352 switch (type()) { 352 switch (type()) {
353 case Type::NONE: 353 case Type::NONE:
354 return CreateNullValue().release(); 354 return CreateNullValue().release();
355 355
356 // For now, make FundamentalValues for backward-compatibility. Convert to
357 // Value when that code is deleted.
358 case Type::BOOLEAN: 356 case Type::BOOLEAN:
359 return new FundamentalValue(bool_value_); 357 return new Value(bool_value_);
360 case Type::INTEGER: 358 case Type::INTEGER:
361 return new FundamentalValue(int_value_); 359 return new Value(int_value_);
362 case Type::DOUBLE: 360 case Type::DOUBLE:
363 return new FundamentalValue(double_value_); 361 return new Value(double_value_);
364 // For now, make StringValues for backward-compatibility. Convert to 362 // For now, make StringValues for backward-compatibility. Convert to
365 // Value when that code is deleted. 363 // Value when that code is deleted.
366 case Type::STRING: 364 case Type::STRING:
367 return new StringValue(*string_value_); 365 return new StringValue(*string_value_);
368 // For now, make BinaryValues for backward-compatibility. Convert to 366 // For now, make BinaryValues for backward-compatibility. Convert to
369 // Value when that code is deleted. 367 // Value when that code is deleted.
370 case Type::BINARY: 368 case Type::BINARY:
371 return new BinaryValue(*binary_value_); 369 return new BinaryValue(*binary_value_);
372 370
373 // TODO(crbug.com/646113): Clean this up when DictionaryValue and ListValue 371 // TODO(crbug.com/646113): Clean this up when DictionaryValue and ListValue
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after
666 664
667 current_dictionary->SetWithoutPathExpansion(current_path, 665 current_dictionary->SetWithoutPathExpansion(current_path,
668 std::move(in_value)); 666 std::move(in_value));
669 } 667 }
670 668
671 void DictionaryValue::Set(StringPiece path, Value* in_value) { 669 void DictionaryValue::Set(StringPiece path, Value* in_value) {
672 Set(path, WrapUnique(in_value)); 670 Set(path, WrapUnique(in_value));
673 } 671 }
674 672
675 void DictionaryValue::SetBoolean(StringPiece path, bool in_value) { 673 void DictionaryValue::SetBoolean(StringPiece path, bool in_value) {
676 Set(path, new FundamentalValue(in_value)); 674 Set(path, new Value(in_value));
677 } 675 }
678 676
679 void DictionaryValue::SetInteger(StringPiece path, int in_value) { 677 void DictionaryValue::SetInteger(StringPiece path, int in_value) {
680 Set(path, new FundamentalValue(in_value)); 678 Set(path, new Value(in_value));
681 } 679 }
682 680
683 void DictionaryValue::SetDouble(StringPiece path, double in_value) { 681 void DictionaryValue::SetDouble(StringPiece path, double in_value) {
684 Set(path, new FundamentalValue(in_value)); 682 Set(path, new Value(in_value));
685 } 683 }
686 684
687 void DictionaryValue::SetString(StringPiece path, StringPiece in_value) { 685 void DictionaryValue::SetString(StringPiece path, StringPiece in_value) {
688 Set(path, new StringValue(in_value)); 686 Set(path, new StringValue(in_value));
689 } 687 }
690 688
691 void DictionaryValue::SetString(StringPiece path, const string16& in_value) { 689 void DictionaryValue::SetString(StringPiece path, const string16& in_value) {
692 Set(path, new StringValue(in_value)); 690 Set(path, new StringValue(in_value));
693 } 691 }
694 692
695 void DictionaryValue::SetWithoutPathExpansion(StringPiece key, 693 void DictionaryValue::SetWithoutPathExpansion(StringPiece key,
696 std::unique_ptr<Value> in_value) { 694 std::unique_ptr<Value> in_value) {
697 (**dict_ptr_)[key.as_string()] = std::move(in_value); 695 (**dict_ptr_)[key.as_string()] = std::move(in_value);
698 } 696 }
699 697
700 void DictionaryValue::SetWithoutPathExpansion(StringPiece key, 698 void DictionaryValue::SetWithoutPathExpansion(StringPiece key,
701 Value* in_value) { 699 Value* in_value) {
702 SetWithoutPathExpansion(key, WrapUnique(in_value)); 700 SetWithoutPathExpansion(key, WrapUnique(in_value));
703 } 701 }
704 702
705 void DictionaryValue::SetBooleanWithoutPathExpansion(StringPiece path, 703 void DictionaryValue::SetBooleanWithoutPathExpansion(StringPiece path,
706 bool in_value) { 704 bool in_value) {
707 SetWithoutPathExpansion(path, 705 SetWithoutPathExpansion(path, base::MakeUnique<base::Value>(in_value));
708 base::MakeUnique<base::FundamentalValue>(in_value));
709 } 706 }
710 707
711 void DictionaryValue::SetIntegerWithoutPathExpansion(StringPiece path, 708 void DictionaryValue::SetIntegerWithoutPathExpansion(StringPiece path,
712 int in_value) { 709 int in_value) {
713 SetWithoutPathExpansion(path, 710 SetWithoutPathExpansion(path, base::MakeUnique<base::Value>(in_value));
714 base::MakeUnique<base::FundamentalValue>(in_value));
715 } 711 }
716 712
717 void DictionaryValue::SetDoubleWithoutPathExpansion(StringPiece path, 713 void DictionaryValue::SetDoubleWithoutPathExpansion(StringPiece path,
718 double in_value) { 714 double in_value) {
719 SetWithoutPathExpansion(path, 715 SetWithoutPathExpansion(path, base::MakeUnique<base::Value>(in_value));
720 base::MakeUnique<base::FundamentalValue>(in_value));
721 } 716 }
722 717
723 void DictionaryValue::SetStringWithoutPathExpansion(StringPiece path, 718 void DictionaryValue::SetStringWithoutPathExpansion(StringPiece path,
724 StringPiece in_value) { 719 StringPiece in_value) {
725 SetWithoutPathExpansion(path, base::MakeUnique<base::StringValue>(in_value)); 720 SetWithoutPathExpansion(path, base::MakeUnique<base::StringValue>(in_value));
726 } 721 }
727 722
728 void DictionaryValue::SetStringWithoutPathExpansion(StringPiece path, 723 void DictionaryValue::SetStringWithoutPathExpansion(StringPiece path,
729 const string16& in_value) { 724 const string16& in_value) {
730 SetWithoutPathExpansion(path, base::MakeUnique<base::StringValue>(in_value)); 725 SetWithoutPathExpansion(path, base::MakeUnique<base::StringValue>(in_value));
(...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after
1267 } 1262 }
1268 1263
1269 #if !defined(OS_LINUX) 1264 #if !defined(OS_LINUX)
1270 void ListValue::Append(Value* in_value) { 1265 void ListValue::Append(Value* in_value) {
1271 DCHECK(in_value); 1266 DCHECK(in_value);
1272 Append(WrapUnique(in_value)); 1267 Append(WrapUnique(in_value));
1273 } 1268 }
1274 #endif 1269 #endif
1275 1270
1276 void ListValue::AppendBoolean(bool in_value) { 1271 void ListValue::AppendBoolean(bool in_value) {
1277 Append(MakeUnique<FundamentalValue>(in_value)); 1272 Append(MakeUnique<Value>(in_value));
1278 } 1273 }
1279 1274
1280 void ListValue::AppendInteger(int in_value) { 1275 void ListValue::AppendInteger(int in_value) {
1281 Append(MakeUnique<FundamentalValue>(in_value)); 1276 Append(MakeUnique<Value>(in_value));
1282 } 1277 }
1283 1278
1284 void ListValue::AppendDouble(double in_value) { 1279 void ListValue::AppendDouble(double in_value) {
1285 Append(MakeUnique<FundamentalValue>(in_value)); 1280 Append(MakeUnique<Value>(in_value));
1286 } 1281 }
1287 1282
1288 void ListValue::AppendString(StringPiece in_value) { 1283 void ListValue::AppendString(StringPiece in_value) {
1289 Append(MakeUnique<StringValue>(in_value)); 1284 Append(MakeUnique<StringValue>(in_value));
1290 } 1285 }
1291 1286
1292 void ListValue::AppendString(const string16& in_value) { 1287 void ListValue::AppendString(const string16& in_value) {
1293 Append(MakeUnique<StringValue>(in_value)); 1288 Append(MakeUnique<StringValue>(in_value));
1294 } 1289 }
1295 1290
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
1359 } 1354 }
1360 1355
1361 std::ostream& operator<<(std::ostream& out, const Value::Type& type) { 1356 std::ostream& operator<<(std::ostream& out, const Value::Type& type) {
1362 if (static_cast<int>(type) < 0 || 1357 if (static_cast<int>(type) < 0 ||
1363 static_cast<size_t>(type) >= arraysize(kTypeNames)) 1358 static_cast<size_t>(type) >= arraysize(kTypeNames))
1364 return out << "Invalid Type (index = " << static_cast<int>(type) << ")"; 1359 return out << "Invalid Type (index = " << static_cast<int>(type) << ")";
1365 return out << Value::GetTypeName(type); 1360 return out << Value::GetTypeName(type);
1366 } 1361 }
1367 1362
1368 } // namespace base 1363 } // namespace base
OLDNEW
« no previous file with comments | « base/values.h ('k') | base/values_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698