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

Side by Side Diff: ui/base/l10n/l10n_util.cc

Issue 518533002: Move StringComparator<string16>::operator() to header (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 6 years, 3 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 | « no previous file | ui/base/l10n/l10n_util_collator.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 "ui/base/l10n/l10n_util.h" 5 #include "ui/base/l10n/l10n_util.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cstdlib> 8 #include <cstdlib>
9 #include <iterator> 9 #include <iterator>
10 #include <string> 10 #include <string>
(...skipping 806 matching lines...) Expand 10 before | Expand all | Expand 10 after
817 } 817 }
818 818
819 base::string16 GetStringFUTF16Int(int message_id, int a) { 819 base::string16 GetStringFUTF16Int(int message_id, int a) {
820 return GetStringFUTF16(message_id, base::UTF8ToUTF16(base::IntToString(a))); 820 return GetStringFUTF16(message_id, base::UTF8ToUTF16(base::IntToString(a)));
821 } 821 }
822 822
823 base::string16 GetStringFUTF16Int(int message_id, int64 a) { 823 base::string16 GetStringFUTF16Int(int message_id, int64 a) {
824 return GetStringFUTF16(message_id, base::UTF8ToUTF16(base::Int64ToString(a))); 824 return GetStringFUTF16(message_id, base::UTF8ToUTF16(base::Int64ToString(a)));
825 } 825 }
826 826
827 // Specialization of operator() method for base::string16 version.
828 template <>
829 bool StringComparator<base::string16>::operator()(const base::string16& lhs,
830 const base::string16& rhs) {
831 // If we can not get collator instance for specified locale, just do simple
832 // string compare.
833 if (!collator_)
834 return lhs < rhs;
835 return base::i18n::CompareString16WithCollator(collator_, lhs, rhs) ==
836 UCOL_LESS;
837 };
838
839 base::string16 GetPluralStringFUTF16(const std::vector<int>& message_ids, 827 base::string16 GetPluralStringFUTF16(const std::vector<int>& message_ids,
840 int number) { 828 int number) {
841 scoped_ptr<icu::PluralFormat> format = BuildPluralFormat(message_ids); 829 scoped_ptr<icu::PluralFormat> format = BuildPluralFormat(message_ids);
842 DCHECK(format); 830 DCHECK(format);
843 831
844 UErrorCode err = U_ZERO_ERROR; 832 UErrorCode err = U_ZERO_ERROR;
845 icu::UnicodeString result_files_string = format->format(number, err); 833 icu::UnicodeString result_files_string = format->format(number, err);
846 int capacity = result_files_string.length() + 1; 834 int capacity = result_files_string.length() + 1;
847 DCHECK_GT(capacity, 1); 835 DCHECK_GT(capacity, 1);
848 base::string16 result; 836 base::string16 result;
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
887 875
888 const char* const* GetAcceptLanguageListForTesting() { 876 const char* const* GetAcceptLanguageListForTesting() {
889 return kAcceptLanguageList; 877 return kAcceptLanguageList;
890 } 878 }
891 879
892 size_t GetAcceptLanguageListSizeForTesting() { 880 size_t GetAcceptLanguageListSizeForTesting() {
893 return arraysize(kAcceptLanguageList); 881 return arraysize(kAcceptLanguageList);
894 } 882 }
895 883
896 } // namespace l10n_util 884 } // namespace l10n_util
OLDNEW
« no previous file with comments | « no previous file | ui/base/l10n/l10n_util_collator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698