Autofill: Add WalletIntegrationAvailable() to components.
[chromium-blink-merge.git] / tools / gn / c_include_iterator.h
blob94ebca14909bd5005dde1025606968ab7b0f7f53
1 // Copyright 2014 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 TOOLS_GN_C_INCLUDE_ITERATOR_H_
6 #define TOOLS_GN_C_INCLUDE_ITERATOR_H_
8 #include "base/basictypes.h"
9 #include "base/strings/string_piece.h"
11 class InputFile;
12 class LocationRange;
14 // Iterates through #includes in C source and header files.
16 // This only returns includes we want to check, which is user includes with
17 // double-quotes: #include "..."
18 class CIncludeIterator {
19 public:
20 // The InputFile pointed to must outlive this class.
21 explicit CIncludeIterator(const InputFile* input);
22 ~CIncludeIterator();
24 // Fills in the string with the contents of the next include, and the
25 // location with where it came from, and returns true, or returns false if
26 // there are no more includes.
27 bool GetNextIncludeString(base::StringPiece* out, LocationRange* location);
29 // Maximum numbef of non-includes we'll tolerate before giving up. This does
30 // not count comments or preprocessor.
31 static const int kMaxNonIncludeLines;
33 private:
34 // Returns false on EOF, otherwise fills in the given line and the one-based
35 // line number into *line_number;
36 bool GetNextLine(base::StringPiece* line, int* line_number);
38 const InputFile* input_file_;
40 // This just points into input_file_.contents() for convenience.
41 base::StringPiece file_;
43 // 0-based offset into the file.
44 size_t offset_;
46 int line_number_; // One-based. Indicates the last line we read.
48 // Number of lines we've processed since seeing the last include (or the
49 // beginning of the file) with some exceptions.
50 int lines_since_last_include_;
52 DISALLOW_COPY_AND_ASSIGN(CIncludeIterator);
55 #endif // TOOLS_GN_C_INCLUDE_ITERATOR_H_