OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/i18n/word_iterator.h" | 5 #include "base/i18n/word_iterator.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "unicode/ubrk.h" | 8 #include "unicode/ubrk.h" |
| 9 #include "unicode/uchar.h" |
9 #include "unicode/ustring.h" | 10 #include "unicode/ustring.h" |
10 | 11 |
11 const size_t npos = -1; | 12 const size_t npos = -1; |
12 | 13 |
13 WordIterator::WordIterator(const string16* str, BreakType break_type) | 14 WordIterator::WordIterator(const string16* str, BreakType break_type) |
14 : iter_(NULL), | 15 : iter_(NULL), |
15 string_(str), | 16 string_(str), |
16 break_type_(break_type), | 17 break_type_(break_type), |
17 prev_(npos), | 18 prev_(npos), |
18 pos_(0) { | 19 pos_(0) { |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 } | 62 } |
62 | 63 |
63 bool WordIterator::IsWord() const { | 64 bool WordIterator::IsWord() const { |
64 return (ubrk_getRuleStatus(iter_) != UBRK_WORD_NONE); | 65 return (ubrk_getRuleStatus(iter_) != UBRK_WORD_NONE); |
65 } | 66 } |
66 | 67 |
67 string16 WordIterator::GetWord() const { | 68 string16 WordIterator::GetWord() const { |
68 DCHECK(prev_ != npos && pos_ != npos); | 69 DCHECK(prev_ != npos && pos_ != npos); |
69 return string_->substr(prev_, pos_ - prev_); | 70 return string_->substr(prev_, pos_ - prev_); |
70 } | 71 } |
OLD | NEW |