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

Unified Diff: base/i18n/break_iterator.h

Issue 6979019: base/i18n: Make BreakIterator::IsWord() more readable. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 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 82e8092632c94eae1e60c9848f38aa16e7cc8559..e49b46e68b523386644f113c4f0ef7d3537269c5 100644
--- a/base/i18n/break_iterator.h
+++ b/base/i18n/break_iterator.h
@@ -41,12 +41,13 @@
// breaks are at the periods in ".foo\n.bar\n.\n.").
//
// To extract the words from a string, move a BREAK_WORD BreakIterator
-// through the string and test whether IsWord() is true. E.g.,
-// BreakIterator iter(&str, BreakIterator::BREAK_WORD);
-// if (!iter.Init()) return false;
+// through the string and test whether IsWord() is true. E.g.,
+// BreakIterator iter(str, BreakIterator::BREAK_WORD);
+// if (!iter.Init())
+// return false;
// while (iter.Advance()) {
// if (iter.IsWord()) {
-// // region [iter.prev(),iter.pos()) contains a word.
+// // Region [iter.prev(), iter.pos()) contains a word.
// VLOG(1) << "word: " << iter.GetString();
// }
// }
@@ -74,13 +75,6 @@ class BreakIterator {
// Returns false if ICU failed to initialize.
bool Init();
- // Return the current break position within the string,
- // or BreakIterator::npos when done.
- size_t pos() const { return pos_; }
-
- // Return the value of pos() returned before Advance() was last called.
- size_t prev() const { return prev_; }
-
// Advance to the next break. Returns false if we've run past the end of
// the string. (Note that the very last "break" is after the final
// character in the string, and when we advance to that position it's the
@@ -93,11 +87,18 @@ class BreakIterator {
// this distinction doesn't apply and it always retuns false.
bool IsWord() const;
- // Return the string between prev() and pos().
- // Advance() must have been called successfully at least once
- // for pos() to have advanced to somewhere useful.
+ // Returns the string between prev() and pos().
+ // Advance() must have been called successfully at least once for pos() to
+ // have advanced to somewhere useful.
string16 GetString() const;
+ // Returns the value of pos() returned before Advance() was last called.
+ size_t prev() const { return prev_; }
+
+ // Returns the current break position within the string,
+ // or BreakIterator::npos when done.
+ size_t pos() const { return pos_; }
+
private:
// ICU iterator, avoiding ICU ubrk.h dependence.
// This is actually an ICU UBreakiterator* type, which turns out to be
« 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