summaryrefslogtreecommitdiffstats
path: root/base
diff options
context:
space:
mode:
authortony@chromium.org <tony@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-10 21:08:39 +0000
committertony@chromium.org <tony@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-10 21:08:39 +0000
commit8a16266e66a38bc1bfc6b00893c2a7c8cf8c55ee (patch)
tree5c07a9d5091a56c6d5a1a2b98ec10d19ae3c20e9 /base
parentf8dce00e633d5ffde45e008fb8f51d5a76942f6b (diff)
downloadchromium_src-8a16266e66a38bc1bfc6b00893c2a7c8cf8c55ee.zip
chromium_src-8a16266e66a38bc1bfc6b00893c2a7c8cf8c55ee.tar.gz
chromium_src-8a16266e66a38bc1bfc6b00893c2a7c8cf8c55ee.tar.bz2
Move StringPiece into the base namespace. It is colliding
with the StringPiece class in icu4.2, which is a problem when trying to use the system version of icu. Review URL: http://codereview.chromium.org/193072 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@25920 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base')
-rw-r--r--base/data_pack.h3
-rw-r--r--base/data_pack_unittest.cc2
-rw-r--r--base/debug_util_posix.cc8
-rw-r--r--base/file_path.cc5
-rw-r--r--base/file_path.h5
-rw-r--r--base/string_piece.cc4
-rw-r--r--base/string_piece.h4
-rw-r--r--base/string_piece_unittest.cc2
-rw-r--r--base/string_util.cc8
-rw-r--r--base/string_util.h10
-rw-r--r--base/string_util_icu.cc2
-rw-r--r--base/sys_string_conversions.h4
12 files changed, 35 insertions, 22 deletions
diff --git a/base/data_pack.h b/base/data_pack.h
index ff4f6d9..02a3849 100644
--- a/base/data_pack.h
+++ b/base/data_pack.h
@@ -16,10 +16,11 @@ namespace file_util {
class MemoryMappedFile;
}
class FilePath;
-class StringPiece;
namespace base {
+class StringPiece;
+
class DataPack {
public:
DataPack();
diff --git a/base/data_pack_unittest.cc b/base/data_pack_unittest.cc
index 71c37e5..7c2cfeb 100644
--- a/base/data_pack_unittest.cc
+++ b/base/data_pack_unittest.cc
@@ -24,7 +24,7 @@ TEST_F(DataPackTest, Load) {
base::DataPack pack;
ASSERT_TRUE(pack.Load(data_path_));
- StringPiece data;
+ base::StringPiece data;
ASSERT_TRUE(pack.Get(4, &data));
EXPECT_EQ("this is id 4", data);
ASSERT_TRUE(pack.Get(6, &data));
diff --git a/base/debug_util_posix.cc b/base/debug_util_posix.cc
index dd22710..081f4c4 100644
--- a/base/debug_util_posix.cc
+++ b/base/debug_util_posix.cc
@@ -92,11 +92,11 @@ bool DebugUtil::BeingDebugged() {
if (num_read <= 0)
return false;
- StringPiece status(buf, num_read);
- StringPiece tracer("TracerPid:\t");
+ base::StringPiece status(buf, num_read);
+ base::StringPiece tracer("TracerPid:\t");
- StringPiece::size_type pid_index = status.find(tracer);
- if (pid_index == StringPiece::npos)
+ base::StringPiece::size_type pid_index = status.find(tracer);
+ if (pid_index == base::StringPiece::npos)
return false;
// Our pid is 0 without a debugger, assume this for any pid starting with 0.
diff --git a/base/file_path.cc b/base/file_path.cc
index 222b225..a521b37 100644
--- a/base/file_path.cc
+++ b/base/file_path.cc
@@ -310,7 +310,8 @@ FilePath FilePath::InsertBeforeExtension(const StringType& suffix) const {
return FilePath(ret);
}
-FilePath FilePath::InsertBeforeExtensionASCII(const StringPiece& suffix) const {
+FilePath FilePath::InsertBeforeExtensionASCII(const base::StringPiece& suffix)
+ const {
DCHECK(IsStringASCII(suffix));
#if defined(OS_WIN)
return InsertBeforeExtension(ASCIIToWide(suffix));
@@ -397,7 +398,7 @@ FilePath FilePath::Append(const FilePath& component) const {
return Append(component.value());
}
-FilePath FilePath::AppendASCII(const StringPiece& component) const {
+FilePath FilePath::AppendASCII(const base::StringPiece& component) const {
DCHECK(IsStringASCII(component));
#if defined(OS_WIN)
return Append(ASCIIToWide(component));
diff --git a/base/file_path.h b/base/file_path.h
index 0b2ba5c..b608651 100644
--- a/base/file_path.h
+++ b/base/file_path.h
@@ -187,7 +187,7 @@ class FilePath {
// path == "C:\pics\jojo" suffix == " (1)", returns "C:\pics\jojo (1)"
// path == "C:\pics.old\jojo" suffix == " (1)", returns "C:\pics.old\jojo (1)"
FilePath InsertBeforeExtension(const StringType& suffix) const;
- FilePath InsertBeforeExtensionASCII(const StringPiece& suffix) const;
+ FilePath InsertBeforeExtensionASCII(const base::StringPiece& suffix) const;
// Replaces the extension of |file_name| with |extension|. If |file_name|
// does not have an extension, them |extension| is added. If |extension| is
@@ -214,7 +214,8 @@ class FilePath {
// On Linux, although it can use any 8-bit encoding for paths, we assume that
// ASCII is a valid subset, regardless of the encoding, since many operating
// system paths will always be ASCII.
- FilePath AppendASCII(const StringPiece& component) const WARN_UNUSED_RESULT;
+ FilePath AppendASCII(const base::StringPiece& component)
+ const WARN_UNUSED_RESULT;
// Returns true if this FilePath contains an absolute path. On Windows, an
// absolute path begins with either a drive letter specification followed by
diff --git a/base/string_piece.cc b/base/string_piece.cc
index 1acb0cb..6844892 100644
--- a/base/string_piece.cc
+++ b/base/string_piece.cc
@@ -8,6 +8,8 @@
#include "base/string_piece.h"
+namespace base {
+
typedef StringPiece::size_type size_type;
std::ostream& operator<<(std::ostream& o, const StringPiece& piece) {
@@ -213,3 +215,5 @@ StringPiece StringPiece::substr(size_type pos, size_type n) const {
}
const StringPiece::size_type StringPiece::npos = size_type(-1);
+
+} // namespace base
diff --git a/base/string_piece.h b/base/string_piece.h
index fe10806..47d4968 100644
--- a/base/string_piece.h
+++ b/base/string_piece.h
@@ -24,6 +24,8 @@
#include "base/basictypes.h"
+namespace base {
+
class StringPiece {
public:
typedef size_t size_type;
@@ -181,4 +183,6 @@ inline bool operator>=(const StringPiece& x, const StringPiece& y) {
// allow StringPiece to be logged (needed for unit testing).
extern std::ostream& operator<<(std::ostream& o, const StringPiece& piece);
+} // namespace base
+
#endif // BASE_STRING_PIECE_H_
diff --git a/base/string_piece_unittest.cc b/base/string_piece_unittest.cc
index ff62d46..8289cf3 100644
--- a/base/string_piece_unittest.cc
+++ b/base/string_piece_unittest.cc
@@ -8,6 +8,8 @@
#include "testing/gtest/include/gtest/gtest.h"
+using namespace base;
+
TEST(StringPieceTest, CheckComparisonOperators) {
#define CMP_Y(op, x, y) \
ASSERT_TRUE( (StringPiece((x)) op StringPiece((y)))); \
diff --git a/base/string_util.cc b/base/string_util.cc
index 82b6c0b..fd33ef0 100644
--- a/base/string_util.cc
+++ b/base/string_util.cc
@@ -506,7 +506,7 @@ std::string WideToASCII(const std::wstring& wide) {
return std::string(wide.begin(), wide.end());
}
-std::wstring ASCIIToWide(const StringPiece& ascii) {
+std::wstring ASCIIToWide(const base::StringPiece& ascii) {
DCHECK(IsStringASCII(ascii)) << ascii;
return std::wstring(ascii.begin(), ascii.end());
}
@@ -516,7 +516,7 @@ std::string UTF16ToASCII(const string16& utf16) {
return std::string(utf16.begin(), utf16.end());
}
-string16 ASCIIToUTF16(const StringPiece& ascii) {
+string16 ASCIIToUTF16(const base::StringPiece& ascii) {
DCHECK(IsStringASCII(ascii)) << ascii;
return string16(ascii.begin(), ascii.end());
}
@@ -563,7 +563,7 @@ bool IsStringASCII(const string16& str) {
}
#endif
-bool IsStringASCII(const StringPiece& str) {
+bool IsStringASCII(const base::StringPiece& str) {
return DoIsStringASCII(str);
}
@@ -745,7 +745,7 @@ bool LowerCaseEqualsASCII(const wchar_t* a_begin,
return DoLowerCaseEqualsASCII(a_begin, a_end, b);
}
-bool EqualsASCII(const string16& a, const StringPiece& b) {
+bool EqualsASCII(const string16& a, const base::StringPiece& b) {
if (a.length() != b.length())
return false;
return std::equal(b.begin(), b.end(), a.begin());
diff --git a/base/string_util.h b/base/string_util.h
index d1767f9..9143346 100644
--- a/base/string_util.h
+++ b/base/string_util.h
@@ -176,9 +176,9 @@ std::string CollapseWhitespaceASCII(const std::string& text,
// These convert between ASCII (7-bit) and Wide/UTF16 strings.
std::string WideToASCII(const std::wstring& wide);
-std::wstring ASCIIToWide(const StringPiece& ascii);
+std::wstring ASCIIToWide(const base::StringPiece& ascii);
std::string UTF16ToASCII(const string16& utf16);
-string16 ASCIIToUTF16(const StringPiece& ascii);
+string16 ASCIIToUTF16(const base::StringPiece& ascii);
// These convert between UTF-8, -16, and -32 strings. They are potentially slow,
// so avoid unnecessary conversions. The low-level versions return a boolean
@@ -196,7 +196,7 @@ string16 ASCIIToUTF16(const StringPiece& ascii);
bool WideToUTF8(const wchar_t* src, size_t src_len, std::string* output);
std::string WideToUTF8(const std::wstring& wide);
bool UTF8ToWide(const char* src, size_t src_len, std::wstring* output);
-std::wstring UTF8ToWide(const StringPiece& utf8);
+std::wstring UTF8ToWide(const base::StringPiece& utf8);
bool WideToUTF16(const wchar_t* src, size_t src_len, string16* output);
string16 WideToUTF16(const std::wstring& wide);
@@ -287,7 +287,7 @@ bool IsString8Bit(const std::wstring& str);
bool IsStringUTF8(const std::string& str);
bool IsStringWideUTF8(const std::wstring& str);
bool IsStringASCII(const std::wstring& str);
-bool IsStringASCII(const StringPiece& str);
+bool IsStringASCII(const base::StringPiece& str);
bool IsStringASCII(const string16& str);
// ASCII-specific tolower. The standard library's tolower is locale sensitive,
@@ -353,7 +353,7 @@ bool LowerCaseEqualsASCII(const wchar_t* a_begin,
// Performs a case-sensitive string compare. The behavior is undefined if both
// strings are not ASCII.
-bool EqualsASCII(const string16& a, const StringPiece& b);
+bool EqualsASCII(const string16& a, const base::StringPiece& b);
// Returns true if str starts with search, or false otherwise.
bool StartsWithASCII(const std::string& str,
diff --git a/base/string_util_icu.cc b/base/string_util_icu.cc
index a043e97..d3c9edf 100644
--- a/base/string_util_icu.cc
+++ b/base/string_util_icu.cc
@@ -333,7 +333,7 @@ bool WideToUTF8(const wchar_t* src, size_t src_len, std::string* output) {
return ConvertUnicode<wchar_t, std::string>(src, src_len, output);
}
-std::wstring UTF8ToWide(const StringPiece& utf8) {
+std::wstring UTF8ToWide(const base::StringPiece& utf8) {
std::wstring ret;
if (utf8.empty())
return ret;
diff --git a/base/sys_string_conversions.h b/base/sys_string_conversions.h
index 420c301..18be826 100644
--- a/base/sys_string_conversions.h
+++ b/base/sys_string_conversions.h
@@ -22,10 +22,10 @@ class NSString;
#endif
#endif // OS_MACOSX
-class StringPiece;
-
namespace base {
+class StringPiece;
+
// Converts between wide and UTF-8 representations of a string. On error, the
// result is system-dependent.
std::string SysWideToUTF8(const std::wstring& wide);