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 3 // found in the LICENSE file. 4 5 #ifndef TOOLS_GN_SUBSTITUTION_LIST_H_ 6 #define TOOLS_GN_SUBSTITUTION_LIST_H_ 7 8 #include <string> 9 #include <vector> 10 11 #include "gn/substitution_pattern.h" 12 13 // Represents a list of strings with {{substitution_patterns}} in them. 14 class SubstitutionList { 15 public: 16 SubstitutionList(); 17 SubstitutionList(const SubstitutionList& other); 18 ~SubstitutionList(); 19 20 SubstitutionList& operator=(const SubstitutionList&) = default; 21 22 bool Parse(const Value& value, Err* err); 23 bool Parse(const std::vector<std::string>& values, 24 const ParseNode* origin, 25 Err* err); 26 27 // Makes a SubstitutionList from the given hardcoded patterns. 28 static SubstitutionList MakeForTest(const char* a, 29 const char* b = nullptr, 30 const char* c = nullptr, 31 const char* d = nullptr); 32 list()33 const std::vector<SubstitutionPattern>& list() const { return list_; } 34 35 // Returns a list of all substitution types used by the patterns in this 36 // list, with the exception of LITERAL. required_types()37 const std::vector<const Substitution*>& required_types() const { 38 return required_types_; 39 } 40 41 void FillRequiredTypes(SubstitutionBits* bits) const; 42 43 private: 44 std::vector<SubstitutionPattern> list_; 45 46 std::vector<const Substitution*> required_types_; 47 }; 48 49 #endif // TOOLS_GN_SUBSTITUTION_LIST_H_ 50