Move IsStringUTF8/ASCII to base namespace
TBR=sky@chromium.org
Review URL: https://codereview.chromium.org/270183002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@268754 0039d316-1c4b-4281-b951-d872f2087c98
CrOS-Libchrome-Original-Commit: 52796541ecc14a0aa287ec0859e23350fed71278
diff --git a/base/files/file_path.cc b/base/files/file_path.cc
index f5a9e5a..a8b2713 100644
--- a/base/files/file_path.cc
+++ b/base/files/file_path.cc
@@ -521,7 +521,7 @@
}
FilePath FilePath::AppendASCII(const StringPiece& component) const {
- DCHECK(IsStringASCII(component));
+ DCHECK(base::IsStringASCII(component));
#if defined(OS_WIN)
return Append(ASCIIToUTF16(component.as_string()));
#elif defined(OS_POSIX)
@@ -587,7 +587,7 @@
}
std::string FilePath::MaybeAsASCII() const {
- if (IsStringASCII(path_))
+ if (base::IsStringASCII(path_))
return path_;
return std::string();
}
@@ -632,7 +632,7 @@
}
std::string FilePath::MaybeAsASCII() const {
- if (IsStringASCII(path_))
+ if (base::IsStringASCII(path_))
return UTF16ToASCII(path_);
return std::string();
}
diff --git a/base/strings/string_util.cc b/base/strings/string_util.cc
index e514ac1..0adb989 100644
--- a/base/strings/string_util.cc
+++ b/base/strings/string_util.cc
@@ -324,8 +324,6 @@
return input.find_first_not_of(characters) == StringPiece16::npos;
}
-} // namespace base
-
template<class STR>
static bool DoIsStringASCII(const STR& str) {
for (size_t i = 0; i < str.length(); i++) {
@@ -336,11 +334,11 @@
return true;
}
-bool IsStringASCII(const base::StringPiece& str) {
+bool IsStringASCII(const StringPiece& str) {
return DoIsStringASCII(str);
}
-bool IsStringASCII(const base::string16& str) {
+bool IsStringASCII(const string16& str) {
return DoIsStringASCII(str);
}
@@ -352,12 +350,14 @@
while (char_index < src_len) {
int32 code_point;
CBU8_NEXT(src, char_index, src_len, code_point);
- if (!base::IsValidCharacter(code_point))
+ if (!IsValidCharacter(code_point))
return false;
}
return true;
}
+} // namespace base
+
template<typename Iter>
static inline bool DoLowerCaseEqualsASCII(Iter a_begin,
Iter a_end,
diff --git a/base/strings/string_util.h b/base/strings/string_util.h
index 473deae..9478a0c 100644
--- a/base/strings/string_util.h
+++ b/base/strings/string_util.h
@@ -234,16 +234,6 @@
BASE_EXPORT bool ContainsOnlyChars(const StringPiece16& input,
const StringPiece16& characters);
-} // 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
-
// Returns true if the specified string matches the criteria. How can a wide
// string be 8-bit or UTF8? It contains only characters that are < 256 (in the
// first case) or characters that use only 8-bits and whose 8-bit
@@ -256,8 +246,18 @@
// there's a use case for just checking the structural validity, we have to
// add a new function for that.
BASE_EXPORT bool IsStringUTF8(const std::string& str);
-BASE_EXPORT bool IsStringASCII(const base::StringPiece& str);
-BASE_EXPORT bool IsStringASCII(const base::string16& str);
+BASE_EXPORT bool IsStringASCII(const StringPiece& str);
+BASE_EXPORT bool IsStringASCII(const string16& str);
+
+} // 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.
diff --git a/dbus/message.cc b/dbus/message.cc
index eaf3c9b..c9219b7 100644
--- a/dbus/message.cc
+++ b/dbus/message.cc
@@ -507,7 +507,7 @@
void MessageWriter::AppendString(const std::string& value) {
// D-Bus Specification (0.19) says a string "must be valid UTF-8".
- CHECK(IsStringUTF8(value));
+ CHECK(base::IsStringUTF8(value));
const char* pointer = value.c_str();
AppendBasic(DBUS_TYPE_STRING, &pointer);
// TODO(satorux): It may make sense to return an error here, as the