Rename GetIconID to GetIconId
[chromium-blink-merge.git] / components / autofill / core / browser / autofill_scanner.h
blobdb3f3baf7d0f9cc3165922e4f225990291d41677
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_
8 #include <vector>
10 #include "base/basictypes.h"
11 #include "base/strings/string16.h"
13 namespace autofill {
15 class AutofillField;
17 // A helper class for parsing a stream of |AutofillField|'s with lookahead.
18 class AutofillScanner {
19 public:
20 explicit AutofillScanner(std::vector<AutofillField*>& fields);
21 ~AutofillScanner();
23 // Advances the cursor by one step, if possible.
24 void Advance();
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.
31 bool IsEnd() const;
33 // Restores the most recently saved cursor. See also |SaveCursor()|.
34 void Rewind();
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
40 // |RewindTo()|.
41 size_t SaveCursor();
43 private:
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_