OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef TOOLS_GN_LIB_FILE_H_ |
| 6 #define TOOLS_GN_LIB_FILE_H_ |
| 7 |
| 8 #include <algorithm> |
| 9 #include <string> |
| 10 |
| 11 #include "base/strings/string_piece.h" |
| 12 #include "tools/gn/source_file.h" |
| 13 |
| 14 // Represents an entry in "libs" list. Can be either a path (a SourceFile) or |
| 15 // a library name (a string). |
| 16 class LibFile { |
| 17 public: |
| 18 LibFile(); |
| 19 explicit LibFile(const base::StringPiece& lib_name); |
| 20 explicit LibFile(const SourceFile& source_file); |
| 21 |
| 22 void Swap(LibFile* other); |
| 23 bool is_source_file() const { return name_.empty(); } |
| 24 |
| 25 // Returns name, or source_file().value() (whichever is set). |
| 26 const std::string& value() const; |
| 27 const SourceFile& source_file() const; |
| 28 |
| 29 bool operator==(const LibFile& other) const { |
| 30 return value() == other.value(); |
| 31 } |
| 32 bool operator!=(const LibFile& other) const { return !operator==(other); } |
| 33 bool operator<(const LibFile& other) const { return value() < other.value(); } |
| 34 |
| 35 private: |
| 36 std::string name_; |
| 37 SourceFile source_file_; |
| 38 }; |
| 39 |
| 40 namespace BASE_HASH_NAMESPACE { |
| 41 |
| 42 template <> |
| 43 struct hash<LibFile> { |
| 44 std::size_t operator()(const LibFile& v) const { |
| 45 hash<std::string> h; |
| 46 return h(v.value()); |
| 47 } |
| 48 }; |
| 49 |
| 50 } // namespace BASE_HASH_NAMESPACE |
| 51 |
| 52 inline void swap(LibFile& lhs, LibFile& rhs) { |
| 53 lhs.Swap(&rhs); |
| 54 } |
| 55 |
| 56 #endif // TOOLS_GN_LIB_FILE_H_ |
OLD | NEW |