Index: base/i18n/char_iterator.h |
diff --git a/base/i18n/char_iterator.h b/base/i18n/char_iterator.h |
index 46928b37d0bf5ba705b1fd1d411fe08046cacb24..33eebff42f3a54a9e225d781b02198b497b6dc9d 100644 |
--- a/base/i18n/char_iterator.h |
+++ b/base/i18n/char_iterator.h |
@@ -33,15 +33,15 @@ class BASE_I18N_EXPORT UTF8CharIterator { |
explicit UTF8CharIterator(const std::string* str); |
~UTF8CharIterator(); |
- // Return the starting array index of the current character within the |
+ // Returns the starting array index of the current character within the |
// string. |
int32 array_pos() const { return array_pos_; } |
- // Return the logical index of the current character, independent of the |
+ // Returns the logical index of the current character, independent of the |
// number of bytes each character takes. |
int32 char_pos() const { return char_pos_; } |
- // Return the current char. |
+ // Returns the current char. |
int32 get() const { return char_; } |
// Returns true if we're at the end of the string. |
@@ -51,6 +51,11 @@ class BASE_I18N_EXPORT UTF8CharIterator { |
// end of the string. |
bool Advance(); |
+ // Set the iterator to the specified |position|. If |position| is not a code |
+ // point boundary, the position is set to the beginning of the code point. |
+ // Calling this function invalidates all future |char_pos()| results. |
+ void SetPosition(int32 position); |
+ |
private: |
// The string we're iterating over. |
const uint8_t* str_; |
@@ -80,15 +85,15 @@ class BASE_I18N_EXPORT UTF16CharIterator { |
UTF16CharIterator(const char16* str, size_t str_len); |
~UTF16CharIterator(); |
- // Return the starting array index of the current character within the |
+ // Returns the starting array index of the current character within the |
// string. |
int32 array_pos() const { return array_pos_; } |
- // Return the logical index of the current character, independent of the |
+ // Returns the logical index of the current character, independent of the |
// number of codewords each character takes. |
int32 char_pos() const { return char_pos_; } |
- // Return the current char. |
+ // Returns the current char. |
int32 get() const { return char_; } |
// Returns true if we're at the end of the string. |
@@ -98,6 +103,11 @@ class BASE_I18N_EXPORT UTF16CharIterator { |
// end of the string. |
bool Advance(); |
+ // Set the iterator to the specified |position|. If |position| is not a code |
+ // point boundary, the position is set to the beginning of the code point. |
+ // Calling this function invalidates all future |char_pos()| results. |
+ void SetPosition(int32 position); |
+ |
private: |
// Fills in the current character we found and advances to the next |
// character, updating all flags as necessary. |