| 1 | // -*- mode: cpp; mode: fold -*- |
| 2 | // Description /*{{{*/ |
| 3 | // $Id: pkgcachegen.h,v 1.15 1999/05/23 22:55:54 jgg Exp $ |
| 4 | /* ###################################################################### |
| 5 | |
| 6 | Package Cache Generator - Generator for the cache structure. |
| 7 | |
| 8 | This builds the cache structure from the abstract package list parser. |
| 9 | Each archive source has it's own list parser that is instantiated by |
| 10 | the caller to provide data for the generator. |
| 11 | |
| 12 | Parts of the cache are created by this generator class while other |
| 13 | parts are created by the list parser. The list parser is responsible |
| 14 | for creating version, depends and provides structures, and some of |
| 15 | their contents |
| 16 | |
| 17 | ##################################################################### */ |
| 18 | /*}}}*/ |
| 19 | // Header section: pkglib |
| 20 | #ifndef PKGLIB_PKGCACHEGEN_H |
| 21 | #define PKGLIB_PKGCACHEGEN_H |
| 22 | |
| 23 | #ifdef __GNUG__ |
| 24 | #pragma interface "apt-pkg/pkgcachegen.h" |
| 25 | #endif |
| 26 | |
| 27 | #include <apt-pkg/pkgcache.h> |
| 28 | |
| 29 | class pkgSourceList; |
| 30 | class OpProgress; |
| 31 | class MMap; |
| 32 | |
| 33 | class pkgCacheGenerator |
| 34 | { |
| 35 | private: |
| 36 | |
| 37 | pkgCache::StringItem *UniqHash[26]; |
| 38 | |
| 39 | public: |
| 40 | |
| 41 | class ListParser; |
| 42 | friend ListParser; |
| 43 | |
| 44 | protected: |
| 45 | |
| 46 | DynamicMMap ⤅ |
| 47 | pkgCache Cache; |
| 48 | OpProgress &Progress; |
| 49 | |
| 50 | string PkgFileName; |
| 51 | pkgCache::PackageFile *CurrentFile; |
| 52 | |
| 53 | bool NewPackage(pkgCache::PkgIterator &Pkg,string Pkg); |
| 54 | bool NewFileVer(pkgCache::VerIterator &Ver,ListParser &List); |
| 55 | unsigned long NewVersion(pkgCache::VerIterator &Ver,string VerStr,unsigned long Next); |
| 56 | |
| 57 | unsigned long WriteUniqString(const char *S,unsigned int Size); |
| 58 | inline unsigned long WriteUniqString(string S) {return WriteUniqString(S.c_str(),S.length());}; |
| 59 | |
| 60 | public: |
| 61 | |
| 62 | bool SelectFile(string File,unsigned long Flags = 0); |
| 63 | bool MergeList(ListParser &List); |
| 64 | inline pkgCache &GetCache() {return Cache;}; |
| 65 | inline pkgCache::PkgFileIterator GetCurFile() |
| 66 | {return pkgCache::PkgFileIterator(Cache,CurrentFile);}; |
| 67 | |
| 68 | pkgCacheGenerator(DynamicMMap &Map,OpProgress &Progress); |
| 69 | ~pkgCacheGenerator(); |
| 70 | }; |
| 71 | |
| 72 | bool pkgSrcCacheCheck(pkgSourceList &List); |
| 73 | bool pkgPkgCacheCheck(string CacheFile); |
| 74 | bool pkgMakeStatusCache(pkgSourceList &List,OpProgress &Progress); |
| 75 | MMap *pkgMakeStatusCacheMem(pkgSourceList &List,OpProgress &Progress); |
| 76 | |
| 77 | // This is the abstract package list parser class. |
| 78 | class pkgCacheGenerator::ListParser |
| 79 | { |
| 80 | pkgCacheGenerator *Owner; |
| 81 | friend pkgCacheGenerator; |
| 82 | |
| 83 | // Some cache items |
| 84 | pkgCache::VerIterator OldDepVer; |
| 85 | __apt_ptrloc *OldDepLast; |
| 86 | |
| 87 | protected: |
| 88 | |
| 89 | inline unsigned long WriteUniqString(string S) {return Owner->WriteUniqString(S);}; |
| 90 | inline unsigned long WriteUniqString(const char *S,unsigned int Size) {return Owner->WriteUniqString(S,Size);}; |
| 91 | inline unsigned long WriteString(string S) {return Owner->Map.WriteString(S);}; |
| 92 | inline unsigned long WriteString(const char *S,unsigned int Size) {return Owner->Map.WriteString(S,Size);}; |
| 93 | bool NewDepends(pkgCache::VerIterator Ver,string Package, |
| 94 | string Version,unsigned int Op, |
| 95 | unsigned int Type); |
| 96 | bool NewProvides(pkgCache::VerIterator Ver,string Package,string Version); |
| 97 | |
| 98 | public: |
| 99 | |
| 100 | // These all operate against the current section |
| 101 | virtual string Package() = 0; |
| 102 | virtual string Version() = 0; |
| 103 | virtual bool NewVersion(pkgCache::VerIterator Ver) = 0; |
| 104 | virtual unsigned short VersionHash() = 0; |
| 105 | virtual bool UsePackage(pkgCache::PkgIterator Pkg, |
| 106 | pkgCache::VerIterator Ver) = 0; |
| 107 | virtual unsigned long Offset() = 0; |
| 108 | virtual unsigned long Size() = 0; |
| 109 | |
| 110 | virtual bool Step() = 0; |
| 111 | |
| 112 | virtual ~ListParser() {}; |
| 113 | }; |
| 114 | |
| 115 | #endif |