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 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
99 // have advanced to somewhere useful. | 99 // have advanced to somewhere useful. |
100 string16 GetString() const; | 100 string16 GetString() const; |
101 | 101 |
102 // Returns the value of pos() returned before Advance() was last called. | 102 // Returns the value of pos() returned before Advance() was last called. |
103 size_t prev() const { return prev_; } | 103 size_t prev() const { return prev_; } |
104 | 104 |
105 // Returns the current break position within the string, | 105 // Returns the current break position within the string, |
106 // or BreakIterator::npos when done. | 106 // or BreakIterator::npos when done. |
107 size_t pos() const { return pos_; } | 107 size_t pos() const { return pos_; } |
108 | 108 |
109 // Returns whether or not the iterator is currently at a valid position. | |
110 bool IsValid() const { | |
111 return pos_ != static_cast<size_t>(-1); | |
112 } | |
mattm
2014/05/09 23:07:12
This change is no longer needed
Andrew Hayden (chromium.org)
2014/05/12 13:07:37
Done.
| |
113 | |
109 private: | 114 private: |
110 // ICU iterator, avoiding ICU ubrk.h dependence. | 115 // ICU iterator, avoiding ICU ubrk.h dependence. |
111 // This is actually an ICU UBreakiterator* type, which turns out to be | 116 // This is actually an ICU UBreakiterator* type, which turns out to be |
112 // a typedef for a void* in the ICU headers. Using void* directly prevents | 117 // a typedef for a void* in the ICU headers. Using void* directly prevents |
113 // callers from needing access to the ICU public headers directory. | 118 // callers from needing access to the ICU public headers directory. |
114 void* iter_; | 119 void* iter_; |
115 | 120 |
116 // The string we're iterating over. | 121 // The string we're iterating over. |
117 const string16& string_; | 122 const string16& string_; |
118 | 123 |
119 // The breaking style (word/space/newline). | 124 // The breaking style (word/space/newline). |
120 BreakType break_type_; | 125 BreakType break_type_; |
121 | 126 |
122 // Previous and current iterator positions. | 127 // Previous and current iterator positions. |
123 size_t prev_, pos_; | 128 size_t prev_, pos_; |
124 | 129 |
125 DISALLOW_COPY_AND_ASSIGN(BreakIterator); | 130 DISALLOW_COPY_AND_ASSIGN(BreakIterator); |
126 }; | 131 }; |
127 | 132 |
128 } // namespace i18n | 133 } // namespace i18n |
129 } // namespace base | 134 } // namespace base |
130 | 135 |
131 #endif // BASE_I18N_BREAK_ITERATOR_H_ | 136 #endif // BASE_I18N_BREAK_ITERATOR_H_ |
OLD | NEW |