| 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_SOURCE_FILE_H_ | 5 #ifndef TOOLS_GN_SOURCE_FILE_H_ |
| 6 #define TOOLS_GN_SOURCE_FILE_H_ | 6 #define TOOLS_GN_SOURCE_FILE_H_ |
| 7 | 7 |
| 8 #include <algorithm> |
| 8 #include <string> | 9 #include <string> |
| 9 | 10 |
| 10 #include "base/containers/hash_tables.h" | 11 #include "base/containers/hash_tables.h" |
| 11 #include "base/files/file_path.h" | 12 #include "base/files/file_path.h" |
| 12 #include "base/logging.h" | 13 #include "base/logging.h" |
| 13 #include "base/strings/string_piece.h" | 14 #include "base/strings/string_piece.h" |
| 14 | 15 |
| 15 class SourceDir; | 16 class SourceDir; |
| 16 | 17 |
| 17 // Represents a file within the source tree. Always begins in a slash, never | 18 // Represents a file within the source tree. Always begins in a slash, never |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 bool operator==(const SourceFile& other) const { | 63 bool operator==(const SourceFile& other) const { |
| 63 return value_ == other.value_; | 64 return value_ == other.value_; |
| 64 } | 65 } |
| 65 bool operator!=(const SourceFile& other) const { | 66 bool operator!=(const SourceFile& other) const { |
| 66 return !operator==(other); | 67 return !operator==(other); |
| 67 } | 68 } |
| 68 bool operator<(const SourceFile& other) const { | 69 bool operator<(const SourceFile& other) const { |
| 69 return value_ < other.value_; | 70 return value_ < other.value_; |
| 70 } | 71 } |
| 71 | 72 |
| 73 void swap(SourceFile& other) { |
| 74 std::swap(value_, other.value_); |
| 75 } |
| 76 |
| 72 private: | 77 private: |
| 73 friend class SourceDir; | 78 friend class SourceDir; |
| 74 | 79 |
| 75 std::string value_; | 80 std::string value_; |
| 76 | 81 |
| 77 // Copy & assign supported. | 82 // Copy & assign supported. |
| 78 }; | 83 }; |
| 79 | 84 |
| 80 namespace BASE_HASH_NAMESPACE { | 85 namespace BASE_HASH_NAMESPACE { |
| 81 | 86 |
| 82 #if defined(COMPILER_GCC) | 87 #if defined(COMPILER_GCC) |
| 83 template<> struct hash<SourceFile> { | 88 template<> struct hash<SourceFile> { |
| 84 std::size_t operator()(const SourceFile& v) const { | 89 std::size_t operator()(const SourceFile& v) const { |
| 85 hash<std::string> h; | 90 hash<std::string> h; |
| 86 return h(v.value()); | 91 return h(v.value()); |
| 87 } | 92 } |
| 88 }; | 93 }; |
| 89 #elif defined(COMPILER_MSVC) | 94 #elif defined(COMPILER_MSVC) |
| 90 inline size_t hash_value(const SourceFile& v) { | 95 inline size_t hash_value(const SourceFile& v) { |
| 91 return hash_value(v.value()); | 96 return hash_value(v.value()); |
| 92 } | 97 } |
| 93 #endif // COMPILER... | 98 #endif // COMPILER... |
| 94 | 99 |
| 95 } // namespace BASE_HASH_NAMESPACE | 100 } // namespace BASE_HASH_NAMESPACE |
| 96 | 101 |
| 102 namespace std { |
| 103 |
| 104 template<> inline void swap(SourceFile& lhs, SourceFile& rhs) { |
| 105 lhs.swap(rhs); |
| 106 } |
| 107 |
| 108 } // namespace std |
| 109 |
| 97 #endif // TOOLS_GN_SOURCE_FILE_H_ | 110 #endif // TOOLS_GN_SOURCE_FILE_H_ |
| OLD | NEW |