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 #include <apt-pkg/macros.h>
00031 
00032 #ifndef APT_8_CLEANER_HEADERS
00033 using std::string;
00034 #endif
00035 
00036 class pkgAcquire;
00037 class pkgCacheGenerator;
00038 class OpProgress;
00039 
00040 class pkgIndexFile
00041 {
00042    protected:
00043    bool Trusted;
00044      
00045    public:
00046 
00047    class Type
00048    {
00049       public:
00050       
00051       // Global list of Items supported
00052       static Type **GlobalList;
00053       static unsigned long GlobalListLen;
00054       static Type *GetType(const char *Type);
00055 
00056       const char *Label;
00057 
00058       virtual pkgRecords::Parser *CreatePkgParser(pkgCache::PkgFileIterator /*File*/) const {return 0;};
00059       Type();
00060       virtual ~Type() {};
00061    };
00062 
00063    virtual const Type *GetType() const = 0;
00064    
00065    // Return descriptive strings of various sorts
00066    virtual std::string ArchiveInfo(pkgCache::VerIterator Ver) const;
00067    virtual std::string SourceInfo(pkgSrcRecords::Parser const &Record,
00068                              pkgSrcRecords::File const &File) const;
00069    virtual std::string Describe(bool Short = false) const = 0;   
00070 
00071    // Interface for acquire
00072    virtual std::string ArchiveURI(std::string /*File*/) const {return std::string();};
00073 
00074    // Interface for the record parsers
00075    virtual pkgSrcRecords::Parser *CreateSrcParser() const {return 0;};
00076    
00077    // Interface for the Cache Generator
00078    virtual bool Exists() const = 0;
00079    virtual bool HasPackages() const = 0;
00080    virtual unsigned long Size() const = 0;
00081    virtual bool Merge(pkgCacheGenerator &/*Gen*/,OpProgress* /*Prog*/) const { return false; };
00082    __deprecated virtual bool Merge(pkgCacheGenerator &Gen, OpProgress &Prog) const
00083       { return Merge(Gen, &Prog); };
00084    virtual bool MergeFileProvides(pkgCacheGenerator &/*Gen*/,OpProgress* /*Prog*/) const {return true;};
00085    __deprecated virtual bool MergeFileProvides(pkgCacheGenerator &Gen, OpProgress &Prog) const
00086       {return MergeFileProvides(Gen, &Prog);};
00087    virtual pkgCache::PkgFileIterator FindInCache(pkgCache &Cache) const;
00088 
00089    static bool TranslationsAvailable();
00090    static bool CheckLanguageCode(const char *Lang);
00091    static std::string LanguageCode();
00092 
00093    bool IsTrusted() const { return Trusted; };
00094    
00095    pkgIndexFile(bool Trusted): Trusted(Trusted) {};
00096    virtual ~pkgIndexFile() {};
00097 };
00098 
00099 #endif