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

Unified Diff: tools/gn/c_include_iterator.h

Issue 216903004: Add optional public header checking to GN build (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: review comments 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 side-by-side diff with in-line comments
Download patch
Index: tools/gn/c_include_iterator.h
diff --git a/tools/gn/c_include_iterator.h b/tools/gn/c_include_iterator.h
new file mode 100644
index 0000000000000000000000000000000000000000..47088fa0793204c6c93a9576fa2bce6344a865ea
--- /dev/null
+++ b/tools/gn/c_include_iterator.h
@@ -0,0 +1,40 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef TOOLS_GN_C_INCLUDE_ITERATOR_H_
+#define TOOLS_GN_C_INCLUDE_ITERATOR_H_
+
+#include "base/basictypes.h"
+#include "base/strings/string_piece.h"
+
+// Iterates through #includes in C source and header files.
+//
+// This only returns includes we want to check, which is user includes with
+// double-quotes: #include "..."
+class CIncludeIterator {
+ public:
+ // The buffer pointed to must outlive this class.
+ CIncludeIterator(const base::StringPiece& file);
+ ~CIncludeIterator();
+
+ // Fills in the string with the contents of the next include and returns
+ // true, or returns false if there are no more includes.
+ bool GetNextIncludeString(base::StringPiece* out);
+
+ private:
+ // Returns false on EOF, otherwise fills in the given line.
+ bool GetNextLine(base::StringPiece* line);
+
+ base::StringPiece file_;
+
+ size_t offset_;
+
+ // Number of lines we've processed since seeing the last include (or the
+ // beginning of the file) with some exceptions.
+ int lines_since_last_include_;
+
+ DISALLOW_COPY_AND_ASSIGN(CIncludeIterator);
+};
+
+#endif // TOOLS_GN_INCLUDE_ITERATOR_H_

Powered by Google App Engine
This is Rietveld 408576698