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 #ifndef TOOLS_GN_CONFIG_VALUES_EXTRACTORS_H_ | 5 #ifndef TOOLS_GN_CONFIG_VALUES_EXTRACTORS_H_ |
6 #define TOOLS_GN_CONFIG_VALUES_EXTRACTORS_H_ | 6 #define TOOLS_GN_CONFIG_VALUES_EXTRACTORS_H_ |
7 | 7 |
8 #include <ostream> | 8 #include <ostream> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "tools/gn/config.h" | 12 #include "tools/gn/config.h" |
13 #include "tools/gn/config_values.h" | 13 #include "tools/gn/config_values.h" |
14 #include "tools/gn/target.h" | 14 #include "tools/gn/target.h" |
15 | 15 |
16 struct EscapeOptions; | 16 struct EscapeOptions; |
17 | 17 |
18 // Provides a way to iterate through all ConfigValues applying to a given | 18 // Provides a way to iterate through all ConfigValues applying to a given |
19 // target. This is more complicated than normal because the target has a list | 19 // target. This is more complicated than normal because the target has a list |
20 // of configs applying to it, and also config values on the target itself. | 20 // of configs applying to it, and also config values on the target itself. |
21 // | 21 // |
22 // This iterator allows one to iterate through all of these in a defined order | 22 // This iterator allows one to iterate through all of these in a defined order |
23 // in one convenient loop. The order is defined to be the ConfigValues on the | 23 // in one convenient loop. The order is defined to be the ConfigValues on the |
24 // target itself first, then the applying configs, in order. | 24 // target itself first, then the applying configs, in order. |
25 // | 25 // |
26 // Example: | 26 // Example: |
27 // for (ConfigValueIterator iter(target); !iter.done(); iter.Next()) | 27 // for (ConfigValueIterator iter(target); !iter.done(); iter.Next()) |
28 // DoSomething(iter->cur()); | 28 // DoSomething(iter.cur()); |
29 class ConfigValuesIterator { | 29 class ConfigValuesIterator { |
30 public: | 30 public: |
31 explicit ConfigValuesIterator(const Target* target) | 31 explicit ConfigValuesIterator(const Target* target) |
32 : target_(target), | 32 : target_(target), |
33 cur_index_(-1) { | 33 cur_index_(-1) { |
34 } | 34 } |
35 | 35 |
36 bool done() const { | 36 bool done() const { |
37 return cur_index_ >= static_cast<int>(target_->configs().size()); | 37 return cur_index_ >= static_cast<int>(target_->configs().size()); |
38 } | 38 } |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 } | 96 } |
97 | 97 |
98 // Writes the values out as strings with no transformation. | 98 // Writes the values out as strings with no transformation. |
99 void RecursiveTargetConfigStringsToStream( | 99 void RecursiveTargetConfigStringsToStream( |
100 const Target* target, | 100 const Target* target, |
101 const std::vector<std::string>& (ConfigValues::* getter)() const, | 101 const std::vector<std::string>& (ConfigValues::* getter)() const, |
102 const EscapeOptions& escape_options, | 102 const EscapeOptions& escape_options, |
103 std::ostream& out); | 103 std::ostream& out); |
104 | 104 |
105 #endif // TOOLS_GN_CONFIG_VALUES_EXTRACTORS_H_ | 105 #endif // TOOLS_GN_CONFIG_VALUES_EXTRACTORS_H_ |
OLD | NEW |