Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(81)

Side by Side Diff: tools/gn/c_include_iterator.h

Issue 229423002: Improve public header file checking (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « third_party/freetype2/BUILD.gn ('k') | tools/gn/c_include_iterator.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef TOOLS_GN_C_INCLUDE_ITERATOR_H_ 5 #ifndef TOOLS_GN_C_INCLUDE_ITERATOR_H_
6 #define TOOLS_GN_C_INCLUDE_ITERATOR_H_ 6 #define TOOLS_GN_C_INCLUDE_ITERATOR_H_
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/strings/string_piece.h" 9 #include "base/strings/string_piece.h"
10 10
11 class InputFile;
12 class LocationRange;
13
11 // Iterates through #includes in C source and header files. 14 // Iterates through #includes in C source and header files.
12 // 15 //
13 // This only returns includes we want to check, which is user includes with 16 // This only returns includes we want to check, which is user includes with
14 // double-quotes: #include "..." 17 // double-quotes: #include "..."
15 class CIncludeIterator { 18 class CIncludeIterator {
16 public: 19 public:
17 // The buffer pointed to must outlive this class. 20 // The InputFile pointed to must outlive this class.
18 CIncludeIterator(const base::StringPiece& file); 21 CIncludeIterator(const InputFile* input);
19 ~CIncludeIterator(); 22 ~CIncludeIterator();
20 23
21 // Fills in the string with the contents of the next include and returns 24 // Fills in the string with the contents of the next include, and the
22 // true, or returns false if there are no more includes. 25 // location with where it came from, and returns true, or returns false if
23 bool GetNextIncludeString(base::StringPiece* out); 26 // there are no more includes.
27 bool GetNextIncludeString(base::StringPiece* out, LocationRange* location);
24 28
25 // Maximum numbef of non-includes we'll tolerate before giving up. This does 29 // Maximum numbef of non-includes we'll tolerate before giving up. This does
26 // not count comments or preprocessor. 30 // not count comments or preprocessor.
27 static const int kMaxNonIncludeLines; 31 static const int kMaxNonIncludeLines;
28 32
29 private: 33 private:
30 // Returns false on EOF, otherwise fills in the given line. 34 // Returns false on EOF, otherwise fills in the given line and the one-based
31 bool GetNextLine(base::StringPiece* line); 35 // line number into *line_number;
scottmg 2014/04/08 23:07:20 ; -> .
36 bool GetNextLine(base::StringPiece* line, int* line_number);
32 37
38 const InputFile* input_file_;
39
40 // This just points into input_file_.contents() for convenience.
33 base::StringPiece file_; 41 base::StringPiece file_;
34 42
43 // 0-based offset into the file.
35 size_t offset_; 44 size_t offset_;
36 45
46 int line_number_; // One-based. Indicates the last line we read.
47
37 // Number of lines we've processed since seeing the last include (or the 48 // Number of lines we've processed since seeing the last include (or the
38 // beginning of the file) with some exceptions. 49 // beginning of the file) with some exceptions.
39 int lines_since_last_include_; 50 int lines_since_last_include_;
40 51
41 DISALLOW_COPY_AND_ASSIGN(CIncludeIterator); 52 DISALLOW_COPY_AND_ASSIGN(CIncludeIterator);
42 }; 53 };
43 54
44 #endif // TOOLS_GN_INCLUDE_ITERATOR_H_ 55 #endif // TOOLS_GN_INCLUDE_ITERATOR_H_
OLDNEW
« no previous file with comments | « third_party/freetype2/BUILD.gn ('k') | tools/gn/c_include_iterator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698