summaryrefslogtreecommitdiffstats
path: root/base
diff options
context:
space:
mode:
authortfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-01-20 02:41:24 +0000
committertfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-01-20 02:41:24 +0000
commit4cf0d9d1cee4b1fa850bbeade738828ab817da07 (patch)
treef6d3500ecc790c882e0454b50d754efd120239a9 /base
parentd462c1abab5865c44036ee3d189fb6fa0717fe3f (diff)
downloadchromium_src-4cf0d9d1cee4b1fa850bbeade738828ab817da07.zip
chromium_src-4cf0d9d1cee4b1fa850bbeade738828ab817da07.tar.gz
chromium_src-4cf0d9d1cee4b1fa850bbeade738828ab817da07.tar.bz2
base/i18n: Add namespace i18n to CharIterator.
BUG=None TEST=None Review URL: http://codereview.chromium.org/6355005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@71910 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base')
-rw-r--r--base/i18n/char_iterator.cc10
-rw-r--r--base/i18n/char_iterator.h8
-rw-r--r--base/i18n/char_iterator_unittest.cc16
3 files changed, 25 insertions, 9 deletions
diff --git a/base/i18n/char_iterator.cc b/base/i18n/char_iterator.cc
index a6cf944..ce4d513 100644
--- a/base/i18n/char_iterator.cc
+++ b/base/i18n/char_iterator.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 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.
@@ -8,6 +8,7 @@
#include "unicode/utf16.h"
namespace base {
+namespace i18n {
UTF8CharIterator::UTF8CharIterator(const std::string* str)
: str_(reinterpret_cast<const uint8_t*>(str->data())),
@@ -20,6 +21,9 @@ UTF8CharIterator::UTF8CharIterator(const std::string* str)
U8_NEXT(str_, next_pos_, len_, char_);
}
+UTF8CharIterator::~UTF8CharIterator() {
+}
+
bool UTF8CharIterator::Advance() {
if (array_pos_ >= len_)
return false;
@@ -54,6 +58,9 @@ UTF16CharIterator::UTF16CharIterator(const char16* str, size_t str_len)
ReadChar();
}
+UTF16CharIterator::~UTF16CharIterator() {
+}
+
bool UTF16CharIterator::Advance() {
if (array_pos_ >= len_)
return false;
@@ -71,4 +78,5 @@ void UTF16CharIterator::ReadChar() {
U16_NEXT(str_, next_pos_, len_, char_);
}
+} // namespace i18n
} // namespace base
diff --git a/base/i18n/char_iterator.h b/base/i18n/char_iterator.h
index f45b04b..bd7cc9f 100644
--- a/base/i18n/char_iterator.h
+++ b/base/i18n/char_iterator.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 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.
@@ -25,12 +25,13 @@ typedef unsigned char uint8_t;
#endif
namespace base {
+namespace i18n {
class UTF8CharIterator {
public:
// Requires |str| to live as long as the UTF8CharIterator does.
UTF8CharIterator(const std::string* str);
- ~UTF8CharIterator() {}
+ ~UTF8CharIterator();
// Return the starting array index of the current character within the
// string.
@@ -77,7 +78,7 @@ class UTF16CharIterator {
// Requires |str| to live as long as the UTF16CharIterator does.
UTF16CharIterator(const string16* str);
UTF16CharIterator(const char16* str, size_t str_len);
- ~UTF16CharIterator() {}
+ ~UTF16CharIterator();
// Return the starting array index of the current character within the
// string.
@@ -123,6 +124,7 @@ class UTF16CharIterator {
DISALLOW_COPY_AND_ASSIGN(UTF16CharIterator);
};
+} // namespace i18n
} // namespace base
#endif // BASE_I18N_CHAR_ITERATOR_H_
diff --git a/base/i18n/char_iterator_unittest.cc b/base/i18n/char_iterator_unittest.cc
index 4fe7ebb..6d1294e 100644
--- a/base/i18n/char_iterator_unittest.cc
+++ b/base/i18n/char_iterator_unittest.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 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.
@@ -7,16 +7,19 @@
#include "base/utf_string_conversions.h"
#include "testing/gtest/include/gtest/gtest.h"
+namespace base {
+namespace i18n {
+
TEST(CharIteratorsTest, TestUTF8) {
std::string empty("");
- base::UTF8CharIterator empty_iter(&empty);
+ UTF8CharIterator empty_iter(&empty);
ASSERT_TRUE(empty_iter.end());
ASSERT_EQ(0, empty_iter.array_pos());
ASSERT_EQ(0, empty_iter.char_pos());
ASSERT_FALSE(empty_iter.Advance());
std::string str("s\303\273r"); // [u with circumflex]
- base::UTF8CharIterator iter(&str);
+ UTF8CharIterator iter(&str);
ASSERT_FALSE(iter.end());
ASSERT_EQ(0, iter.array_pos());
ASSERT_EQ(0, iter.char_pos());
@@ -47,7 +50,7 @@ TEST(CharIteratorsTest, TestUTF8) {
TEST(CharIteratorsTest, TestUTF16) {
string16 empty = UTF8ToUTF16("");
- base::UTF16CharIterator empty_iter(&empty);
+ UTF16CharIterator empty_iter(&empty);
ASSERT_TRUE(empty_iter.end());
ASSERT_EQ(0, empty_iter.array_pos());
ASSERT_EQ(0, empty_iter.char_pos());
@@ -59,7 +62,7 @@ TEST(CharIteratorsTest, TestUTF16) {
// math double-struck A - 4 bytes in UTF8, 2 codewords in UTF16
// z
string16 str = UTF8ToUTF16("x\303\273\360\235\224\270z");
- base::UTF16CharIterator iter(&str);
+ UTF16CharIterator iter(&str);
ASSERT_FALSE(iter.end());
ASSERT_EQ(0, iter.array_pos());
ASSERT_EQ(0, iter.char_pos());
@@ -93,3 +96,6 @@ TEST(CharIteratorsTest, TestUTF16) {
ASSERT_FALSE(iter.Advance());
}
+
+} // namespace i18n
+} // namespace base