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_CHAR_ITERATOR_H_ | 5 #ifndef BASE_I18N_CHAR_ITERATOR_H_ |
6 #define BASE_I18N_CHAR_ITERATOR_H_ | 6 #define BASE_I18N_CHAR_ITERATOR_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/i18n/base_i18n_export.h" | 11 #include "base/i18n/base_i18n_export.h" |
12 #include "base/strings/string16.h" | 12 #include "base/strings/string16.h" |
13 | 13 |
14 // The CharIterator classes iterate through the characters in UTF8 and | 14 // The CharIterator classes iterate through the characters in UTF8 and |
15 // UTF16 strings. Example usage: | 15 // UTF16 strings. Example usage: |
16 // | 16 // |
17 // UTF8CharIterator iter(&str); | 17 // UTF8CharIterator iter(&str); |
18 // while (!iter.end()) { | 18 // while (!iter.end()) { |
19 // VLOG(1) << iter.get(); | 19 // VLOG(1) << iter.get(); |
20 // iter.Advance(); | 20 // iter.Advance(); |
21 // } | 21 // } |
22 | 22 |
23 #if defined(OS_WIN) | |
24 typedef unsigned char uint8_t; | |
25 #endif | |
26 | |
27 namespace base { | 23 namespace base { |
28 namespace i18n { | 24 namespace i18n { |
29 | 25 |
30 class BASE_I18N_EXPORT UTF8CharIterator { | 26 class BASE_I18N_EXPORT UTF8CharIterator { |
31 public: | 27 public: |
32 // Requires |str| to live as long as the UTF8CharIterator does. | 28 // Requires |str| to live as long as the UTF8CharIterator does. |
33 explicit UTF8CharIterator(const std::string* str); | 29 explicit UTF8CharIterator(const std::string* str); |
34 ~UTF8CharIterator(); | 30 ~UTF8CharIterator(); |
35 | 31 |
36 // Return the starting array index of the current character within the | 32 // Return the starting array index of the current character within the |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 // The current character. | 117 // The current character. |
122 int32 char_; | 118 int32 char_; |
123 | 119 |
124 DISALLOW_COPY_AND_ASSIGN(UTF16CharIterator); | 120 DISALLOW_COPY_AND_ASSIGN(UTF16CharIterator); |
125 }; | 121 }; |
126 | 122 |
127 } // namespace i18n | 123 } // namespace i18n |
128 } // namespace base | 124 } // namespace base |
129 | 125 |
130 #endif // BASE_I18N_CHAR_ITERATOR_H_ | 126 #endif // BASE_I18N_CHAR_ITERATOR_H_ |
OLD | NEW |