HeaderMap.h revision 98751314c4ba596860b574c3d3551030f01ff7d8
1//===--- HeaderMap.h - A file that acts like dir of symlinks ----*- C++ -*-===//
2//
3//                     The LLVM Compiler Infrastructure
4//
5// This file was developed by Chris Lattner and is distributed under
6// the University of Illinois Open Source License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// This file defines the HeaderMap interface.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef LLVM_CLANG_LEX_HEADERMAP_H
15#define LLVM_CLANG_LEX_HEADERMAP_H
16
17namespace llvm {
18  class MemoryBuffer;
19}
20namespace clang {
21  class FileEntry;
22  class FileManager;
23
24/// This class represents an Apple concept known as a 'header map'.  To the
25/// #include file resolution process, it basically acts like a directory of
26/// symlinks to files.  Its advantages are that it is dense and more efficient
27/// to create and process than a directory of symlinks.
28class HeaderMap {
29  HeaderMap(const HeaderMap&); // DO NOT IMPLEMENT
30  void operator=(const HeaderMap&); // DO NOT IMPLEMENT
31
32  const llvm::MemoryBuffer *FileBuffer;
33  bool NeedsBSwap;
34
35  HeaderMap(const llvm::MemoryBuffer *File, bool BSwap)
36    : FileBuffer(File), NeedsBSwap(BSwap) {
37  }
38public:
39  ~HeaderMap();
40
41  /// HeaderMap::Create - This attempts to load the specified file as a header
42  /// map.  If it doesn't look like a HeaderMap, it gives up and returns null.
43  static const HeaderMap *Create(const FileEntry *FE);
44
45  /// LookupFile - Check to see if the specified relative filename is located in
46  /// this HeaderMap.  If so, open it and return its FileEntry.
47  const FileEntry *LookupFile(const char *FilenameStart,const char *FilenameEnd,
48                              FileManager &FM) const;
49
50  /// getFileName - Return the filename of the headermap.
51  const char *getFileName() const;
52};
53
54} // end namespace clang.
55
56#endif