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

Unified Diff: base/i18n/break_iterator.h

Issue 270203003: Refactor code to avoid direct dependency upon ICU: spellcheck_worditerator (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@refactoring_icu_usage
Patch Set: jungshik@ comments Created 6 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | base/i18n/break_iterator.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/i18n/break_iterator.h
diff --git a/base/i18n/break_iterator.h b/base/i18n/break_iterator.h
index 618a320924e4993e4d76ee818462c6512b8bcc37..b34c6770d10fa7badd5c1a50ec290e9c8cf53491 100644
--- a/base/i18n/break_iterator.h
+++ b/base/i18n/break_iterator.h
@@ -66,10 +66,17 @@ class BASE_I18N_EXPORT BreakIterator {
BREAK_SPACE = BREAK_LINE,
BREAK_NEWLINE,
BREAK_CHARACTER,
+ // But don't remove this one!
+ RULE_BASED,
};
// Requires |str| to live as long as the BreakIterator does.
BreakIterator(const string16& str, BreakType break_type);
+ // Make a rule-based iterator. BreakType == RULE_BASED is implied.
+ // TODO(andrewhayden): This signature could easily be misinterpreted as
+ // "(const string16& str, const string16& locale)". We should do something
+ // better.
+ BreakIterator(const string16& str, const string16& rules);
~BreakIterator();
// Init() must be called before any of the iterators are valid.
@@ -82,6 +89,11 @@ class BASE_I18N_EXPORT BreakIterator {
// last time Advance() returns true.)
bool Advance();
+ // Updates the text used by the iterator, resetting the iterator as if
+ // if Init() had been called again. Any old state is lost. Returns true
+ // unless there is an error setting the text.
+ bool SetText(const base::char16* text, const size_t length);
+
// Under BREAK_WORD mode, returns true if the break we just hit is the
// end of a word. (Otherwise, the break iterator just skipped over e.g.
// whitespace or punctuation.) Under BREAK_LINE and BREAK_NEWLINE modes,
@@ -113,10 +125,13 @@ class BASE_I18N_EXPORT BreakIterator {
// callers from needing access to the ICU public headers directory.
void* iter_;
- // The string we're iterating over.
+ // The string we're iterating over. Can be changed with SetText(...)
const string16& string_;
- // The breaking style (word/space/newline).
+ // Rules for our iterator. Mutually exclusive with break_type_.
+ const string16 rules_;
+
+ // The breaking style (word/space/newline). Mutually exclusive with rules_
BreakType break_type_;
// Previous and current iterator positions.
« no previous file with comments | « no previous file | base/i18n/break_iterator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698