1 // Copyright 2013 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 "components/autofill/core/browser/autofill_scanner.h"
7 #include "base/logging.h"
8 #include "components/autofill/core/browser/autofill_field.h"
12 AutofillScanner::AutofillScanner(std::vector
<AutofillField
*>& fields
)
13 : cursor_(fields
.begin()),
14 saved_cursor_(fields
.begin()),
15 begin_(fields
.begin()),
19 AutofillScanner::~AutofillScanner() {
22 void AutofillScanner::Advance() {
27 AutofillField
* AutofillScanner::Cursor() const {
36 bool AutofillScanner::IsEnd() const {
37 return cursor_
== end_
;
40 void AutofillScanner::Rewind() {
41 DCHECK(saved_cursor_
!= end_
);
42 cursor_
= saved_cursor_
;
46 void AutofillScanner::RewindTo(size_t index
) {
47 DCHECK(index
< static_cast<size_t>(end_
- begin_
));
48 cursor_
= begin_
+ index
;
52 size_t AutofillScanner::SaveCursor() {
53 saved_cursor_
= cursor_
;
54 return static_cast<size_t>(cursor_
- begin_
);
57 } // namespace autofill