summaryrefslogtreecommitdiffstats
path: root/base
diff options
context:
space:
mode:
Diffstat (limited to 'base')
-rw-r--r--base/string_split.cc10
-rw-r--r--base/string_split.h6
-rw-r--r--base/string_split_unittest.cc21
3 files changed, 16 insertions, 21 deletions
diff --git a/base/string_split.cc b/base/string_split.cc
index 2b1a037..44b5d06 100644
--- a/base/string_split.cc
+++ b/base/string_split.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -35,12 +35,20 @@ static void SplitStringT(const STR& str,
}
}
+void SplitString(const std::wstring& str,
+ wchar_t c,
+ std::vector<std::wstring>* r) {
+ SplitStringT(str, c, true, r);
+}
+
+#if !defined(WCHAR_T_IS_UTF16)
void SplitString(const string16& str,
char16 c,
std::vector<string16>* r) {
DCHECK(CBU16_IS_SINGLE(c));
SplitStringT(str, c, true, r);
}
+#endif
void SplitString(const std::string& str,
char c,
diff --git a/base/string_split.h b/base/string_split.h
index 883b126..f2e8c86 100644
--- a/base/string_split.h
+++ b/base/string_split.h
@@ -20,6 +20,12 @@ namespace base {
// |str| begins with or ends with |s|, then an empty string is inserted.
//
// Every substring is trimmed of any leading or trailing white space.
+// Where wchar_t is char16 (i.e. Windows), |c| must be in BMP
+// (Basic Multilingual Plane). Elsewhere (Linux/Mac), wchar_t
+// should be a valid Unicode code point (32-bit).
+BASE_API void SplitString(const std::wstring& str,
+ wchar_t c,
+ std::vector<std::wstring>* r);
// NOTE: |c| must be in BMP (Basic Multilingual Plane)
BASE_API void SplitString(const string16& str,
char16 c,
diff --git a/base/string_split_unittest.cc b/base/string_split_unittest.cc
index ee5877b..749d566 100644
--- a/base/string_split_unittest.cc
+++ b/base/string_split_unittest.cc
@@ -1,10 +1,8 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "base/string_split.h"
-
-#include "base/utf_string_conversions.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -12,23 +10,6 @@ using ::testing::ElementsAre;
namespace base {
-namespace {
-
-#if !defined(WCHAR_T_IS_UTF16)
-// Overload SplitString with a wide-char version to make it easier to
-// test the string16 version with wide character literals.
-void SplitString(const std::wstring& str,
- wchar_t c,
- std::vector<std::wstring>* result) {
- std::vector<string16> result16;
- SplitString(WideToUTF16(str), c, &result16);
- for (size_t i = 0; i < result16.size(); ++i)
- result->push_back(UTF16ToWide(result16[i]));
-}
-#endif
-
-} // anonymous namespace
-
class SplitStringIntoKeyValuesTest : public testing::Test {
protected:
std::string key;