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 "tools/gn/build_settings.h" | 11 #include "tools/gn/build_settings.h" |
11 #include "tools/gn/source_file.h" | 12 #include "tools/gn/source_file.h" |
12 | 13 |
13 // A simple wrapper around a string that indicates the string is a path | 14 // A simple wrapper around a string that indicates the string is a path |
14 // relative to the output directory. | 15 // relative to the output directory. |
15 class OutputFile { | 16 class OutputFile { |
16 public: | 17 public: |
17 OutputFile() : value_() {} | 18 OutputFile() : value_() {} |
18 explicit OutputFile(const base::StringPiece& str) | 19 explicit OutputFile(const base::StringPiece& str) |
19 : value_(str.data(), str.size()) { | 20 : value_(str.data(), str.size()) { |
(...skipping 14 matching lines...) Expand all Loading... |
34 return value_ != other.value_; | 35 return value_ != other.value_; |
35 } | 36 } |
36 bool operator<(const OutputFile& other) const { | 37 bool operator<(const OutputFile& other) const { |
37 return value_ < other.value_; | 38 return value_ < other.value_; |
38 } | 39 } |
39 | 40 |
40 private: | 41 private: |
41 std::string value_; | 42 std::string value_; |
42 }; | 43 }; |
43 | 44 |
| 45 namespace BASE_HASH_NAMESPACE { |
| 46 |
| 47 #if defined(COMPILER_GCC) |
| 48 template<> struct hash<OutputFile> { |
| 49 std::size_t operator()(const OutputFile& v) const { |
| 50 hash<std::string> h; |
| 51 return h(v.value()); |
| 52 } |
| 53 }; |
| 54 #elif defined(COMPILER_MSVC) |
| 55 inline size_t hash_value(const OutputFile& v) { |
| 56 return hash_value(v.value()); |
| 57 } |
| 58 #endif // COMPILER... |
| 59 |
| 60 } // namespace BASE_HASH_NAMESPACE |
| 61 |
| 62 inline void swap(OutputFile& lhs, OutputFile& rhs) { |
| 63 lhs.value().swap(rhs.value()); |
| 64 } |
| 65 |
44 #endif // TOOLS_GN_OUTPUT_FILE_H_ | 66 #endif // TOOLS_GN_OUTPUT_FILE_H_ |
OLD | NEW |