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_LABEL_H_ | 5 #ifndef TOOLS_GN_LABEL_H_ |
6 #define TOOLS_GN_LABEL_H_ | 6 #define TOOLS_GN_LABEL_H_ |
7 | 7 |
8 #include "base/containers/hash_tables.h" | 8 #include "base/containers/hash_tables.h" |
9 #include "build/build_config.h" | 9 #include "build/build_config.h" |
10 #include "tools/gn/source_dir.h" | 10 #include "tools/gn/source_dir.h" |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 // (one for operator==, one for <). | 71 // (one for operator==, one for <). |
72 if (dir_ != other.dir_) | 72 if (dir_ != other.dir_) |
73 return dir_ < other.dir_; | 73 return dir_ < other.dir_; |
74 if (name_ != other.name_) | 74 if (name_ != other.name_) |
75 return name_ < other.name_; | 75 return name_ < other.name_; |
76 if (toolchain_dir_ != other.toolchain_dir_) | 76 if (toolchain_dir_ != other.toolchain_dir_) |
77 return toolchain_dir_ < other.toolchain_dir_; | 77 return toolchain_dir_ < other.toolchain_dir_; |
78 return toolchain_name_ < other.toolchain_name_; | 78 return toolchain_name_ < other.toolchain_name_; |
79 } | 79 } |
80 | 80 |
| 81 void swap(Label& other) { |
| 82 std::swap(dir_, other.dir_); |
| 83 std::swap(name_, other.name_); |
| 84 std::swap(toolchain_dir_, other.toolchain_dir_); |
| 85 std::swap(toolchain_name_, other.toolchain_name_); |
| 86 } |
| 87 |
81 // Returns true if the toolchain dir/name of this object matches some | 88 // Returns true if the toolchain dir/name of this object matches some |
82 // other object. | 89 // other object. |
83 bool ToolchainsEqual(const Label& other) const { | 90 bool ToolchainsEqual(const Label& other) const { |
84 return toolchain_dir_ == other.toolchain_dir_ && | 91 return toolchain_dir_ == other.toolchain_dir_ && |
85 toolchain_name_ == other.toolchain_name_; | 92 toolchain_name_ == other.toolchain_name_; |
86 } | 93 } |
87 | 94 |
88 private: | 95 private: |
89 SourceDir dir_; | 96 SourceDir dir_; |
90 std::string name_; | 97 std::string name_; |
(...skipping 18 matching lines...) Expand all Loading... |
109 inline size_t hash_value(const Label& v) { | 116 inline size_t hash_value(const Label& v) { |
110 return ((hash_value(v.dir().value()) * 131 + | 117 return ((hash_value(v.dir().value()) * 131 + |
111 hash_value(v.name())) * 131 + | 118 hash_value(v.name())) * 131 + |
112 hash_value(v.toolchain_dir().value())) * 131 + | 119 hash_value(v.toolchain_dir().value())) * 131 + |
113 hash_value(v.toolchain_name()); | 120 hash_value(v.toolchain_name()); |
114 } | 121 } |
115 #endif // COMPILER... | 122 #endif // COMPILER... |
116 | 123 |
117 } // namespace BASE_HASH_NAMESPACE | 124 } // namespace BASE_HASH_NAMESPACE |
118 | 125 |
| 126 namespace std { |
| 127 |
| 128 template<> inline void swap(Label& lhs, Label& rhs) { |
| 129 lhs.swap(rhs); |
| 130 } |
| 131 |
| 132 } // namespace std |
| 133 |
119 #endif // TOOLS_GN_LABEL_H_ | 134 #endif // TOOLS_GN_LABEL_H_ |
OLD | NEW |