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 42 // Object and children. 43 isObject, 44 isCOFF, 45 isELF, 46 isMachO, 47 lastObject 48 }; 49 50public: 51 virtual ~Binary(); 52 53 StringRef getData() const; 54 StringRef getFileName() const; 55 56 // Cast methods. 57 unsigned int getType() const { return TypeID; } 58 static inline bool classof(const Binary *v) { return true; } 59}; 60 61error_code createBinary(MemoryBuffer *Source, OwningPtr<Binary> &Result); 62error_code createBinary(StringRef Path, OwningPtr<Binary> &Result); 63 64} 65} 66 67#endif 68