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 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/string16.h" | 10 #include "base/string16.h" |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 // character in the string, and when we advance to that position it's the | 80 // character in the string, and when we advance to that position it's the |
81 // last time Advance() returns true.) | 81 // last time Advance() returns true.) |
82 bool Advance(); | 82 bool Advance(); |
83 | 83 |
84 // Under BREAK_WORD mode, returns true if the break we just hit is the | 84 // Under BREAK_WORD mode, returns true if the break we just hit is the |
85 // end of a word. (Otherwise, the break iterator just skipped over e.g. | 85 // end of a word. (Otherwise, the break iterator just skipped over e.g. |
86 // whitespace or punctuation.) Under BREAK_LINE and BREAK_NEWLINE modes, | 86 // whitespace or punctuation.) Under BREAK_LINE and BREAK_NEWLINE modes, |
87 // this distinction doesn't apply and it always retuns false. | 87 // this distinction doesn't apply and it always retuns false. |
88 bool IsWord() const; | 88 bool IsWord() const; |
89 | 89 |
| 90 // Returns true if |position| is a valid word break. |
| 91 // Loosely follow common Windows behavior; break at word logical beginnings. |
| 92 // TODO(msw): Consider "better" word break algorithms and other platforms. |
| 93 bool IsWordBreakAt(size_t position); |
| 94 |
90 // Returns the string between prev() and pos(). | 95 // Returns the string between prev() and pos(). |
91 // Advance() must have been called successfully at least once for pos() to | 96 // Advance() must have been called successfully at least once for pos() to |
92 // have advanced to somewhere useful. | 97 // have advanced to somewhere useful. |
93 string16 GetString() const; | 98 string16 GetString() const; |
94 | 99 |
95 // Returns the value of pos() returned before Advance() was last called. | 100 // Returns the value of pos() returned before Advance() was last called. |
96 size_t prev() const { return prev_; } | 101 size_t prev() const { return prev_; } |
97 | 102 |
98 // Returns the current break position within the string, | 103 // Returns the current break position within the string, |
99 // or BreakIterator::npos when done. | 104 // or BreakIterator::npos when done. |
(...skipping 15 matching lines...) Expand all Loading... |
115 // Previous and current iterator positions. | 120 // Previous and current iterator positions. |
116 size_t prev_, pos_; | 121 size_t prev_, pos_; |
117 | 122 |
118 DISALLOW_COPY_AND_ASSIGN(BreakIterator); | 123 DISALLOW_COPY_AND_ASSIGN(BreakIterator); |
119 }; | 124 }; |
120 | 125 |
121 } // namespace i18n | 126 } // namespace i18n |
122 } // namespace base | 127 } // namespace base |
123 | 128 |
124 #endif // BASE_I18N_BREAK_ITERATOR_H_ | 129 #endif // BASE_I18N_BREAK_ITERATOR_H_ |
OLD | NEW |