OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/string_util.h" | 5 #include "base/string_util.h" |
6 | 6 |
7 #include "build/build_config.h" | 7 #include "build/build_config.h" |
8 | 8 |
9 #include <ctype.h> | 9 #include <ctype.h> |
10 #include <errno.h> | 10 #include <errno.h> |
(...skipping 833 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
844 return false; | 844 return false; |
845 if (case_sensitive) { | 845 if (case_sensitive) { |
846 return str.compare(str_length - search_length, search_length, search) == 0; | 846 return str.compare(str_length - search_length, search_length, search) == 0; |
847 } else { | 847 } else { |
848 return std::equal(search.begin(), search.end(), | 848 return std::equal(search.begin(), search.end(), |
849 str.begin() + (str_length - search_length), | 849 str.begin() + (str_length - search_length), |
850 CaseInsensitiveCompare<typename STR::value_type>()); | 850 CaseInsensitiveCompare<typename STR::value_type>()); |
851 } | 851 } |
852 } | 852 } |
853 | 853 |
| 854 bool EndsWith(const std::string& str, const std::string& search, |
| 855 bool case_sensitive) { |
| 856 return EndsWithT(str, search, case_sensitive); |
| 857 } |
| 858 |
854 bool EndsWith(const std::wstring& str, const std::wstring& search, | 859 bool EndsWith(const std::wstring& str, const std::wstring& search, |
855 bool case_sensitive) { | 860 bool case_sensitive) { |
856 return EndsWithT(str, search, case_sensitive); | 861 return EndsWithT(str, search, case_sensitive); |
857 } | 862 } |
858 | 863 |
859 #if !defined(WCHAR_T_IS_UTF16) | 864 #if !defined(WCHAR_T_IS_UTF16) |
860 bool EndsWith(const string16& str, const string16& search, | 865 bool EndsWith(const string16& str, const string16& search, |
861 bool case_sensitive) { | 866 bool case_sensitive) { |
862 return EndsWithT(str, search, case_sensitive); | 867 return EndsWithT(str, search, case_sensitive); |
863 } | 868 } |
(...skipping 941 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1805 // Each input byte creates two output hex characters. | 1810 // Each input byte creates two output hex characters. |
1806 std::string ret(size * 2, '\0'); | 1811 std::string ret(size * 2, '\0'); |
1807 | 1812 |
1808 for (size_t i = 0; i < size; ++i) { | 1813 for (size_t i = 0; i < size; ++i) { |
1809 char b = reinterpret_cast<const char*>(bytes)[i]; | 1814 char b = reinterpret_cast<const char*>(bytes)[i]; |
1810 ret[(i * 2)] = kHexChars[(b >> 4) & 0xf]; | 1815 ret[(i * 2)] = kHexChars[(b >> 4) & 0xf]; |
1811 ret[(i * 2) + 1] = kHexChars[b & 0xf]; | 1816 ret[(i * 2) + 1] = kHexChars[b & 0xf]; |
1812 } | 1817 } |
1813 return ret; | 1818 return ret; |
1814 } | 1819 } |
OLD | NEW |