]>
Commit | Line | Data |
---|---|---|
1 | // -*- mode: cpp; mode: fold -*- | |
2 | // Description /*{{{*/ | |
3 | // $Id: pkgcachegen.h,v 1.11 1998/12/14 02:23:47 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 | ||
32 | class pkgCacheGenerator | |
33 | { | |
34 | public: | |
35 | ||
36 | class ListParser; | |
37 | friend ListParser; | |
38 | ||
39 | protected: | |
40 | ||
41 | DynamicMMap ⤅ | |
42 | pkgCache Cache; | |
43 | OpProgress &Progress; | |
44 | ||
45 | string PkgFileName; | |
46 | pkgCache::PackageFile *CurrentFile; | |
47 | ||
48 | bool NewPackage(pkgCache::PkgIterator &Pkg,string Pkg); | |
49 | bool NewFileVer(pkgCache::VerIterator &Ver,ListParser &List); | |
50 | unsigned long NewVersion(pkgCache::VerIterator &Ver,string VerStr,unsigned long Next); | |
51 | ||
52 | unsigned long WriteUniqString(const char *S,unsigned int Size); | |
53 | inline unsigned long WriteUniqString(string S) {return WriteUniqString(S);}; | |
54 | ||
55 | public: | |
56 | ||
57 | bool SelectFile(string File,unsigned long Flags = 0); | |
58 | bool MergeList(ListParser &List); | |
59 | inline pkgCache &GetCache() {return Cache;}; | |
60 | inline pkgCache::PkgFileIterator GetCurFile() | |
61 | {return pkgCache::PkgFileIterator(Cache,CurrentFile);}; | |
62 | ||
63 | pkgCacheGenerator(DynamicMMap &Map,OpProgress &Progress); | |
64 | ~pkgCacheGenerator(); | |
65 | }; | |
66 | ||
67 | bool pkgSrcCacheCheck(pkgSourceList &List); | |
68 | bool pkgPkgCacheCheck(string CacheFile); | |
69 | bool pkgMakeStatusCache(pkgSourceList &List,OpProgress &Progress); | |
70 | ||
71 | // This is the abstract package list parser class. | |
72 | class pkgCacheGenerator::ListParser | |
73 | { | |
74 | pkgCacheGenerator *Owner; | |
75 | friend pkgCacheGenerator; | |
76 | ||
77 | protected: | |
78 | ||
79 | inline unsigned long WriteUniqString(string S) {return Owner->WriteUniqString(S);}; | |
80 | inline unsigned long WriteUniqString(const char *S,unsigned int Size) {return Owner->WriteUniqString(S,Size);}; | |
81 | inline unsigned long WriteString(string S) {return Owner->Map.WriteString(S);}; | |
82 | inline unsigned long WriteString(const char *S,unsigned int Size) {return Owner->Map.WriteString(S,Size);}; | |
83 | bool NewDepends(pkgCache::VerIterator Ver,string Package, | |
84 | string Version,unsigned int Op, | |
85 | unsigned int Type); | |
86 | bool NewProvides(pkgCache::VerIterator Ver,string Package,string Version); | |
87 | ||
88 | public: | |
89 | ||
90 | // These all operate against the current section | |
91 | virtual string Package() = 0; | |
92 | virtual string Version() = 0; | |
93 | virtual bool NewVersion(pkgCache::VerIterator Ver) = 0; | |
94 | virtual bool UsePackage(pkgCache::PkgIterator Pkg, | |
95 | pkgCache::VerIterator Ver) = 0; | |
96 | virtual unsigned long Offset() = 0; | |
97 | virtual unsigned long Size() = 0; | |
98 | ||
99 | virtual bool Step() = 0; | |
100 | ||
101 | virtual ~ListParser() {}; | |
102 | }; | |
103 | ||
104 | #endif |