]>
Commit | Line | Data |
---|---|---|
da6ee469 JF |
1 | // -*- mode: cpp; mode: fold -*- |
2 | // Description /*{{{*/ | |
3 | // $Id: pkgcachegen.h,v 1.19 2002/07/08 03:13:30 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 | #ifndef PKGLIB_PKGCACHEGEN_H | |
20 | #define PKGLIB_PKGCACHEGEN_H | |
21 | ||
da6ee469 JF |
22 | |
23 | #include <apt-pkg/pkgcache.h> | |
00ec24d0 | 24 | #include <apt-pkg/md5.h> |
da6ee469 JF |
25 | |
26 | class pkgSourceList; | |
27 | class OpProgress; | |
28 | class MMap; | |
29 | class pkgIndexFile; | |
30 | ||
0e5943eb | 31 | class pkgCacheGenerator /*{{{*/ |
da6ee469 JF |
32 | { |
33 | private: | |
34 | ||
148029df | 35 | pkgCache::StringItem *UniqHash[26]; |
da6ee469 JF |
36 | |
37 | public: | |
38 | ||
39 | class ListParser; | |
40 | friend class ListParser; | |
41 | ||
42 | protected: | |
43 | ||
44 | DynamicMMap ⤅ | |
45 | pkgCache Cache; | |
46 | OpProgress *Progress; | |
47 | ||
48 | string PkgFileName; | |
49 | pkgCache::PackageFile *CurrentFile; | |
50 | ||
51 | // Flag file dependencies | |
52 | bool FoundFileDeps; | |
53 | ||
00ec24d0 | 54 | bool NewPackage(pkgCache::PkgIterator &Pkg,const string &PkgName); |
734f3daf | 55 | bool NewPackage(pkgCache::PkgIterator &Pkg,const srkString &PkgName); |
da6ee469 | 56 | bool NewFileVer(pkgCache::VerIterator &Ver,ListParser &List); |
00ec24d0 | 57 | bool NewFileDesc(pkgCache::DescIterator &Desc,ListParser &List); |
da6ee469 | 58 | unsigned long NewVersion(pkgCache::VerIterator &Ver,const string &VerStr,unsigned long Next); |
734f3daf | 59 | unsigned long NewVersion(pkgCache::VerIterator &Ver,const srkString &VerStr,unsigned long Next); |
00ec24d0 | 60 | map_ptrloc NewDescription(pkgCache::DescIterator &Desc,const string &Lang,const MD5SumValue &md5sum,map_ptrloc Next); |
da6ee469 JF |
61 | |
62 | public: | |
63 | ||
64 | unsigned long WriteUniqString(const char *S,unsigned int Size); | |
65 | inline unsigned long WriteUniqString(const string &S) {return WriteUniqString(S.c_str(),S.length());}; | |
66 | ||
67 | void DropProgress() {Progress = 0;}; | |
68 | bool SelectFile(const string &File,const string &Site,pkgIndexFile const &Index, | |
69 | unsigned long Flags = 0); | |
70 | bool MergeList(ListParser &List,pkgCache::VerIterator *Ver = 0); | |
71 | inline pkgCache &GetCache() {return Cache;}; | |
72 | inline pkgCache::PkgFileIterator GetCurFile() | |
73 | {return pkgCache::PkgFileIterator(Cache,CurrentFile);}; | |
74 | ||
75 | bool HasFileDeps() {return FoundFileDeps;}; | |
76 | bool MergeFileProvides(ListParser &List); | |
77 | ||
78 | pkgCacheGenerator(DynamicMMap *Map,OpProgress *Progress); | |
79 | ~pkgCacheGenerator(); | |
80 | }; | |
0e5943eb JF |
81 | /*}}}*/ |
82 | // This is the abstract package list parser class. /*{{{*/ | |
da6ee469 JF |
83 | class pkgCacheGenerator::ListParser |
84 | { | |
85 | pkgCacheGenerator *Owner; | |
86 | friend class pkgCacheGenerator; | |
87 | ||
88 | // Some cache items | |
89 | pkgCache::VerIterator OldDepVer; | |
90 | map_ptrloc *OldDepLast; | |
91 | ||
92 | // Flag file dependencies | |
93 | bool FoundFileDeps; | |
94 | ||
95 | protected: | |
96 | ||
97 | inline unsigned long WriteUniqString(string S) {return Owner->WriteUniqString(S);}; | |
98 | inline unsigned long WriteUniqString(const char *S,unsigned int Size) {return Owner->WriteUniqString(S,Size);}; | |
99 | inline unsigned long WriteString(const string &S) {return Owner->Map.WriteString(S);}; | |
100 | inline unsigned long WriteString(const char *S,unsigned int Size) {return Owner->Map.WriteString(S,Size);}; | |
148029df | 101 | inline unsigned long WriteString(const srkString &S) {return Owner->Map.WriteString(S.Start,S.Size);}; |
da6ee469 JF |
102 | bool NewDepends(pkgCache::VerIterator Ver,const string &Package, |
103 | const string &Version,unsigned int Op, | |
104 | unsigned int Type); | |
734f3daf JF |
105 | bool NewDepends(pkgCache::VerIterator Ver,const srkString &Package, |
106 | const srkString &Version,unsigned int Op, | |
107 | unsigned int Type); | |
da6ee469 JF |
108 | bool NewProvides(pkgCache::VerIterator Ver,const string &Package, |
109 | const string &Version); | |
734f3daf JF |
110 | bool NewProvides(pkgCache::VerIterator Ver,const srkString &Package, |
111 | const srkString &Version); | |
acdafb44 | 112 | bool NewTag(pkgCache::PkgIterator Pkg,const char *NameStart,unsigned int NameSize); |
da6ee469 JF |
113 | |
114 | public: | |
115 | ||
116 | // These all operate against the current section | |
117 | virtual string Package() = 0; | |
118 | virtual string Version() = 0; | |
119 | virtual bool NewVersion(pkgCache::VerIterator Ver) = 0; | |
00ec24d0 JF |
120 | virtual string Description() = 0; |
121 | virtual string DescriptionLanguage() = 0; | |
122 | virtual MD5SumValue Description_md5() = 0; | |
da6ee469 JF |
123 | virtual unsigned short VersionHash() = 0; |
124 | virtual bool UsePackage(pkgCache::PkgIterator Pkg, | |
125 | pkgCache::VerIterator Ver) = 0; | |
126 | virtual unsigned long Offset() = 0; | |
127 | virtual unsigned long Size() = 0; | |
128 | ||
129 | virtual bool Step() = 0; | |
130 | ||
131 | inline bool HasFileDeps() {return FoundFileDeps;}; | |
132 | virtual bool CollectFileProvides(pkgCache &Cache, | |
133 | pkgCache::VerIterator Ver) {return true;}; | |
134 | ||
135 | ListParser() : FoundFileDeps(false) {}; | |
136 | virtual ~ListParser() {}; | |
137 | }; | |
0e5943eb | 138 | /*}}}*/ |
da6ee469 JF |
139 | bool pkgMakeStatusCache(pkgSourceList &List,OpProgress &Progress, |
140 | MMap **OutMap = 0,bool AllowMem = false); | |
141 | bool pkgMakeOnlyStatusCache(OpProgress &Progress,DynamicMMap **OutMap); | |
142 | ||
143 | #ifdef APT_COMPATIBILITY | |
144 | #if APT_COMPATIBILITY != 986 | |
145 | #warning "Using APT_COMPATIBILITY" | |
146 | #endif | |
147 | MMap *pkgMakeStatusCacheMem(pkgSourceList &List,OpProgress &Progress) | |
148 | { | |
149 | MMap *Map = 0; | |
150 | if (pkgMakeStatusCache(List,Progress,&Map,true) == false) | |
151 | return 0; | |
152 | return Map; | |
153 | } | |
154 | #endif | |
155 | ||
156 | #endif |