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 #ifndef COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_SCANNER_H_
6 #define COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_SCANNER_H_
10 #include "base/basictypes.h"
11 #include "base/strings/string16.h"
17 // A helper class for parsing a stream of |AutofillField|'s with lookahead.
18 class AutofillScanner
{
20 explicit AutofillScanner(std::vector
<AutofillField
*>& fields
);
23 // Advances the cursor by one step, if possible.
26 // Returns the current field in the stream, or |NULL| if there are no more
27 // fields in the stream.
28 AutofillField
* Cursor() const;
30 // Returns |true| if the cursor has reached the end of the stream.
33 // Restores the most recently saved cursor. See also |SaveCursor()|.
36 // Repositions the cursor to the specified |index|. See also |SaveCursor()|.
37 void RewindTo(size_t index
);
39 // Saves and returns the current cursor position. See also |Rewind()| and
44 // Indicates the current position in the stream, represented as a vector.
45 std::vector
<AutofillField
*>::const_iterator cursor_
;
47 // The most recently saved cursor.
48 std::vector
<AutofillField
*>::const_iterator saved_cursor_
;
50 // The beginning pointer for the stream.
51 const std::vector
<AutofillField
*>::iterator begin_
;
53 // The past-the-end pointer for the stream.
54 const std::vector
<AutofillField
*>::iterator end_
;
56 DISALLOW_COPY_AND_ASSIGN(AutofillScanner
);
59 } // namespace autofill
61 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_SCANNER_H_