Allow supervised users to delete profiles in about:settings.
[chromium-blink-merge.git] / base / i18n / char_iterator.cc
blob25efc518694c0fd480253b82f9e55dd3b598d406
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
3 // found in the LICENSE file.
5 #include "base/i18n/char_iterator.h"
7 #include "third_party/icu/source/common/unicode/utf8.h"
8 #include "third_party/icu/source/common/unicode/utf16.h"
10 namespace base {
11 namespace i18n {
13 UTF8CharIterator::UTF8CharIterator(const std::string* str)
14 : str_(reinterpret_cast<const uint8_t*>(str->data())),
15 len_(str->size()),
16 array_pos_(0),
17 next_pos_(0),
18 char_pos_(0),
19 char_(0) {
20 if (len_)
21 U8_NEXT(str_, next_pos_, len_, char_);
24 UTF8CharIterator::~UTF8CharIterator() {
27 bool UTF8CharIterator::Advance() {
28 if (array_pos_ >= len_)
29 return false;
31 array_pos_ = next_pos_;
32 char_pos_++;
33 if (next_pos_ < len_)
34 U8_NEXT(str_, next_pos_, len_, char_);
36 return true;
39 UTF16CharIterator::UTF16CharIterator(const string16* str)
40 : str_(reinterpret_cast<const char16*>(str->data())),
41 len_(str->size()),
42 array_pos_(0),
43 next_pos_(0),
44 char_pos_(0),
45 char_(0) {
46 if (len_)
47 ReadChar();
50 UTF16CharIterator::UTF16CharIterator(const char16* str, size_t str_len)
51 : str_(str),
52 len_(str_len),
53 array_pos_(0),
54 next_pos_(0),
55 char_pos_(0),
56 char_(0) {
57 if (len_)
58 ReadChar();
61 UTF16CharIterator::~UTF16CharIterator() {
64 bool UTF16CharIterator::Advance() {
65 if (array_pos_ >= len_)
66 return false;
68 array_pos_ = next_pos_;
69 char_pos_++;
70 if (next_pos_ < len_)
71 ReadChar();
73 return true;
76 void UTF16CharIterator::ReadChar() {
77 // This is actually a huge macro, so is worth having in a separate function.
78 U16_NEXT(str_, next_pos_, len_, char_);
81 } // namespace i18n
82 } // namespace base