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

Side by Side Diff: base/values.cc

Issue 3091005: Rename GetStringAsUTF16() to GetString() (and overload), etc. (Closed)
Patch Set: Created 10 years, 4 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') | chrome/browser/automation/automation_provider.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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "base/logging.h" 7 #include "base/logging.h"
8 #include "base/string_util.h" 8 #include "base/string_util.h"
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 10
(...skipping 547 matching lines...) Expand 10 before | Expand all | Expand 10 after
558 558
559 bool DictionaryValue::GetString(const std::string& path, 559 bool DictionaryValue::GetString(const std::string& path,
560 std::string* out_value) const { 560 std::string* out_value) const {
561 Value* value; 561 Value* value;
562 if (!Get(path, &value)) 562 if (!Get(path, &value))
563 return false; 563 return false;
564 564
565 return value->GetAsString(out_value); 565 return value->GetAsString(out_value);
566 } 566 }
567 567
568 bool DictionaryValue::GetStringAsUTF16(const std::string& path, 568 bool DictionaryValue::GetString(const std::string& path,
569 string16* out_value) const { 569 string16* out_value) const {
570 Value* value; 570 Value* value;
571 if (!Get(path, &value)) 571 if (!Get(path, &value))
572 return false; 572 return false;
573 573
574 return value->GetAsString(out_value); 574 return value->GetAsString(out_value);
575 } 575 }
576 576
577 bool DictionaryValue::GetStringASCII(const std::string& path, 577 bool DictionaryValue::GetStringASCII(const std::string& path,
578 std::string* out_value) const { 578 std::string* out_value) const {
579 std::string out; 579 std::string out;
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
639 int* out_value) const { 639 int* out_value) const {
640 return GetInteger(WideToUTF8(path), out_value); 640 return GetInteger(WideToUTF8(path), out_value);
641 } 641 }
642 642
643 // TODO(viettrungluu): Deprecated and to be removed: 643 // TODO(viettrungluu): Deprecated and to be removed:
644 bool DictionaryValue::GetReal(const std::wstring& path, 644 bool DictionaryValue::GetReal(const std::wstring& path,
645 double* out_value) const { 645 double* out_value) const {
646 return GetReal(WideToUTF8(path), out_value); 646 return GetReal(WideToUTF8(path), out_value);
647 } 647 }
648 648
649 // TODO(viettrungluu): or maybe we should get rid of the "AsUTF16" version?
650 bool DictionaryValue::GetString(const std::string& path,
651 string16* out_value) const {
652 return GetStringAsUTF16(path, out_value);
653 }
654
655 // TODO(viettrungluu): Deprecated and to be removed: 649 // TODO(viettrungluu): Deprecated and to be removed:
656 bool DictionaryValue::GetString(const std::wstring& path, 650 bool DictionaryValue::GetString(const std::wstring& path,
657 std::string* out_value) const { 651 std::string* out_value) const {
658 return GetString(WideToUTF8(path), out_value); 652 return GetString(WideToUTF8(path), out_value);
659 } 653 }
660 654
661 // TODO(viettrungluu): Deprecated and to be removed: 655 // TODO(viettrungluu): Deprecated and to be removed:
662 bool DictionaryValue::GetString(const std::wstring& path, 656 bool DictionaryValue::GetString(const std::wstring& path,
663 std::wstring* out_value) const { 657 std::wstring* out_value) const {
664 Value* value; 658 Value* value;
665 if (!Get(WideToUTF8(path), &value)) 659 if (!Get(WideToUTF8(path), &value))
666 return false; 660 return false;
667 661
668 return value->GetAsString(out_value); 662 return value->GetAsString(out_value);
669 } 663 }
670 664
671 // TODO(viettrungluu): Deprecated and to be removed: 665 // TODO(viettrungluu): Deprecated and to be removed:
672 bool DictionaryValue::GetStringAsUTF16(const std::wstring& path,
673 string16* out_value) const {
674 return GetStringAsUTF16(WideToUTF8(path), out_value);
675 }
676
677 // TODO(viettrungluu): Deprecated and to be removed:
678 bool DictionaryValue::GetBinary(const std::wstring& path, 666 bool DictionaryValue::GetBinary(const std::wstring& path,
679 BinaryValue** out_value) const { 667 BinaryValue** out_value) const {
680 return GetBinary(WideToUTF8(path), out_value); 668 return GetBinary(WideToUTF8(path), out_value);
681 } 669 }
682 670
683 // TODO(viettrungluu): Deprecated and to be removed: 671 // TODO(viettrungluu): Deprecated and to be removed:
684 bool DictionaryValue::GetDictionary(const std::wstring& path, 672 bool DictionaryValue::GetDictionary(const std::wstring& path,
685 DictionaryValue** out_value) const { 673 DictionaryValue** out_value) const {
686 return GetDictionary(WideToUTF8(path), out_value); 674 return GetDictionary(WideToUTF8(path), out_value);
687 } 675 }
(...skipping 28 matching lines...) Expand all
716 bool DictionaryValue::GetStringWithoutPathExpansion( 704 bool DictionaryValue::GetStringWithoutPathExpansion(
717 const std::string& key, 705 const std::string& key,
718 std::string* out_value) const { 706 std::string* out_value) const {
719 Value* value; 707 Value* value;
720 if (!GetWithoutPathExpansion(key, &value)) 708 if (!GetWithoutPathExpansion(key, &value))
721 return false; 709 return false;
722 710
723 return value->GetAsString(out_value); 711 return value->GetAsString(out_value);
724 } 712 }
725 713
726 bool DictionaryValue::GetStringAsUTF16WithoutPathExpansion( 714 bool DictionaryValue::GetStringWithoutPathExpansion(
727 const std::string& key, 715 const std::string& key,
728 string16* out_value) const { 716 string16* out_value) const {
729 Value* value; 717 Value* value;
730 if (!GetWithoutPathExpansion(key, &value)) 718 if (!GetWithoutPathExpansion(key, &value))
731 return false; 719 return false;
732 720
733 return value->GetAsString(out_value); 721 return value->GetAsString(out_value);
734 } 722 }
735 723
736 bool DictionaryValue::GetDictionaryWithoutPathExpansion( 724 bool DictionaryValue::GetDictionaryWithoutPathExpansion(
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
784 const std::wstring& key, 772 const std::wstring& key,
785 std::wstring* out_value) const { 773 std::wstring* out_value) const {
786 Value* value; 774 Value* value;
787 if (!GetWithoutPathExpansion(WideToUTF8(key), &value)) 775 if (!GetWithoutPathExpansion(WideToUTF8(key), &value))
788 return false; 776 return false;
789 777
790 return value->GetAsString(out_value); 778 return value->GetAsString(out_value);
791 } 779 }
792 780
793 // TODO(viettrungluu): Deprecated and to be removed: 781 // TODO(viettrungluu): Deprecated and to be removed:
794 bool DictionaryValue::GetStringAsUTF16WithoutPathExpansion(
795 const std::wstring& key,
796 string16* out_value) const {
797 return GetStringAsUTF16WithoutPathExpansion(WideToUTF8(key), out_value);
798 }
799
800 // TODO(viettrungluu): Deprecated and to be removed:
801 bool DictionaryValue::GetDictionaryWithoutPathExpansion( 782 bool DictionaryValue::GetDictionaryWithoutPathExpansion(
802 const std::wstring& key, 783 const std::wstring& key,
803 DictionaryValue** out_value) const { 784 DictionaryValue** out_value) const {
804 return GetDictionaryWithoutPathExpansion(WideToUTF8(key), out_value); 785 return GetDictionaryWithoutPathExpansion(WideToUTF8(key), out_value);
805 } 786 }
806 787
807 // TODO(viettrungluu): Deprecated and to be removed: 788 // TODO(viettrungluu): Deprecated and to be removed:
808 bool DictionaryValue::GetListWithoutPathExpansion(const std::wstring& key, 789 bool DictionaryValue::GetListWithoutPathExpansion(const std::wstring& key,
809 ListValue** out_value) const { 790 ListValue** out_value) const {
810 return GetListWithoutPathExpansion(WideToUTF8(key), out_value); 791 return GetListWithoutPathExpansion(WideToUTF8(key), out_value);
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
1051 } 1032 }
1052 1033
1053 bool ListValue::GetString(size_t index, std::string* out_value) const { 1034 bool ListValue::GetString(size_t index, std::string* out_value) const {
1054 Value* value; 1035 Value* value;
1055 if (!Get(index, &value)) 1036 if (!Get(index, &value))
1056 return false; 1037 return false;
1057 1038
1058 return value->GetAsString(out_value); 1039 return value->GetAsString(out_value);
1059 } 1040 }
1060 1041
1061 bool ListValue::GetString(size_t index, std::wstring* out_value) const { 1042 bool ListValue::GetString(size_t index, string16* out_value) const {
1062 Value* value; 1043 Value* value;
1063 if (!Get(index, &value)) 1044 if (!Get(index, &value))
1064 return false; 1045 return false;
1065 1046
1066 return value->GetAsString(out_value); 1047 return value->GetAsString(out_value);
1067 } 1048 }
1068 1049
1069 bool ListValue::GetStringAsUTF16(size_t index, string16* out_value) const { 1050 #if !defined(WCHAR_T_IS_UTF16)
1051 // TODO(viettrungluu): Deprecated and to be removed:
1052 bool ListValue::GetString(size_t index, std::wstring* out_value) const {
1070 Value* value; 1053 Value* value;
1071 if (!Get(index, &value)) 1054 if (!Get(index, &value))
1072 return false; 1055 return false;
1073 1056
1074 return value->GetAsString(out_value); 1057 return value->GetAsString(out_value);
1075 } 1058 }
1059 #endif
1076 1060
1077 bool ListValue::GetBinary(size_t index, BinaryValue** out_value) const { 1061 bool ListValue::GetBinary(size_t index, BinaryValue** out_value) const {
1078 Value* value; 1062 Value* value;
1079 bool result = Get(index, &value); 1063 bool result = Get(index, &value);
1080 if (!result || !value->IsType(TYPE_BINARY)) 1064 if (!result || !value->IsType(TYPE_BINARY))
1081 return false; 1065 return false;
1082 1066
1083 if (out_value) 1067 if (out_value)
1084 *out_value = static_cast<BinaryValue*>(value); 1068 *out_value = static_cast<BinaryValue*>(value);
1085 1069
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
1187 return false; 1171 return false;
1188 } 1172 }
1189 if (lhs_it != end() || rhs_it != other_list->end()) 1173 if (lhs_it != end() || rhs_it != other_list->end())
1190 return false; 1174 return false;
1191 1175
1192 return true; 1176 return true;
1193 } 1177 }
1194 1178
1195 ValueSerializer::~ValueSerializer() { 1179 ValueSerializer::~ValueSerializer() {
1196 } 1180 }
OLDNEW
« no previous file with comments | « base/values.h ('k') | chrome/browser/automation/automation_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698