| 1 | // -*- mode: cpp; mode: fold -*- |
| 2 | // Description /*{{{*/ |
| 3 | // $Id: pkgcachegen.h,v 1.3 1998/07/05 05:33:57 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 | |
| 10 | ##################################################################### */ |
| 11 | /*}}}*/ |
| 12 | // Header section: pkglib |
| 13 | #ifndef PKGLIB_PKGCACHEGEN_H |
| 14 | #define PKGLIB_PKGCACHEGEN_H |
| 15 | |
| 16 | #include <pkglib/pkgcache.h> |
| 17 | |
| 18 | class pkgCacheGenerator |
| 19 | { |
| 20 | public: |
| 21 | |
| 22 | class ListParser; |
| 23 | |
| 24 | protected: |
| 25 | |
| 26 | DynamicMMap ⤅ |
| 27 | pkgCache Cache; |
| 28 | |
| 29 | string PkgFileName; |
| 30 | pkgCache::PackageFile *CurrentFile; |
| 31 | |
| 32 | bool NewPackage(pkgCache::PkgIterator &Pkg,string Pkg); |
| 33 | bool NewFileVer(pkgCache::VerIterator &Ver,ListParser &List); |
| 34 | unsigned long NewVersion(pkgCache::VerIterator &Ver,string VerStr,unsigned long Next); |
| 35 | |
| 36 | unsigned long WriteUniqString(const char *S,unsigned int Size); |
| 37 | inline unsigned long WriteUniqString(string S) {return WriteUniqString(S);}; |
| 38 | |
| 39 | public: |
| 40 | |
| 41 | // This is the abstract package list parser class. |
| 42 | class ListParser |
| 43 | { |
| 44 | pkgCacheGenerator *Owner; |
| 45 | friend pkgCacheGenerator; |
| 46 | |
| 47 | protected: |
| 48 | |
| 49 | inline unsigned long WriteUniqString(string S) {return Owner->WriteUniqString(S);}; |
| 50 | inline unsigned long WriteUniqString(const char *S,unsigned int Size) {return Owner->WriteUniqString(S,Size);}; |
| 51 | inline unsigned long WriteString(string S) {return Owner->Map.WriteString(S);}; |
| 52 | inline unsigned long WriteString(const char *S,unsigned int Size) {return Owner->Map.WriteString(S,Size);}; |
| 53 | bool NewDepends(pkgCache::VerIterator Ver,string Package, |
| 54 | string Version,unsigned int Op, |
| 55 | unsigned int Type); |
| 56 | bool NewProvides(pkgCache::VerIterator Ver,string Package,string Version); |
| 57 | |
| 58 | public: |
| 59 | |
| 60 | // These all operate against the current section |
| 61 | virtual string Package() = 0; |
| 62 | virtual string Version() = 0; |
| 63 | virtual bool NewVersion(pkgCache::VerIterator Ver) = 0; |
| 64 | virtual bool UsePackage(pkgCache::PkgIterator Pkg, |
| 65 | pkgCache::VerIterator Ver) = 0; |
| 66 | virtual unsigned long Offset() = 0; |
| 67 | virtual unsigned long Size() = 0; |
| 68 | |
| 69 | virtual bool Step() = 0; |
| 70 | |
| 71 | virtual ~ListParser() {}; |
| 72 | }; |
| 73 | friend ListParser; |
| 74 | |
| 75 | bool SelectFile(string File,unsigned long Flags = 0); |
| 76 | bool MergeList(ListParser &List); |
| 77 | |
| 78 | pkgCacheGenerator(DynamicMMap &Map); |
| 79 | ~pkgCacheGenerator(); |
| 80 | }; |
| 81 | |
| 82 | #endif |