Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(136)

Side by Side Diff: tools/gn/source_dir.h

Issue 26537002: Add a UniqueVector class to GN (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: REview comments, remove npos Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « tools/gn/output_file.h ('k') | tools/gn/source_file.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_DIR_H_ 5 #ifndef TOOLS_GN_SOURCE_DIR_H_
6 #define TOOLS_GN_SOURCE_DIR_H_ 6 #define TOOLS_GN_SOURCE_DIR_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 SourceFile; 16 class SourceFile;
16 17
17 // Represents a directory within the source tree. Source dirs begin and end in 18 // Represents a directory within the source tree. Source dirs begin and end in
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 bool operator==(const SourceDir& other) const { 84 bool operator==(const SourceDir& other) const {
84 return value_ == other.value_; 85 return value_ == other.value_;
85 } 86 }
86 bool operator!=(const SourceDir& other) const { 87 bool operator!=(const SourceDir& other) const {
87 return !operator==(other); 88 return !operator==(other);
88 } 89 }
89 bool operator<(const SourceDir& other) const { 90 bool operator<(const SourceDir& other) const {
90 return value_ < other.value_; 91 return value_ < other.value_;
91 } 92 }
92 93
94 void swap(SourceDir& other) {
95 value_.swap(other.value_);
96 }
97
93 private: 98 private:
94 friend class SourceFile; 99 friend class SourceFile;
95 std::string value_; 100 std::string value_;
96 101
97 // Copy & assign supported. 102 // Copy & assign supported.
98 }; 103 };
99 104
100 namespace BASE_HASH_NAMESPACE { 105 namespace BASE_HASH_NAMESPACE {
101 106
102 #if defined(COMPILER_GCC) 107 #if defined(COMPILER_GCC)
103 template<> struct hash<SourceDir> { 108 template<> struct hash<SourceDir> {
104 std::size_t operator()(const SourceDir& v) const { 109 std::size_t operator()(const SourceDir& v) const {
105 hash<std::string> h; 110 hash<std::string> h;
106 return h(v.value()); 111 return h(v.value());
107 } 112 }
108 }; 113 };
109 #elif defined(COMPILER_MSVC) 114 #elif defined(COMPILER_MSVC)
110 inline size_t hash_value(const SourceDir& v) { 115 inline size_t hash_value(const SourceDir& v) {
111 return hash_value(v.value()); 116 return hash_value(v.value());
112 } 117 }
113 #endif // COMPILER... 118 #endif // COMPILER...
114 119
115 } // namespace BASE_HASH_NAMESPACE 120 } // namespace BASE_HASH_NAMESPACE
116 121
122 inline void swap(SourceDir& lhs, SourceDir& rhs) {
123 lhs.swap(rhs);
124 }
125
117 #endif // TOOLS_GN_SOURCE_DIR_H_ 126 #endif // TOOLS_GN_SOURCE_DIR_H_
OLDNEW
« no previous file with comments | « tools/gn/output_file.h ('k') | tools/gn/source_file.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698