| 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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 BREAK_WORD, | 60 BREAK_WORD, |
| 61 BREAK_LINE, | 61 BREAK_LINE, |
| 62 // TODO(jshin): Remove this after reviewing call sites. | 62 // TODO(jshin): Remove this after reviewing call sites. |
| 63 // If call sites really need break only on space-like characters | 63 // If call sites really need break only on space-like characters |
| 64 // implement it separately. | 64 // implement it separately. |
| 65 BREAK_SPACE = BREAK_LINE, | 65 BREAK_SPACE = BREAK_LINE, |
| 66 BREAK_NEWLINE, | 66 BREAK_NEWLINE, |
| 67 }; | 67 }; |
| 68 | 68 |
| 69 // Requires |str| to live as long as the BreakIterator does. | 69 // Requires |str| to live as long as the BreakIterator does. |
| 70 BreakIterator(const string16* str, BreakType break_type); | 70 BreakIterator(const string16& str, BreakType break_type); |
| 71 ~BreakIterator(); | 71 ~BreakIterator(); |
| 72 | 72 |
| 73 // Init() must be called before any of the iterators are valid. | 73 // Init() must be called before any of the iterators are valid. |
| 74 // Returns false if ICU failed to initialize. | 74 // Returns false if ICU failed to initialize. |
| 75 bool Init(); | 75 bool Init(); |
| 76 | 76 |
| 77 // Return the current break position within the string, | 77 // Return the current break position within the string, |
| 78 // or BreakIterator::npos when done. | 78 // or BreakIterator::npos when done. |
| 79 size_t pos() const { return pos_; } | 79 size_t pos() const { return pos_; } |
| 80 | 80 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 99 string16 GetString() const; | 99 string16 GetString() const; |
| 100 | 100 |
| 101 private: | 101 private: |
| 102 // ICU iterator, avoiding ICU ubrk.h dependence. | 102 // ICU iterator, avoiding ICU ubrk.h dependence. |
| 103 // This is actually an ICU UBreakiterator* type, which turns out to be | 103 // This is actually an ICU UBreakiterator* type, which turns out to be |
| 104 // a typedef for a void* in the ICU headers. Using void* directly prevents | 104 // a typedef for a void* in the ICU headers. Using void* directly prevents |
| 105 // callers from needing access to the ICU public headers directory. | 105 // callers from needing access to the ICU public headers directory. |
| 106 void* iter_; | 106 void* iter_; |
| 107 | 107 |
| 108 // The string we're iterating over. | 108 // The string we're iterating over. |
| 109 const string16* string_; | 109 const string16& string_; |
| 110 | 110 |
| 111 // The breaking style (word/space/newline). | 111 // The breaking style (word/space/newline). |
| 112 BreakType break_type_; | 112 BreakType break_type_; |
| 113 | 113 |
| 114 // Previous and current iterator positions. | 114 // Previous and current iterator positions. |
| 115 size_t prev_, pos_; | 115 size_t prev_, pos_; |
| 116 | 116 |
| 117 DISALLOW_COPY_AND_ASSIGN(BreakIterator); | 117 DISALLOW_COPY_AND_ASSIGN(BreakIterator); |
| 118 }; | 118 }; |
| 119 | 119 |
| 120 } // namespace i18n | 120 } // namespace i18n |
| 121 } // namespace base | 121 } // namespace base |
| 122 | 122 |
| 123 #endif // BASE_I18N_BREAK_ITERATOR_H_ | 123 #endif // BASE_I18N_BREAK_ITERATOR_H_ |
| OLD | NEW |