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

Side by Side Diff: tools/gn/source_file.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/source_dir.h ('k') | tools/gn/target.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_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
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 value_.swap(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 inline void swap(SourceFile& lhs, SourceFile& rhs) {
103 lhs.swap(rhs);
104 }
105
97 #endif // TOOLS_GN_SOURCE_FILE_H_ 106 #endif // TOOLS_GN_SOURCE_FILE_H_
OLDNEW
« no previous file with comments | « tools/gn/source_dir.h ('k') | tools/gn/target.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698