Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 // FilePath is a container for pathnames stored in a platform's native string | 5 // FilePath is a container for pathnames stored in a platform's native string |
| 6 // type, providing containers for manipulation in according with the | 6 // type, providing containers for manipulation in according with the |
| 7 // platform's conventions for pathnames. It supports the following path | 7 // platform's conventions for pathnames. It supports the following path |
| 8 // types: | 8 // types: |
| 9 // | 9 // |
| 10 // POSIX Windows | 10 // POSIX Windows |
| (...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 465 #if defined(OS_POSIX) | 465 #if defined(OS_POSIX) |
| 466 #define FILE_PATH_LITERAL(x) x | 466 #define FILE_PATH_LITERAL(x) x |
| 467 #define PRFilePath "s" | 467 #define PRFilePath "s" |
| 468 #elif defined(OS_WIN) | 468 #elif defined(OS_WIN) |
| 469 #define FILE_PATH_LITERAL(x) L ## x | 469 #define FILE_PATH_LITERAL(x) L ## x |
| 470 #define PRFilePath "ls" | 470 #define PRFilePath "ls" |
| 471 #endif // OS_WIN | 471 #endif // OS_WIN |
| 472 | 472 |
| 473 // Provide a hash function so that hash_sets and maps can contain FilePath | 473 // Provide a hash function so that hash_sets and maps can contain FilePath |
| 474 // objects. | 474 // objects. |
| 475 // | |
| 476 // TODO(brettw) remove this when base::hash_map is removed. | |
|
Łukasz Anforowicz
2017/04/24 18:46:10
I don't understand why we need to wait for removal
brettw
2017/04/25 23:32:36
I missed the forwarding to std::hash. I'll remove.
| |
| 475 namespace BASE_HASH_NAMESPACE { | 477 namespace BASE_HASH_NAMESPACE { |
| 476 | 478 |
| 477 template<> | 479 template<> |
| 478 struct hash<base::FilePath> { | 480 struct hash<base::FilePath> { |
| 479 size_t operator()(const base::FilePath& f) const { | 481 size_t operator()(const base::FilePath& f) const { |
| 480 return hash<base::FilePath::StringType>()(f.value()); | 482 return hash<base::FilePath::StringType>()(f.value()); |
| 481 } | 483 } |
| 482 }; | 484 }; |
| 483 | 485 |
| 484 } // namespace BASE_HASH_NAMESPACE | 486 } // namespace BASE_HASH_NAMESPACE |
| 485 | 487 |
| 488 namespace std { | |
| 489 | |
| 490 template <> | |
| 491 struct hash<base::FilePath> { | |
| 492 typedef base::FilePath argument_type; | |
| 493 typedef std::size_t result_type; | |
| 494 result_type operator()(argument_type const& f) const { | |
| 495 return hash<base::FilePath::StringType>()(f.value()); | |
| 496 } | |
| 497 }; | |
| 498 | |
| 499 } // namespace std | |
| 500 | |
| 486 #endif // BASE_FILES_FILE_PATH_H_ | 501 #endif // BASE_FILES_FILE_PATH_H_ |
| OLD | NEW |