Scroll-bar browser test.
[chromium-blink-merge.git] / tools / gn / output_file.h
blobeb6faf064f8c19cf32e1398a0878a34234e91633
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 #if defined(COMPILER_GCC)
51 template<> struct hash<OutputFile> {
52 std::size_t operator()(const OutputFile& v) const {
53 hash<std::string> h;
54 return h(v.value());
57 #elif defined(COMPILER_MSVC)
58 inline size_t hash_value(const OutputFile& v) {
59 return hash_value(v.value());
61 #endif // COMPILER...
63 } // namespace BASE_HASH_NAMESPACE
65 inline void swap(OutputFile& lhs, OutputFile& rhs) {
66 lhs.value().swap(rhs.value());
69 #endif // TOOLS_GN_OUTPUT_FILE_H_