]>
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 | ||
31 | class pkgCacheGenerator | |
32 | { | |
33 | private: | |
34 | ||
05d8d514 | 35 | pkgCache::StringItem *UniqHash[32768*2]; |
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); |
da6ee469 | 55 | bool NewFileVer(pkgCache::VerIterator &Ver,ListParser &List); |
00ec24d0 | 56 | bool NewFileDesc(pkgCache::DescIterator &Desc,ListParser &List); |
da6ee469 | 57 | unsigned long NewVersion(pkgCache::VerIterator &Ver,const string &VerStr,unsigned long Next); |
00ec24d0 | 58 | map_ptrloc NewDescription(pkgCache::DescIterator &Desc,const string &Lang,const MD5SumValue &md5sum,map_ptrloc Next); |
da6ee469 JF |
59 | |
60 | public: | |
61 | ||
62 | unsigned long WriteUniqString(const char *S,unsigned int Size); | |
63 | inline unsigned long WriteUniqString(const string &S) {return WriteUniqString(S.c_str(),S.length());}; | |
64 | ||
65 | void DropProgress() {Progress = 0;}; | |
66 | bool SelectFile(const string &File,const string &Site,pkgIndexFile const &Index, | |
67 | unsigned long Flags = 0); | |
68 | bool MergeList(ListParser &List,pkgCache::VerIterator *Ver = 0); | |
69 | inline pkgCache &GetCache() {return Cache;}; | |
70 | inline pkgCache::PkgFileIterator GetCurFile() | |
71 | {return pkgCache::PkgFileIterator(Cache,CurrentFile);}; | |
72 | ||
73 | bool HasFileDeps() {return FoundFileDeps;}; | |
74 | bool MergeFileProvides(ListParser &List); | |
75 | ||
76 | pkgCacheGenerator(DynamicMMap *Map,OpProgress *Progress); | |
77 | ~pkgCacheGenerator(); | |
78 | }; | |
79 | ||
80 | // This is the abstract package list parser class. | |
81 | class pkgCacheGenerator::ListParser | |
82 | { | |
83 | pkgCacheGenerator *Owner; | |
84 | friend class pkgCacheGenerator; | |
85 | ||
86 | // Some cache items | |
87 | pkgCache::VerIterator OldDepVer; | |
88 | map_ptrloc *OldDepLast; | |
89 | ||
90 | // Flag file dependencies | |
91 | bool FoundFileDeps; | |
92 | ||
93 | protected: | |
94 | ||
95 | inline unsigned long WriteUniqString(string S) {return Owner->WriteUniqString(S);}; | |
96 | inline unsigned long WriteUniqString(const char *S,unsigned int Size) {return Owner->WriteUniqString(S,Size);}; | |
97 | inline unsigned long WriteString(const string &S) {return Owner->Map.WriteString(S);}; | |
98 | inline unsigned long WriteString(const char *S,unsigned int Size) {return Owner->Map.WriteString(S,Size);}; | |
99 | bool NewDepends(pkgCache::VerIterator Ver,const string &Package, | |
100 | const string &Version,unsigned int Op, | |
101 | unsigned int Type); | |
102 | bool NewProvides(pkgCache::VerIterator Ver,const string &Package, | |
103 | const string &Version); | |
acdafb44 | 104 | bool NewTag(pkgCache::PkgIterator Pkg,const char *NameStart,unsigned int NameSize); |
da6ee469 JF |
105 | |
106 | public: | |
107 | ||
108 | // These all operate against the current section | |
109 | virtual string Package() = 0; | |
110 | virtual string Version() = 0; | |
111 | virtual bool NewVersion(pkgCache::VerIterator Ver) = 0; | |
00ec24d0 JF |
112 | virtual string Description() = 0; |
113 | virtual string DescriptionLanguage() = 0; | |
114 | virtual MD5SumValue Description_md5() = 0; | |
da6ee469 JF |
115 | virtual unsigned short VersionHash() = 0; |
116 | virtual bool UsePackage(pkgCache::PkgIterator Pkg, | |
117 | pkgCache::VerIterator Ver) = 0; | |
118 | virtual unsigned long Offset() = 0; | |
119 | virtual unsigned long Size() = 0; | |
120 | ||
121 | virtual bool Step() = 0; | |
122 | ||
123 | inline bool HasFileDeps() {return FoundFileDeps;}; | |
124 | virtual bool CollectFileProvides(pkgCache &Cache, | |
125 | pkgCache::VerIterator Ver) {return true;}; | |
126 | ||
127 | ListParser() : FoundFileDeps(false) {}; | |
128 | virtual ~ListParser() {}; | |
129 | }; | |
130 | ||
131 | bool pkgMakeStatusCache(pkgSourceList &List,OpProgress &Progress, | |
132 | MMap **OutMap = 0,bool AllowMem = false); | |
133 | bool pkgMakeOnlyStatusCache(OpProgress &Progress,DynamicMMap **OutMap); | |
134 | ||
135 | #ifdef APT_COMPATIBILITY | |
136 | #if APT_COMPATIBILITY != 986 | |
137 | #warning "Using APT_COMPATIBILITY" | |
138 | #endif | |
139 | MMap *pkgMakeStatusCacheMem(pkgSourceList &List,OpProgress &Progress) | |
140 | { | |
141 | MMap *Map = 0; | |
142 | if (pkgMakeStatusCache(List,Progress,&Map,true) == false) | |
143 | return 0; | |
144 | return Map; | |
145 | } | |
146 | #endif | |
147 | ||
148 | #endif |