OLD | NEW |
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/input_conversion.h" | 5 #include "tools/gn/input_conversion.h" |
6 | 6 |
7 #include "base/strings/string_split.h" | 7 #include "base/strings/string_split.h" |
8 #include "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
9 #include "tools/gn/build_settings.h" | 9 #include "tools/gn/build_settings.h" |
10 #include "tools/gn/err.h" | 10 #include "tools/gn/err.h" |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 Value DoConvertInputToValue(const Settings* settings, | 109 Value DoConvertInputToValue(const Settings* settings, |
110 const std::string& input, | 110 const std::string& input, |
111 const ParseNode* origin, | 111 const ParseNode* origin, |
112 const Value& original_input_conversion, | 112 const Value& original_input_conversion, |
113 const std::string& input_conversion, | 113 const std::string& input_conversion, |
114 Err* err) { | 114 Err* err) { |
115 if (input_conversion.empty()) | 115 if (input_conversion.empty()) |
116 return Value(); // Empty string means discard the result. | 116 return Value(); // Empty string means discard the result. |
117 | 117 |
118 const char kTrimPrefix[] = "trim "; | 118 const char kTrimPrefix[] = "trim "; |
119 if (StartsWithASCII(input_conversion, kTrimPrefix, true)) { | 119 if (base::StartsWithASCII(input_conversion, kTrimPrefix, true)) { |
120 std::string trimmed; | 120 std::string trimmed; |
121 base::TrimWhitespaceASCII(input, base::TRIM_ALL, &trimmed); | 121 base::TrimWhitespaceASCII(input, base::TRIM_ALL, &trimmed); |
122 | 122 |
123 // Remove "trim" prefix from the input conversion and re-run. | 123 // Remove "trim" prefix from the input conversion and re-run. |
124 return DoConvertInputToValue( | 124 return DoConvertInputToValue( |
125 settings, trimmed, origin, original_input_conversion, | 125 settings, trimmed, origin, original_input_conversion, |
126 input_conversion.substr(arraysize(kTrimPrefix) - 1), err); | 126 input_conversion.substr(arraysize(kTrimPrefix) - 1), err); |
127 } | 127 } |
128 | 128 |
129 if (input_conversion == "value") | 129 if (input_conversion == "value") |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 const ParseNode* origin, | 200 const ParseNode* origin, |
201 const Value& input_conversion_value, | 201 const Value& input_conversion_value, |
202 Err* err) { | 202 Err* err) { |
203 if (input_conversion_value.type() == Value::NONE) | 203 if (input_conversion_value.type() == Value::NONE) |
204 return Value(); // Allow null inputs to mean discard the result. | 204 return Value(); // Allow null inputs to mean discard the result. |
205 if (!input_conversion_value.VerifyTypeIs(Value::STRING, err)) | 205 if (!input_conversion_value.VerifyTypeIs(Value::STRING, err)) |
206 return Value(); | 206 return Value(); |
207 return DoConvertInputToValue(settings, input, origin, input_conversion_value, | 207 return DoConvertInputToValue(settings, input, origin, input_conversion_value, |
208 input_conversion_value.string_value(), err); | 208 input_conversion_value.string_value(), err); |
209 } | 209 } |
OLD | NEW |