1 //===- Archive.h - ar archive file format -----------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file declares the ar archive file format class.
12 //===----------------------------------------------------------------------===//
14 #ifndef LLVM_OBJECT_ARCHIVE_H
15 #define LLVM_OBJECT_ARCHIVE_H
17 #include "llvm/Object/Binary.h"
18 #include "llvm/ADT/StringRef.h"
19 #include "llvm/Support/DataTypes.h"
24 class Archive : public Binary {
27 const Archive *Parent;
31 Child(const Archive *p, StringRef d) : Parent(p), Data(d) {}
33 bool operator ==(const Child &other) const {
34 return (Parent == other.Parent) && (Data.begin() == other.Data.begin());
37 Child getNext() const;
38 error_code getName(StringRef &Result) const;
39 int getLastModified() const;
42 int getAccessMode() const;
43 ///! Return the size of the archive member without the header or padding.
44 uint64_t getSize() const;
46 MemoryBuffer *getBuffer() const;
47 error_code getAsBinary(OwningPtr<Binary> &Result) const;
50 class child_iterator {
53 child_iterator(const Child &c) : child(c) {}
54 const Child* operator->() const {
58 bool operator==(const child_iterator &other) const {
59 return child == other.child;
62 bool operator!=(const child_iterator &other) const {
63 return !(*this == other);
66 child_iterator& operator++() { // Preincrement
67 child = child.getNext();
72 Archive(MemoryBuffer *source, error_code &ec);
74 child_iterator begin_children(bool skip_internal = true) const;
75 child_iterator end_children() const;
78 static inline bool classof(Archive const *v) { return true; }
79 static inline bool classof(Binary const *v) {
80 return v->getType() == Binary::isArchive;
84 child_iterator StringTable;