Roll src/third_party/skia ff271c2:b679ca8
[chromium-blink-merge.git] / tools / gn / output_file.h
blob3e0e99df47fc15049023f7c61287105648082060
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_
8 #include <string>
10 #include "base/containers/hash_tables.h"
11 #include "tools/gn/build_settings.h"
13 class SourceFile;
15 // A simple wrapper around a string that indicates the string is a path
16 // relative to the output directory.
17 class OutputFile {
18 public:
19 OutputFile();
20 explicit OutputFile(const base::StringPiece& str);
21 OutputFile(const BuildSettings* build_settings,
22 const SourceFile& source_file);
23 ~OutputFile();
25 std::string& value() { return value_; }
26 const std::string& value() const { return value_; }
28 // Converts to a SourceFile by prepending the build directory to the file.
29 // The *Dir version requires that the current OutputFile ends in a slash, and
30 // the *File version is the opposite.
31 SourceFile AsSourceFile(const BuildSettings* build_settings) const;
32 SourceDir AsSourceDir(const BuildSettings* build_settings) const;
34 bool operator==(const OutputFile& other) const {
35 return value_ == other.value_;
37 bool operator!=(const OutputFile& other) const {
38 return value_ != other.value_;
40 bool operator<(const OutputFile& other) const {
41 return value_ < other.value_;
44 private:
45 std::string value_;
48 namespace BASE_HASH_NAMESPACE {
50 template<> struct hash<OutputFile> {
51 std::size_t operator()(const OutputFile& v) const {
52 hash<std::string> h;
53 return h(v.value());
57 } // namespace BASE_HASH_NAMESPACE
59 inline void swap(OutputFile& lhs, OutputFile& rhs) {
60 lhs.value().swap(rhs.value());
63 #endif // TOOLS_GN_OUTPUT_FILE_H_