Binary.h revision fc9ec691da995e7894490a80f5b6b65daf5e34d3
1//===- Binary.h - A generic binary file -------------------------*- C++ -*-===//
2//
3//                     The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// This file declares the Binary class.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef LLVM_OBJECT_BINARY_H
15#define LLVM_OBJECT_BINARY_H
16
17#include "llvm/ADT/OwningPtr.h"
18#include "llvm/Object/Error.h"
19
20namespace llvm {
21
22class MemoryBuffer;
23class StringRef;
24
25namespace object {
26
27class Binary {
28private:
29  Binary(); // = delete
30  Binary(const Binary &other); // = delete
31
32  unsigned int TypeID;
33
34protected:
35  MemoryBuffer *Data;
36
37  Binary(unsigned int Type, MemoryBuffer *Source);
38
39  enum {
40    isArchive,
41    isCOFF,
42    isELF,
43    isMachO,
44    isObject
45  };
46
47public:
48  virtual ~Binary();
49
50  StringRef getData() const;
51  StringRef getFileName() const;
52
53  // Cast methods.
54  unsigned int getType() const { return TypeID; }
55  static inline bool classof(Binary const *v) { return true; }
56};
57
58error_code createBinary(MemoryBuffer *Source, OwningPtr<Binary> &Result);
59error_code createBinary(StringRef Path, OwningPtr<Binary> &Result);
60
61}
62}
63
64#endif
65