Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(548)

Side by Side Diff: base/i18n/break_iterator.cc

Issue 1272683002: Creates BreakIterator::GetWordBreakStatus. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "third_party/icu/source/common/unicode/ubrk.h" 8 #include "third_party/icu/source/common/unicode/ubrk.h"
9 #include "third_party/icu/source/common/unicode/uchar.h" 9 #include "third_party/icu/source/common/unicode/uchar.h"
10 #include "third_party/icu/source/common/unicode/ustring.h" 10 #include "third_party/icu/source/common/unicode/ustring.h"
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 return true; 137 return true;
138 } 138 }
139 139
140 bool BreakIterator::IsWord() const { 140 bool BreakIterator::IsWord() const {
141 int32_t status = ubrk_getRuleStatus(static_cast<UBreakIterator*>(iter_)); 141 int32_t status = ubrk_getRuleStatus(static_cast<UBreakIterator*>(iter_));
142 if (break_type_ != BREAK_WORD && break_type_ != RULE_BASED) 142 if (break_type_ != BREAK_WORD && break_type_ != RULE_BASED)
143 return false; 143 return false;
144 return status != UBRK_WORD_NONE; 144 return status != UBRK_WORD_NONE;
145 } 145 }
146 146
147 BreakIterator::WordBreakStatus BreakIterator::IsWordBreak() const {
148 if (break_type_ != BREAK_WORD && break_type_ != RULE_BASED)
149 return IS_NOT_WORD_BREAK;
150 return ubrk_getRuleStatus(static_cast<UBreakIterator*>(iter_)) ==
151 UBRK_WORD_NONE
152 ? IS_SKIPPABLE_WORD
153 : IS_WORD_BREAK;
154 }
155
147 bool BreakIterator::IsEndOfWord(size_t position) const { 156 bool BreakIterator::IsEndOfWord(size_t position) const {
148 if (break_type_ != BREAK_WORD && break_type_ != RULE_BASED) 157 if (break_type_ != BREAK_WORD && break_type_ != RULE_BASED)
149 return false; 158 return false;
150 159
151 UBreakIterator* iter = static_cast<UBreakIterator*>(iter_); 160 UBreakIterator* iter = static_cast<UBreakIterator*>(iter_);
152 UBool boundary = ubrk_isBoundary(iter, static_cast<int32_t>(position)); 161 UBool boundary = ubrk_isBoundary(iter, static_cast<int32_t>(position));
153 int32_t status = ubrk_getRuleStatus(iter); 162 int32_t status = ubrk_getRuleStatus(iter);
154 return (!!boundary && status != UBRK_WORD_NONE); 163 return (!!boundary && status != UBRK_WORD_NONE);
155 } 164 }
156 165
(...skipping 20 matching lines...) Expand all
177 return GetStringPiece().as_string(); 186 return GetStringPiece().as_string();
178 } 187 }
179 188
180 StringPiece16 BreakIterator::GetStringPiece() const { 189 StringPiece16 BreakIterator::GetStringPiece() const {
181 DCHECK(prev_ != npos && pos_ != npos); 190 DCHECK(prev_ != npos && pos_ != npos);
182 return string_.substr(prev_, pos_ - prev_); 191 return string_.substr(prev_, pos_ - prev_);
183 } 192 }
184 193
185 } // namespace i18n 194 } // namespace i18n
186 } // namespace base 195 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698