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

Unified Diff: trunk/src/tools/gn/pattern.h

Issue 21084010: Revert 214254 "Add initial prototype for the GN meta-buildsystem." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 7 years, 5 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
« no previous file with comments | « trunk/src/tools/gn/path_output_unittest.cc ('k') | trunk/src/tools/gn/pattern.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: trunk/src/tools/gn/pattern.h
===================================================================
--- trunk/src/tools/gn/pattern.h (revision 214322)
+++ trunk/src/tools/gn/pattern.h (working copy)
@@ -1,86 +0,0 @@
-// Copyright (c) 2013 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_PATTERN_H_
-#define TOOLS_GN_PATTERN_H_
-
-#include <string>
-#include <vector>
-
-#include "tools/gn/value.h"
-
-class Pattern {
- public:
- struct Subrange {
- enum Type {
- LITERAL, // Matches exactly the contents of the string.
- ANYTHING, // * (zero or more chars).
- PATH_BOUNDARY // '/' or beginning of string.
- };
-
- Subrange(Type t, const std::string& l = std::string())
- : type(t),
- literal(l) {
- }
-
- // Returns the minimum number of chars that this subrange requires.
- size_t MinSize() const {
- switch (type) {
- case LITERAL:
- return literal.size();
- case ANYTHING:
- return 0;
- case PATH_BOUNDARY:
- return 0; // Can match beginning or end of string, which is 0 len.
- default:
- return 0;
- }
- }
-
- Type type;
-
- // When type == LITERAL this is the text to match.
- std::string literal;
- };
-
- Pattern(const std::string& s);
- ~Pattern();
-
- // Returns true if the current pattern matches the given string.
- bool MatchesString(const std::string& s) const;
-
- private:
- // allow_implicit_path_boundary determines if a path boundary should accept
- // matches at the beginning or end of the string.
- bool RecursiveMatch(const std::string& s,
- size_t begin_char,
- size_t subrange_index,
- bool allow_implicit_path_boundary) const;
-
- std::vector<Subrange> subranges_;
-
- // Set to true when the subranges are "*foo" ("ANYTHING" followed by a
- // literal). This covers most patterns so we optimize for this.
- bool is_suffix_;
-};
-
-class PatternList {
- public:
- PatternList();
- ~PatternList();
-
- bool is_empty() const { return patterns_.empty(); }
-
- // Initializes the pattern list from a give list of pattern strings. Sets
- // |*err| on failure.
- void SetFromValue(const Value& v, Err* err);
-
- bool MatchesString(const std::string& s) const;
- bool MatchesValue(const Value& v) const;
-
- private:
- std::vector<Pattern> patterns_;
-};
-
-#endif // TOOLS_GN_PATTERN_H_
« no previous file with comments | « trunk/src/tools/gn/path_output_unittest.cc ('k') | trunk/src/tools/gn/pattern.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698