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 // Defines an iterator class that enumerates words supported by our spellchecker | 5 // Defines an iterator class that enumerates words supported by our spellchecker |
6 // from multi-language text. This class is used for filtering out characters | 6 // from multi-language text. This class is used for filtering out characters |
7 // not supported by our spellchecker. | 7 // not supported by our spellchecker. |
8 | 8 |
9 #ifndef CHROME_RENDERER_SPELLCHECKER_SPELLCHECK_WORDITERATOR_H_ | 9 #ifndef CHROME_RENDERER_SPELLCHECKER_SPELLCHECK_WORDITERATOR_H_ |
10 #define CHROME_RENDERER_SPELLCHECKER_SPELLCHECK_WORDITERATOR_H_ | 10 #define CHROME_RENDERER_SPELLCHECKER_SPELLCHECK_WORDITERATOR_H_ |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 // temporal memory to compile a custom word-break rule into an automaton.) | 115 // temporal memory to compile a custom word-break rule into an automaton.) |
116 bool Initialize(const SpellcheckCharAttribute* attribute, | 116 bool Initialize(const SpellcheckCharAttribute* attribute, |
117 bool allow_contraction); | 117 bool allow_contraction); |
118 | 118 |
119 // Returns whether this word iterator is initialized. | 119 // Returns whether this word iterator is initialized. |
120 bool IsInitialized() const; | 120 bool IsInitialized() const; |
121 | 121 |
122 // Set text to be iterated. (This text does not have to be NULL-terminated.) | 122 // Set text to be iterated. (This text does not have to be NULL-terminated.) |
123 // This function also resets internal state so we can reuse this iterator | 123 // This function also resets internal state so we can reuse this iterator |
124 // without calling Initialize(). | 124 // without calling Initialize(). |
125 bool SetText(const char16* text, size_t length); | 125 bool SetText(const base::char16* text, size_t length); |
126 | 126 |
127 // Retrieves a word (or a contraction), stores its copy to 'word_string', and | 127 // Retrieves a word (or a contraction), stores its copy to 'word_string', and |
128 // stores the position and the length for input word to 'word_start'. Since | 128 // stores the position and the length for input word to 'word_start'. Since |
129 // this function normalizes the output word, the length of 'word_string' may | 129 // this function normalizes the output word, the length of 'word_string' may |
130 // be different from the 'word_length'. Therefore, when we call functions that | 130 // be different from the 'word_length'. Therefore, when we call functions that |
131 // changes the input text, such as string16::replace(), we need to use | 131 // changes the input text, such as string16::replace(), we need to use |
132 // 'word_start' and 'word_length' as listed in the following snippet. | 132 // 'word_start' and 'word_length' as listed in the following snippet. |
133 // | 133 // |
134 // while(iterator.GetNextWord(&word, &offset, &length)) | 134 // while(iterator.GetNextWord(&word, &offset, &length)) |
135 // text.replace(offset, length, word); | 135 // text.replace(offset, length, word); |
(...skipping 11 matching lines...) Expand all Loading... |
147 // not supported by our spellchecker, e.g. ligatures, combining/ characters, | 147 // not supported by our spellchecker, e.g. ligatures, combining/ characters, |
148 // full-width letters, etc. This function replaces such characters with | 148 // full-width letters, etc. This function replaces such characters with |
149 // alternative characters supported by our spellchecker. This function also | 149 // alternative characters supported by our spellchecker. This function also |
150 // calls SpellcheckWordIterator::OutputChar() to filter out false-positive | 150 // calls SpellcheckWordIterator::OutputChar() to filter out false-positive |
151 // characters. | 151 // characters. |
152 bool Normalize(int input_start, | 152 bool Normalize(int input_start, |
153 int input_length, | 153 int input_length, |
154 base::string16* output_string) const; | 154 base::string16* output_string) const; |
155 | 155 |
156 // The pointer to the input string from which we are extracting words. | 156 // The pointer to the input string from which we are extracting words. |
157 const char16* text_; | 157 const base::char16* text_; |
158 | 158 |
159 // The length of the original string. | 159 // The length of the original string. |
160 int length_; | 160 int length_; |
161 | 161 |
162 // The current position in the original string. | 162 // The current position in the original string. |
163 int position_; | 163 int position_; |
164 | 164 |
165 // The language-specific attributes used for filtering out non-word | 165 // The language-specific attributes used for filtering out non-word |
166 // characters. | 166 // characters. |
167 const SpellcheckCharAttribute* attribute_; | 167 const SpellcheckCharAttribute* attribute_; |
168 | 168 |
169 // The ICU break iterator. | 169 // The ICU break iterator. |
170 UBreakIterator* iterator_; | 170 UBreakIterator* iterator_; |
171 | 171 |
172 DISALLOW_COPY_AND_ASSIGN(SpellcheckWordIterator); | 172 DISALLOW_COPY_AND_ASSIGN(SpellcheckWordIterator); |
173 }; | 173 }; |
174 | 174 |
175 #endif // CHROME_RENDERER_SPELLCHECKER_SPELLCHECK_WORDITERATOR_H_ | 175 #endif // CHROME_RENDERER_SPELLCHECKER_SPELLCHECK_WORDITERATOR_H_ |
176 | 176 |
OLD | NEW |