| 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 16 matching lines...) Expand all Loading... |
| 27 return type == other.type && literal == other.literal; | 27 return type == other.type && literal == other.literal; |
| 28 } | 28 } |
| 29 | 29 |
| 30 SubstitutionType type; | 30 SubstitutionType type; |
| 31 | 31 |
| 32 // When type_ == LITERAL, this specifies the literal. | 32 // When type_ == LITERAL, this specifies the literal. |
| 33 std::string literal; | 33 std::string literal; |
| 34 }; | 34 }; |
| 35 | 35 |
| 36 SubstitutionPattern(); | 36 SubstitutionPattern(); |
| 37 SubstitutionPattern(const SubstitutionPattern& other); |
| 37 ~SubstitutionPattern(); | 38 ~SubstitutionPattern(); |
| 38 | 39 |
| 39 // Parses the given string and fills in the pattern. The pattern must only | 40 // 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. | 41 // be initialized once. On failure, returns false and sets the error. |
| 41 bool Parse(const Value& value, Err* err); | 42 bool Parse(const Value& value, Err* err); |
| 42 bool Parse(const std::string& str, const ParseNode* origin, Err* err); | 43 bool Parse(const std::string& str, const ParseNode* origin, Err* err); |
| 43 | 44 |
| 44 // Makes a pattern given a hardcoded string. Will assert if the string is | 45 // Makes a pattern given a hardcoded string. Will assert if the string is |
| 45 // not a valid pattern. | 46 // not a valid pattern. |
| 46 static SubstitutionPattern MakeForTest(const char* str); | 47 static SubstitutionPattern MakeForTest(const char* str); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 68 bool empty() const { return ranges_.empty(); } | 69 bool empty() const { return ranges_.empty(); } |
| 69 | 70 |
| 70 private: | 71 private: |
| 71 std::vector<Subrange> ranges_; | 72 std::vector<Subrange> ranges_; |
| 72 const ParseNode* origin_; | 73 const ParseNode* origin_; |
| 73 | 74 |
| 74 std::vector<SubstitutionType> required_types_; | 75 std::vector<SubstitutionType> required_types_; |
| 75 }; | 76 }; |
| 76 | 77 |
| 77 #endif // TOOLS_GN_SUBSTITUTION_PATTERN_H_ | 78 #endif // TOOLS_GN_SUBSTITUTION_PATTERN_H_ |
| OLD | NEW |