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.
5 #ifndef TOOLS_GN_OUTPUT_FILE_H_
6 #define TOOLS_GN_OUTPUT_FILE_H_
10 #include "base/containers/hash_tables.h"
11 #include "tools/gn/build_settings.h"
15 // A simple wrapper around a string that indicates the string is a path
16 // relative to the output directory.
20 explicit OutputFile(std::string
&& v
);
21 explicit OutputFile(const std::string
& v
);
22 OutputFile(const BuildSettings
* build_settings
,
23 const SourceFile
& source_file
);
26 std::string
& value() { return value_
; }
27 const std::string
& value() const { return value_
; }
29 // Converts to a SourceFile by prepending the build directory to the file.
30 // The *Dir version requires that the current OutputFile ends in a slash, and
31 // the *File version is the opposite.
32 SourceFile
AsSourceFile(const BuildSettings
* build_settings
) const;
33 SourceDir
AsSourceDir(const BuildSettings
* build_settings
) const;
35 bool operator==(const OutputFile
& other
) const {
36 return value_
== other
.value_
;
38 bool operator!=(const OutputFile
& other
) const {
39 return value_
!= other
.value_
;
41 bool operator<(const OutputFile
& other
) const {
42 return value_
< other
.value_
;
49 namespace BASE_HASH_NAMESPACE
{
51 template<> struct hash
<OutputFile
> {
52 std::size_t operator()(const OutputFile
& v
) const {
58 } // namespace BASE_HASH_NAMESPACE
60 inline void swap(OutputFile
& lhs
, OutputFile
& rhs
) {
61 lhs
.value().swap(rhs
.value());
64 #endif // TOOLS_GN_OUTPUT_FILE_H_