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 |
11 #include "tools/gn/substitution_type.h" | 11 #include "tools/gn/substitution_type.h" |
12 | 12 |
13 class BuildSettings; | 13 class BuildSettings; |
14 class Err; | 14 class Err; |
15 class ParseNode; | 15 class ParseNode; |
16 class Value; | 16 class Value; |
17 | 17 |
18 // Represents a string with {{substitution_patterns}} in them. | 18 // Represents a string with {{substitution_patterns}} in them. |
19 class SubstitutionPattern { | 19 class SubstitutionPattern { |
20 public: | 20 public: |
21 struct Subrange { | 21 struct Subrange { |
22 Subrange(); | 22 Subrange(); |
23 Subrange(SubstitutionType t, const std::string& l = std::string()); | 23 explicit Subrange(SubstitutionType t, const std::string& l = std::string()); |
24 ~Subrange(); | 24 ~Subrange(); |
25 | 25 |
26 inline bool operator==(const Subrange& other) const { | 26 inline bool operator==(const Subrange& other) const { |
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; |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 bool empty() const { return ranges_.empty(); } | 68 bool empty() const { return ranges_.empty(); } |
69 | 69 |
70 private: | 70 private: |
71 std::vector<Subrange> ranges_; | 71 std::vector<Subrange> ranges_; |
72 const ParseNode* origin_; | 72 const ParseNode* origin_; |
73 | 73 |
74 std::vector<SubstitutionType> required_types_; | 74 std::vector<SubstitutionType> required_types_; |
75 }; | 75 }; |
76 | 76 |
77 #endif // TOOLS_GN_SUBSTITUTION_PATTERN_H_ | 77 #endif // TOOLS_GN_SUBSTITUTION_PATTERN_H_ |
OLD | NEW |