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 #ifndef BASE_I18N_BREAK_ITERATOR_H_ | 5 #ifndef BASE_I18N_BREAK_ITERATOR_H_ |
6 #define BASE_I18N_BREAK_ITERATOR_H_ | 6 #define BASE_I18N_BREAK_ITERATOR_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/i18n/base_i18n_export.h" | 9 #include "base/i18n/base_i18n_export.h" |
10 #include "base/strings/string16.h" | 10 #include "base/strings/string16.h" |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
64 // TODO(jshin): Remove this after reviewing call sites. | 64 // TODO(jshin): Remove this after reviewing call sites. |
65 // If call sites really need break only on space-like characters | 65 // If call sites really need break only on space-like characters |
66 // implement it separately. | 66 // implement it separately. |
67 BREAK_SPACE = BREAK_LINE, | 67 BREAK_SPACE = BREAK_LINE, |
68 BREAK_NEWLINE, | 68 BREAK_NEWLINE, |
69 BREAK_CHARACTER, | 69 BREAK_CHARACTER, |
70 // But don't remove this one! | 70 // But don't remove this one! |
71 RULE_BASED, | 71 RULE_BASED, |
72 }; | 72 }; |
73 | 73 |
74 enum WordBreakStatus { IS_WORD_BREAK, IS_SKIPPABLE_WORD, IS_NOT_WORD_BREAK }; | |
please use gerrit instead
2015/08/07 17:16:59
add newlines and comments on the meaning of these
Julius
2015/08/07 20:30:04
Done.
| |
75 | |
74 // Requires |str| to live as long as the BreakIterator does. | 76 // Requires |str| to live as long as the BreakIterator does. |
75 BreakIterator(const StringPiece16& str, BreakType break_type); | 77 BreakIterator(const StringPiece16& str, BreakType break_type); |
76 // Make a rule-based iterator. BreakType == RULE_BASED is implied. | 78 // Make a rule-based iterator. BreakType == RULE_BASED is implied. |
77 // TODO(andrewhayden): This signature could easily be misinterpreted as | 79 // TODO(andrewhayden): This signature could easily be misinterpreted as |
78 // "(const string16& str, const string16& locale)". We should do something | 80 // "(const string16& str, const string16& locale)". We should do something |
79 // better. | 81 // better. |
80 BreakIterator(const StringPiece16& str, const string16& rules); | 82 BreakIterator(const StringPiece16& str, const string16& rules); |
81 ~BreakIterator(); | 83 ~BreakIterator(); |
82 | 84 |
83 // Init() must be called before any of the iterators are valid. | 85 // Init() must be called before any of the iterators are valid. |
(...skipping 10 matching lines...) Expand all Loading... | |
94 // if Init() had been called again. Any old state is lost. Returns true | 96 // if Init() had been called again. Any old state is lost. Returns true |
95 // unless there is an error setting the text. | 97 // unless there is an error setting the text. |
96 bool SetText(const base::char16* text, const size_t length); | 98 bool SetText(const base::char16* text, const size_t length); |
97 | 99 |
98 // Under BREAK_WORD mode, returns true if the break we just hit is the | 100 // Under BREAK_WORD mode, returns true if the break we just hit is the |
99 // end of a word. (Otherwise, the break iterator just skipped over e.g. | 101 // end of a word. (Otherwise, the break iterator just skipped over e.g. |
100 // whitespace or punctuation.) Under BREAK_LINE and BREAK_NEWLINE modes, | 102 // whitespace or punctuation.) Under BREAK_LINE and BREAK_NEWLINE modes, |
101 // this distinction doesn't apply and it always returns false. | 103 // this distinction doesn't apply and it always returns false. |
102 bool IsWord() const; | 104 bool IsWord() const; |
103 | 105 |
106 // Under BREAK_WORD mode, returns IS_WORD_BREAK if the break we just hit is | |
107 // the end of a word. Under BREAK_LINE and BREAK_NEWLINE modes, this | |
108 // distinction doesn't apply and it always returns IS_NOT_WORD_BREAK. | |
109 // Otherwise, the iterator just skipped over e.g. whitespace, punctuation, or | |
110 // characters that are unsupported by |rules_| and returns IS_SKIPPABLE_WORD. | |
111 BreakIterator::WordBreakStatus IsWordBreak() const; | |
112 | |
104 // Under BREAK_WORD mode, returns true if |position| is at the end of word or | 113 // Under BREAK_WORD mode, returns true if |position| is at the end of word or |
105 // at the start of word. It always returns false under BREAK_LINE and | 114 // at the start of word. It always returns false under BREAK_LINE and |
106 // BREAK_NEWLINE modes. | 115 // BREAK_NEWLINE modes. |
107 bool IsEndOfWord(size_t position) const; | 116 bool IsEndOfWord(size_t position) const; |
108 bool IsStartOfWord(size_t position) const; | 117 bool IsStartOfWord(size_t position) const; |
109 | 118 |
110 // Under BREAK_CHARACTER mode, returns whether |position| is a Unicode | 119 // Under BREAK_CHARACTER mode, returns whether |position| is a Unicode |
111 // grapheme boundary. | 120 // grapheme boundary. |
112 bool IsGraphemeBoundary(size_t position) const; | 121 bool IsGraphemeBoundary(size_t position) const; |
113 | 122 |
(...skipping 30 matching lines...) Expand all Loading... | |
144 // Previous and current iterator positions. | 153 // Previous and current iterator positions. |
145 size_t prev_, pos_; | 154 size_t prev_, pos_; |
146 | 155 |
147 DISALLOW_COPY_AND_ASSIGN(BreakIterator); | 156 DISALLOW_COPY_AND_ASSIGN(BreakIterator); |
148 }; | 157 }; |
149 | 158 |
150 } // namespace i18n | 159 } // namespace i18n |
151 } // namespace base | 160 } // namespace base |
152 | 161 |
153 #endif // BASE_I18N_BREAK_ITERATOR_H_ | 162 #endif // BASE_I18N_BREAK_ITERATOR_H_ |
OLD | NEW |