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_OUTPUT_FILE_H_ | 5 #ifndef TOOLS_GN_OUTPUT_FILE_H_ |
6 #define TOOLS_GN_OUTPUT_FILE_H_ | 6 #define TOOLS_GN_OUTPUT_FILE_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/containers/hash_tables.h" | 10 #include "base/containers/hash_tables.h" |
11 #include "tools/gn/build_settings.h" | 11 #include "tools/gn/build_settings.h" |
12 #include "tools/gn/source_file.h" | 12 |
| 13 class SourceFile; |
13 | 14 |
14 // A simple wrapper around a string that indicates the string is a path | 15 // A simple wrapper around a string that indicates the string is a path |
15 // relative to the output directory. | 16 // relative to the output directory. |
16 class OutputFile { | 17 class OutputFile { |
17 public: | 18 public: |
18 OutputFile() : value_() {} | 19 OutputFile(); |
19 explicit OutputFile(const base::StringPiece& str) | 20 explicit OutputFile(const base::StringPiece& str); |
20 : value_(str.data(), str.size()) { | 21 OutputFile(const BuildSettings* build_settings, |
21 } | 22 const SourceFile& source_file); |
| 23 ~OutputFile(); |
22 | 24 |
23 std::string& value() { return value_; } | 25 std::string& value() { return value_; } |
24 const std::string& value() const { return value_; } | 26 const std::string& value() const { return value_; } |
25 | 27 |
26 // Converts to a SourceFile by prepending the build directory to the file. | 28 // Converts to a SourceFile by prepending the build directory to the file. |
27 SourceFile GetSourceFile(const BuildSettings* build_settings) const { | 29 // The *Dir version requires that the current OutputFile ends in a slash, and |
28 return SourceFile(build_settings->build_dir().value() + value_); | 30 // the *File version is the opposite. |
29 } | 31 SourceFile AsSourceFile(const BuildSettings* build_settings) const; |
| 32 SourceDir AsSourceDir(const BuildSettings* build_settings) const; |
30 | 33 |
31 bool operator==(const OutputFile& other) const { | 34 bool operator==(const OutputFile& other) const { |
32 return value_ == other.value_; | 35 return value_ == other.value_; |
33 } | 36 } |
34 bool operator!=(const OutputFile& other) const { | 37 bool operator!=(const OutputFile& other) const { |
35 return value_ != other.value_; | 38 return value_ != other.value_; |
36 } | 39 } |
37 bool operator<(const OutputFile& other) const { | 40 bool operator<(const OutputFile& other) const { |
38 return value_ < other.value_; | 41 return value_ < other.value_; |
39 } | 42 } |
(...skipping 17 matching lines...) Expand all Loading... |
57 } | 60 } |
58 #endif // COMPILER... | 61 #endif // COMPILER... |
59 | 62 |
60 } // namespace BASE_HASH_NAMESPACE | 63 } // namespace BASE_HASH_NAMESPACE |
61 | 64 |
62 inline void swap(OutputFile& lhs, OutputFile& rhs) { | 65 inline void swap(OutputFile& lhs, OutputFile& rhs) { |
63 lhs.value().swap(rhs.value()); | 66 lhs.value().swap(rhs.value()); |
64 } | 67 } |
65 | 68 |
66 #endif // TOOLS_GN_OUTPUT_FILE_H_ | 69 #endif // TOOLS_GN_OUTPUT_FILE_H_ |
OLD | NEW |