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

Side by Side Diff: tools/gn/pattern.cc

Issue 1728303003: tools/gn: Add out-of-line copy ctors for complex classes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 #include "tools/gn/pattern.h" 5 #include "tools/gn/pattern.h"
6 6
7 #include "tools/gn/value.h" 7 #include "tools/gn/value.h"
8 8
9 namespace { 9 namespace {
10 10
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 } // namespace 53 } // namespace
54 54
55 Pattern::Pattern(const std::string& s) { 55 Pattern::Pattern(const std::string& s) {
56 ParsePattern(s, &subranges_); 56 ParsePattern(s, &subranges_);
57 is_suffix_ = 57 is_suffix_ =
58 (subranges_.size() == 2 && 58 (subranges_.size() == 2 &&
59 subranges_[0].type == Subrange::ANYTHING && 59 subranges_[0].type == Subrange::ANYTHING &&
60 subranges_[1].type == Subrange::LITERAL); 60 subranges_[1].type == Subrange::LITERAL);
61 } 61 }
62 62
63 Pattern::Pattern(const Pattern& other) = default;
64
63 Pattern::~Pattern() { 65 Pattern::~Pattern() {
64 } 66 }
65 67
66 bool Pattern::MatchesString(const std::string& s) const { 68 bool Pattern::MatchesString(const std::string& s) const {
67 // Empty pattern matches only empty string. 69 // Empty pattern matches only empty string.
68 if (subranges_.empty()) 70 if (subranges_.empty())
69 return s.empty(); 71 return s.empty();
70 72
71 if (is_suffix_) { 73 if (is_suffix_) {
72 const std::string& suffix = subranges_[1].literal; 74 const std::string& suffix = subranges_[1].literal;
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 default: 146 default:
145 NOTREACHED(); 147 NOTREACHED();
146 } 148 }
147 149
148 return false; 150 return false;
149 } 151 }
150 152
151 PatternList::PatternList() { 153 PatternList::PatternList() {
152 } 154 }
153 155
156 PatternList::PatternList(const PatternList& other) = default;
157
154 PatternList::~PatternList() { 158 PatternList::~PatternList() {
155 } 159 }
156 160
157 void PatternList::Append(const Pattern& pattern) { 161 void PatternList::Append(const Pattern& pattern) {
158 patterns_.push_back(pattern); 162 patterns_.push_back(pattern);
159 } 163 }
160 164
161 void PatternList::SetFromValue(const Value& v, Err* err) { 165 void PatternList::SetFromValue(const Value& v, Err* err) {
162 patterns_.clear(); 166 patterns_.clear();
163 167
(...skipping 16 matching lines...) Expand all
180 return true; 184 return true;
181 } 185 }
182 return false; 186 return false;
183 } 187 }
184 188
185 bool PatternList::MatchesValue(const Value& v) const { 189 bool PatternList::MatchesValue(const Value& v) const {
186 if (v.type() == Value::STRING) 190 if (v.type() == Value::STRING)
187 return MatchesString(v.string_value()); 191 return MatchesString(v.string_value());
188 return false; 192 return false;
189 } 193 }
OLDNEW
« tools/gn/label.h ('K') | « tools/gn/pattern.h ('k') | tools/gn/substitution_list.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698