OLD | NEW |
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_SUBSTITUTION_PATTERN_H_ | 5 #ifndef TOOLS_GN_SUBSTITUTION_PATTERN_H_ |
6 #define TOOLS_GN_SUBSTITUTION_PATTERN_H_ | 6 #define TOOLS_GN_SUBSTITUTION_PATTERN_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 23 matching lines...) Expand all Loading... |
34 }; | 34 }; |
35 | 35 |
36 SubstitutionPattern(); | 36 SubstitutionPattern(); |
37 ~SubstitutionPattern(); | 37 ~SubstitutionPattern(); |
38 | 38 |
39 // Parses the given string and fills in the pattern. The pattern must only | 39 // Parses the given string and fills in the pattern. The pattern must only |
40 // be initialized once. On failure, returns false and sets the error. | 40 // be initialized once. On failure, returns false and sets the error. |
41 bool Parse(const Value& value, Err* err); | 41 bool Parse(const Value& value, Err* err); |
42 bool Parse(const std::string& str, const ParseNode* origin, Err* err); | 42 bool Parse(const std::string& str, const ParseNode* origin, Err* err); |
43 | 43 |
| 44 // Makes a pattern given a hardcoded string. Will assert if the string is |
| 45 // not a valid pattern. |
| 46 static SubstitutionPattern MakeForTest(const char* str); |
| 47 |
44 // Returns the pattern as a string with substitutions in them. | 48 // Returns the pattern as a string with substitutions in them. |
45 std::string AsString() const; | 49 std::string AsString() const; |
46 | 50 |
47 // Sets the bits in the given vector corresponding to the substitutions used | 51 // Sets the bits in the given vector corresponding to the substitutions used |
48 // by this pattern. SUBSTITUTION_LITERAL is ignored. | 52 // by this pattern. SUBSTITUTION_LITERAL is ignored. |
49 void FillRequiredTypes(SubstitutionBits* bits) const; | 53 void FillRequiredTypes(SubstitutionBits* bits) const; |
50 | 54 |
51 // Checks whether this pattern resolves to something in the output directory | 55 // Checks whether this pattern resolves to something in the output directory |
52 // for the given build settings. If not, returns false and fills in the given | 56 // for the given build settings. If not, returns false and fills in the given |
53 // error. | 57 // error. |
(...skipping 10 matching lines...) Expand all Loading... |
64 bool empty() const { return ranges_.empty(); } | 68 bool empty() const { return ranges_.empty(); } |
65 | 69 |
66 private: | 70 private: |
67 std::vector<Subrange> ranges_; | 71 std::vector<Subrange> ranges_; |
68 const ParseNode* origin_; | 72 const ParseNode* origin_; |
69 | 73 |
70 std::vector<SubstitutionType> required_types_; | 74 std::vector<SubstitutionType> required_types_; |
71 }; | 75 }; |
72 | 76 |
73 #endif // TOOLS_GN_SUBSTITUTION_PATTERN_H_ | 77 #endif // TOOLS_GN_SUBSTITUTION_PATTERN_H_ |
OLD | NEW |