| 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" |
| 11 #include "base/i18n/base_i18n_export.h" |
| 11 | 12 |
| 12 // The BreakIterator class iterates through the words, word breaks, and | 13 // The BreakIterator class iterates through the words, word breaks, and |
| 13 // line breaks in a UTF-16 string. | 14 // line breaks in a UTF-16 string. |
| 14 // | 15 // |
| 15 // It provides several modes, BREAK_WORD, BREAK_LINE, and BREAK_NEWLINE, | 16 // It provides several modes, BREAK_WORD, BREAK_LINE, and BREAK_NEWLINE, |
| 16 // which modify how characters are aggregated into the returned string. | 17 // which modify how characters are aggregated into the returned string. |
| 17 // | 18 // |
| 18 // Under BREAK_WORD mode, once a word is encountered any non-word | 19 // Under BREAK_WORD mode, once a word is encountered any non-word |
| 19 // characters are not included in the returned string (e.g. in the | 20 // characters are not included in the returned string (e.g. in the |
| 20 // UTF-16 equivalent of the string " foo bar! ", the word breaks are at | 21 // UTF-16 equivalent of the string " foo bar! ", the word breaks are at |
| (...skipping 27 matching lines...) Expand all Loading... |
| 48 // while (iter.Advance()) { | 49 // while (iter.Advance()) { |
| 49 // if (iter.IsWord()) { | 50 // if (iter.IsWord()) { |
| 50 // // Region [iter.prev(), iter.pos()) contains a word. | 51 // // Region [iter.prev(), iter.pos()) contains a word. |
| 51 // VLOG(1) << "word: " << iter.GetString(); | 52 // VLOG(1) << "word: " << iter.GetString(); |
| 52 // } | 53 // } |
| 53 // } | 54 // } |
| 54 | 55 |
| 55 namespace base { | 56 namespace base { |
| 56 namespace i18n { | 57 namespace i18n { |
| 57 | 58 |
| 58 class BreakIterator { | 59 class BASE_I18N_EXPORT BreakIterator { |
| 59 public: | 60 public: |
| 60 enum BreakType { | 61 enum BreakType { |
| 61 BREAK_WORD, | 62 BREAK_WORD, |
| 62 BREAK_LINE, | 63 BREAK_LINE, |
| 63 // TODO(jshin): Remove this after reviewing call sites. | 64 // TODO(jshin): Remove this after reviewing call sites. |
| 64 // If call sites really need break only on space-like characters | 65 // If call sites really need break only on space-like characters |
| 65 // implement it separately. | 66 // implement it separately. |
| 66 BREAK_SPACE = BREAK_LINE, | 67 BREAK_SPACE = BREAK_LINE, |
| 67 BREAK_NEWLINE, | 68 BREAK_NEWLINE, |
| 68 }; | 69 }; |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 // Previous and current iterator positions. | 116 // Previous and current iterator positions. |
| 116 size_t prev_, pos_; | 117 size_t prev_, pos_; |
| 117 | 118 |
| 118 DISALLOW_COPY_AND_ASSIGN(BreakIterator); | 119 DISALLOW_COPY_AND_ASSIGN(BreakIterator); |
| 119 }; | 120 }; |
| 120 | 121 |
| 121 } // namespace i18n | 122 } // namespace i18n |
| 122 } // namespace base | 123 } // namespace base |
| 123 | 124 |
| 124 #endif // BASE_I18N_BREAK_ITERATOR_H_ | 125 #endif // BASE_I18N_BREAK_ITERATOR_H_ |
| OLD | NEW |