Home | History | Annotate | Download | only in Object
      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 
     20 namespace llvm {
     21 
     22 class MemoryBuffer;
     23 class StringRef;
     24 
     25 namespace object {
     26 
     27 class Binary {
     28 private:
     29   Binary(); // = delete
     30   Binary(const Binary &other); // = delete
     31 
     32   unsigned int TypeID;
     33 
     34 protected:
     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 
     50 public:
     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 
     61 error_code createBinary(MemoryBuffer *Source, OwningPtr<Binary> &Result);
     62 error_code createBinary(StringRef Path, OwningPtr<Binary> &Result);
     63 
     64 }
     65 }
     66 
     67 #endif
     68