| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef TOOLS_GN_CONFIG_VALUES_EXTRACTORS_H_ | |
| 6 #define TOOLS_GN_CONFIG_VALUES_EXTRACTORS_H_ | |
| 7 | |
| 8 #include <ostream> | |
| 9 #include <string> | |
| 10 #include <vector> | |
| 11 | |
| 12 #include "tools/gn/config.h" | |
| 13 #include "tools/gn/config_values.h" | |
| 14 #include "tools/gn/target.h" | |
| 15 | |
| 16 template<typename T, class Writer> | |
| 17 inline void ConfigValuesToStream( | |
| 18 const ConfigValues& values, | |
| 19 const std::vector<T>& (ConfigValues::* getter)() const, | |
| 20 const Writer& writer, | |
| 21 std::ostream& out) { | |
| 22 const std::vector<T>& v = (values.*getter)(); | |
| 23 for (size_t i = 0; i < v.size(); i++) | |
| 24 writer(v[i], out); | |
| 25 }; | |
| 26 | |
| 27 template<typename T, class Writer> | |
| 28 inline void RecursiveTargetConfigToStream( | |
| 29 const Target* target, | |
| 30 const std::vector<T>& (ConfigValues::* getter)() const, | |
| 31 const Writer& writer, | |
| 32 std::ostream& out) { | |
| 33 // Write all configs in reverse order (to get oldest first, which will look | |
| 34 // more normal in the output). | |
| 35 for (int i = static_cast<int>(target->configs().size() - 1); i >= 0; i--) { | |
| 36 ConfigValuesToStream(target->configs()[i]->config_values(), getter, | |
| 37 writer, out); | |
| 38 } | |
| 39 | |
| 40 // Last write from the config from the Target itself, if any. | |
| 41 ConfigValuesToStream(target->config_values(), getter, writer, out); | |
| 42 } | |
| 43 | |
| 44 // Writes the values out as strings with no transformation. | |
| 45 void RecursiveTargetConfigStringsToStream( | |
| 46 const Target* target, | |
| 47 const std::vector<std::string>& (ConfigValues::* getter)() const, | |
| 48 std::ostream& out); | |
| 49 | |
| 50 #endif // TOOLS_GN_CONFIG_VALUES_EXTRACTORS_H_ | |
| OLD | NEW |