OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/break_iterator.h" | 5 #include "base/i18n/break_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/uchar.h" |
10 #include "unicode/ustring.h" | 10 #include "unicode/ustring.h" |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 NOTREACHED() << "invalid break_type_"; | 85 NOTREACHED() << "invalid break_type_"; |
86 return false; | 86 return false; |
87 } | 87 } |
88 } | 88 } |
89 | 89 |
90 bool BreakIterator::IsWord() const { | 90 bool BreakIterator::IsWord() const { |
91 int32_t status = ubrk_getRuleStatus(static_cast<UBreakIterator*>(iter_)); | 91 int32_t status = ubrk_getRuleStatus(static_cast<UBreakIterator*>(iter_)); |
92 return (break_type_ == BREAK_WORD && status != UBRK_WORD_NONE); | 92 return (break_type_ == BREAK_WORD && status != UBRK_WORD_NONE); |
93 } | 93 } |
94 | 94 |
| 95 bool BreakIterator::IsEndOfWord(size_t position) const { |
| 96 if (break_type_ != BREAK_WORD) |
| 97 return false; |
| 98 |
| 99 UBreakIterator* iter = static_cast<UBreakIterator*>(iter_); |
| 100 UBool boundary = ubrk_isBoundary(iter, static_cast<int32_t>(position)); |
| 101 int32_t status = ubrk_getRuleStatus(iter); |
| 102 return (!!boundary && status != UBRK_WORD_NONE); |
| 103 } |
| 104 |
| 105 bool BreakIterator::IsStartOfWord(size_t position) const { |
| 106 if (break_type_ != BREAK_WORD) |
| 107 return false; |
| 108 |
| 109 UBreakIterator* iter = static_cast<UBreakIterator*>(iter_); |
| 110 UBool boundary = ubrk_isBoundary(iter, static_cast<int32_t>(position)); |
| 111 ubrk_next(iter); |
| 112 int32_t next_status = ubrk_getRuleStatus(iter); |
| 113 return (!!boundary && next_status != UBRK_WORD_NONE); |
| 114 } |
| 115 |
95 string16 BreakIterator::GetString() const { | 116 string16 BreakIterator::GetString() const { |
96 DCHECK(prev_ != npos && pos_ != npos); | 117 DCHECK(prev_ != npos && pos_ != npos); |
97 return string_.substr(prev_, pos_ - prev_); | 118 return string_.substr(prev_, pos_ - prev_); |
98 } | 119 } |
99 | 120 |
100 } // namespace i18n | 121 } // namespace i18n |
101 } // namespace base | 122 } // namespace base |
OLD | NEW |