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_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 <string> | 8 #include <string> |
9 | 9 |
10 #include "base/containers/hash_tables.h" | 10 #include "base/containers/hash_tables.h" |
11 #include "base/files/file_path.h" | 11 #include "base/files/file_path.h" |
12 #include "base/logging.h" | 12 #include "base/logging.h" |
13 #include "base/strings/string_piece.h" | 13 #include "base/strings/string_piece.h" |
14 | 14 |
15 class SourceDir; | 15 class SourceDir; |
16 | 16 |
17 // Represents a file within the source tree. Always begins in a slash, never | 17 // Represents a file within the source tree. Always begins in a slash, never |
18 // ends in one. | 18 // ends in one. |
19 class SourceFile { | 19 class SourceFile { |
20 public: | 20 public: |
21 enum SwapIn { SWAP_IN }; | |
22 | |
21 SourceFile(); | 23 SourceFile(); |
22 | 24 |
23 // Takes a known absolute source file. Always begins in a slash. | 25 // Takes a known absolute source file. Always begins in a slash. |
24 explicit SourceFile(const base::StringPiece& p); | 26 explicit SourceFile(const base::StringPiece& p); |
25 | 27 |
28 // Constructs from the given string by swapping in the contents of the given | |
29 // value. The value will be the empty string after this call. | |
30 explicit SourceFile(SwapIn, std::string* value); | |
scottmg
2014/08/05 22:30:32
no explicit necessary
| |
31 | |
26 ~SourceFile(); | 32 ~SourceFile(); |
27 | 33 |
28 bool is_null() const { return value_.empty(); } | 34 bool is_null() const { return value_.empty(); } |
29 const std::string& value() const { return value_; } | 35 const std::string& value() const { return value_; } |
30 | 36 |
31 // Returns everything after the last slash. | 37 // Returns everything after the last slash. |
32 std::string GetName() const; | 38 std::string GetName() const; |
33 SourceDir GetDir() const; | 39 SourceDir GetDir() const; |
34 | 40 |
35 // Resolves this source file relative to some given source root. Returns | 41 // Resolves this source file relative to some given source root. Returns |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
88 }; | 94 }; |
89 #elif defined(COMPILER_MSVC) | 95 #elif defined(COMPILER_MSVC) |
90 inline size_t hash_value(const SourceFile& v) { | 96 inline size_t hash_value(const SourceFile& v) { |
91 return hash_value(v.value()); | 97 return hash_value(v.value()); |
92 } | 98 } |
93 #endif // COMPILER... | 99 #endif // COMPILER... |
94 | 100 |
95 } // namespace BASE_HASH_NAMESPACE | 101 } // namespace BASE_HASH_NAMESPACE |
96 | 102 |
97 #endif // TOOLS_GN_SOURCE_FILE_H_ | 103 #endif // TOOLS_GN_SOURCE_FILE_H_ |
OLD | NEW |