apt @VERSION@

indexfile.h

00001 // -*- mode: cpp; mode: fold -*-
00002 // Description                                                          /*{{{*/
00003 // $Id: indexfile.h,v 1.6.2.1 2003/12/24 23:09:17 mdz Exp $
00004 /* ######################################################################
00005 
00006    Index File - Abstraction for an index of archive/source file.
00007    
00008    There are 4 primary sorts of index files, all represented by this 
00009    class:
00010    
00011    Binary index files 
00012    Binary translation files 
00013    Bianry index files decribing the local system
00014    Source index files
00015    
00016    They are all bundled together here, and the interfaces for 
00017    sources.list, acquire, cache gen and record parsing all use this class
00018    to acess the underlying representation.
00019    
00020    ##################################################################### */
00021                                                                         /*}}}*/
00022 #ifndef PKGLIB_INDEXFILE_H
00023 #define PKGLIB_INDEXFILE_H
00024 
00025 
00026 #include <string>
00027 #include <apt-pkg/pkgcache.h>
00028 #include <apt-pkg/srcrecords.h>
00029 #include <apt-pkg/pkgrecords.h>
00030     
00031 using std::string;
00032 
00033 class pkgAcquire;
00034 class pkgCacheGenerator;
00035 class OpProgress;
00036 class pkgIndexFile
00037 {
00038    protected:
00039    bool Trusted;
00040      
00041    public:
00042 
00043    class Type
00044    {
00045       public:
00046       
00047       // Global list of Items supported
00048       static Type **GlobalList;
00049       static unsigned long GlobalListLen;
00050       static Type *GetType(const char *Type);
00051 
00052       const char *Label;
00053 
00054       virtual pkgRecords::Parser *CreatePkgParser(pkgCache::PkgFileIterator /*File*/) const {return 0;};
00055       Type();
00056       virtual ~Type() {};
00057    };
00058 
00059    virtual const Type *GetType() const = 0;
00060    
00061    // Return descriptive strings of various sorts
00062    virtual string ArchiveInfo(pkgCache::VerIterator Ver) const;
00063    virtual string SourceInfo(pkgSrcRecords::Parser const &Record,
00064                              pkgSrcRecords::File const &File) const;
00065    virtual string Describe(bool Short = false) const = 0;   
00066 
00067    // Interface for acquire
00068    virtual string ArchiveURI(string /*File*/) const {return string();};
00069 
00070    // Interface for the record parsers
00071    virtual pkgSrcRecords::Parser *CreateSrcParser() const {return 0;};
00072    
00073    // Interface for the Cache Generator
00074    virtual bool Exists() const = 0;
00075    virtual bool HasPackages() const = 0;
00076    virtual unsigned long Size() const = 0;
00077    virtual bool Merge(pkgCacheGenerator &/*Gen*/,OpProgress* /*Prog*/) const { return false; };
00078    __deprecated virtual bool Merge(pkgCacheGenerator &Gen, OpProgress &Prog) const
00079       { return Merge(Gen, &Prog); };
00080    virtual bool MergeFileProvides(pkgCacheGenerator &/*Gen*/,OpProgress* /*Prog*/) const {return true;};
00081    __deprecated virtual bool MergeFileProvides(pkgCacheGenerator &Gen, OpProgress &Prog) const
00082       {return MergeFileProvides(Gen, &Prog);};
00083    virtual pkgCache::PkgFileIterator FindInCache(pkgCache &Cache) const;
00084 
00085    static bool TranslationsAvailable();
00086    static bool CheckLanguageCode(const char *Lang);
00087    static string LanguageCode();
00088 
00089    bool IsTrusted() const { return Trusted; };
00090    
00091    pkgIndexFile(bool Trusted): Trusted(Trusted) {};
00092    virtual ~pkgIndexFile() {};
00093 };
00094 
00095 #endif