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

Unified Diff: base/strings/string_util.h

Issue 448143008: Move StringToUpperASCII and LowerCaseEqualsASCII to the base namespace (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/i18n/rtl.cc ('k') | base/strings/string_util.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/strings/string_util.h
diff --git a/base/strings/string_util.h b/base/strings/string_util.h
index e20bbf0a40c59f9440a23812ca7e8723dd2c9dec..1570a0371b365d44b5a4b2e15dd9f5f4b8ba12a7 100644
--- a/base/strings/string_util.h
+++ b/base/strings/string_util.h
@@ -263,16 +263,6 @@ template <class str> inline str StringToLowerASCII(const str& s) {
return output;
}
-} // namespace base
-
-#if defined(OS_WIN)
-#include "base/strings/string_util_win.h"
-#elif defined(OS_POSIX)
-#include "base/strings/string_util_posix.h"
-#else
-#error Define string operations appropriately for your platform
-#endif
-
// Converts the elements of the given string. This version uses a pointer to
// clearly differentiate it from the non-pointer variant.
template <class str> inline void StringToUpperASCII(str* s) {
@@ -287,14 +277,18 @@ template <class str> inline str StringToUpperASCII(const str& s) {
return output;
}
-// Compare the lower-case form of the given string against the given ASCII
-// string. This is useful for doing checking if an input string matches some
-// token, and it is optimized to avoid intermediate string copies. This API is
-// borrowed from the equivalent APIs in Mozilla.
-BASE_EXPORT bool LowerCaseEqualsASCII(const std::string& a, const char* b);
-BASE_EXPORT bool LowerCaseEqualsASCII(const base::string16& a, const char* b);
+// Compare the lower-case form of the given string against the given
+// previously-lower-cased ASCII string. This is useful for doing checking if an
+// input string matches some token, and it is optimized to avoid intermediate
+// string copies.
+BASE_EXPORT bool LowerCaseEqualsASCII(StringPiece str,
+ const char* lower_cased_cmp);
+BASE_EXPORT bool LowerCaseEqualsASCII(StringPiece16 str,
+ const char* lower_cased_cmp);
// Same thing, but with string iterators instead.
+// TODO(brettw) remove these variants in preference for the StringPiece
+// versions above.
BASE_EXPORT bool LowerCaseEqualsASCII(std::string::const_iterator a_begin,
std::string::const_iterator a_end,
const char* b);
@@ -308,6 +302,16 @@ BASE_EXPORT bool LowerCaseEqualsASCII(const base::char16* a_begin,
const base::char16* a_end,
const char* b);
+} // namespace base
+
+#if defined(OS_WIN)
+#include "base/strings/string_util_win.h"
+#elif defined(OS_POSIX)
+#include "base/strings/string_util_posix.h"
+#else
+#error Define string operations appropriately for your platform
+#endif
+
// Performs a case-sensitive string compare. The behavior is undefined if both
// strings are not ASCII.
BASE_EXPORT bool EqualsASCII(const base::string16& a, const base::StringPiece& b);
« no previous file with comments | « base/i18n/rtl.cc ('k') | base/strings/string_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698