]> git.saurik.com Git - apt.git/blame - apt-pkg/pkgcachegen.h
stop exporting the accidently exported parsenetrc() symbol
[apt.git] / apt-pkg / pkgcachegen.h
CommitLineData
578bfd0a
AL
1// -*- mode: cpp; mode: fold -*-
2// Description /*{{{*/
45415543 3// $Id: pkgcachegen.h,v 1.19 2002/07/08 03:13:30 jgg Exp $
578bfd0a
AL
4/* ######################################################################
5
6 Package Cache Generator - Generator for the cache structure.
7
8 This builds the cache structure from the abstract package list parser.
6fc33863
AL
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
578bfd0a
AL
16
17 ##################################################################### */
18 /*}}}*/
578bfd0a
AL
19#ifndef PKGLIB_PKGCACHEGEN_H
20#define PKGLIB_PKGCACHEGEN_H
21
6c139d6e 22
094a497d 23#include <apt-pkg/pkgcache.h>
a52f938b 24#include <apt-pkg/md5.h>
5a8e963b 25#include <apt-pkg/macros.h>
b35d2f5f 26
7635093c 27#include <vector>
a9fe5928 28
b35d2f5f
AL
29class pkgSourceList;
30class OpProgress;
2d11135a 31class MMap;
b2e465d6 32class pkgIndexFile;
578bfd0a 33
92fcbfc1 34class pkgCacheGenerator /*{{{*/
578bfd0a 35{
f9eec0e7 36 private:
7e58ab0c 37
f9eec0e7 38 pkgCache::StringItem *UniqHash[26];
a9fe5928
DK
39 map_ptrloc WriteStringInMap(std::string const &String) { return WriteStringInMap(String.c_str()); };
40 map_ptrloc WriteStringInMap(const char *String);
41 map_ptrloc WriteStringInMap(const char *String, const unsigned long &Len);
42 map_ptrloc AllocateInMap(const unsigned long &size);
7e58ab0c 43
578bfd0a
AL
44 public:
45
46 class ListParser;
b2e465d6 47 friend class ListParser;
a9fe5928
DK
48
49 template<typename Iter> class Dynamic {
a9fe5928 50 public:
7635093c
DK
51 static std::vector<Iter*> toReMap;
52 Dynamic(Iter &I) {
53 toReMap.push_back(&I);
a9fe5928
DK
54 }
55
56 ~Dynamic() {
7635093c 57 toReMap.pop_back();
a9fe5928
DK
58 }
59 };
60
578bfd0a 61 protected:
a9fe5928 62
578bfd0a
AL
63 DynamicMMap &Map;
64 pkgCache Cache;
ddc1d8d0 65 OpProgress *Progress;
404ec98e 66
8f3ba4e8 67 std::string PkgFileName;
578bfd0a 68 pkgCache::PackageFile *CurrentFile;
45415543
AL
69
70 // Flag file dependencies
71 bool FoundFileDeps;
578bfd0a 72
8f3ba4e8
DK
73 bool NewGroup(pkgCache::GrpIterator &Grp,const std::string &Name);
74 bool NewPackage(pkgCache::PkgIterator &Pkg,const std::string &Name, const std::string &Arch);
f55a958f 75 bool NewFileVer(pkgCache::VerIterator &Ver,ListParser &List);
a52f938b 76 bool NewFileDesc(pkgCache::DescIterator &Desc,ListParser &List);
25396fb0 77 bool NewDepends(pkgCache::PkgIterator &Pkg, pkgCache::VerIterator &Ver,
8f3ba4e8 78 std::string const &Version, unsigned int const &Op,
64dda04b 79 unsigned int const &Type, map_ptrloc* &OldDepLast);
8f3ba4e8
DK
80 unsigned long NewVersion(pkgCache::VerIterator &Ver,const std::string &VerStr,unsigned long Next);
81 map_ptrloc NewDescription(pkgCache::DescIterator &Desc,const std::string &Lang,const MD5SumValue &md5sum,map_ptrloc Next);
578bfd0a 82
b2e465d6
AL
83 public:
84
f55a958f 85 unsigned long WriteUniqString(const char *S,unsigned int Size);
8f3ba4e8 86 inline unsigned long WriteUniqString(const std::string &S) {return WriteUniqString(S.c_str(),S.length());};
813c8eea 87
ddc1d8d0 88 void DropProgress() {Progress = 0;};
8f3ba4e8 89 bool SelectFile(const std::string &File,const std::string &Site,pkgIndexFile const &Index,
b2e465d6 90 unsigned long Flags = 0);
ddc1d8d0 91 bool MergeList(ListParser &List,pkgCache::VerIterator *Ver = 0);
ad00ae81 92 inline pkgCache &GetCache() {return Cache;};
b0b4efb9
AL
93 inline pkgCache::PkgFileIterator GetCurFile()
94 {return pkgCache::PkgFileIterator(Cache,CurrentFile);};
45415543
AL
95
96 bool HasFileDeps() {return FoundFileDeps;};
97 bool MergeFileProvides(ListParser &List);
5a8e963b 98 __deprecated bool FinishCache(OpProgress *Progress);
2e5f4e45
DK
99
100 static bool MakeStatusCache(pkgSourceList &List,OpProgress *Progress,
101 MMap **OutMap = 0,bool AllowMem = false);
102 static bool MakeOnlyStatusCache(OpProgress *Progress,DynamicMMap **OutMap);
dcdf1ef1 103 static DynamicMMap* CreateDynamicMMap(FileFd *CacheF, unsigned long Flags = 0);
25396fb0 104
a9fe5928
DK
105 void ReMap(void const * const oldMap, void const * const newMap);
106
b2e465d6 107 pkgCacheGenerator(DynamicMMap *Map,OpProgress *Progress);
578bfd0a 108 ~pkgCacheGenerator();
99a2ea5a
DK
109
110 private:
111 bool MergeListGroup(ListParser &List, std::string const &GrpName);
112 bool MergeListPackage(ListParser &List, pkgCache::PkgIterator &Pkg);
113 bool MergeListVersion(ListParser &List, pkgCache::PkgIterator &Pkg,
114 std::string const &Version, pkgCache::VerIterator* &OutVer);
5a8e963b
DK
115
116 bool AddImplicitDepends(pkgCache::GrpIterator &G, pkgCache::PkgIterator &P,
117 pkgCache::VerIterator &V);
118 bool AddImplicitDepends(pkgCache::VerIterator &V, pkgCache::PkgIterator &D);
578bfd0a 119};
92fcbfc1
DK
120 /*}}}*/
121// This is the abstract package list parser class. /*{{{*/
f55ece0e
AL
122class pkgCacheGenerator::ListParser
123{
124 pkgCacheGenerator *Owner;
b2e465d6 125 friend class pkgCacheGenerator;
f55ece0e 126
f9eec0e7
AL
127 // Some cache items
128 pkgCache::VerIterator OldDepVer;
349cd3b8 129 map_ptrloc *OldDepLast;
45415543
AL
130
131 // Flag file dependencies
132 bool FoundFileDeps;
f9eec0e7 133
f55ece0e 134 protected:
813c8eea 135
8f3ba4e8 136 inline unsigned long WriteUniqString(std::string S) {return Owner->WriteUniqString(S);};
f55ece0e 137 inline unsigned long WriteUniqString(const char *S,unsigned int Size) {return Owner->WriteUniqString(S,Size);};
8f3ba4e8 138 inline unsigned long WriteString(const std::string &S) {return Owner->WriteStringInMap(S);};
7e58ab0c 139 inline unsigned long WriteString(const char *S,unsigned int Size) {return Owner->WriteStringInMap(S,Size);};
8f3ba4e8
DK
140 bool NewDepends(pkgCache::VerIterator &Ver,const std::string &Package, const std::string &Arch,
141 const std::string &Version,unsigned int Op,
f55ece0e 142 unsigned int Type);
8f3ba4e8
DK
143 bool NewProvides(pkgCache::VerIterator &Ver,const std::string &PkgName,
144 const std::string &PkgArch, const std::string &Version);
f55ece0e
AL
145
146 public:
147
148 // These all operate against the current section
8f3ba4e8
DK
149 virtual std::string Package() = 0;
150 virtual std::string Architecture() = 0;
857e9c13 151 virtual bool ArchitectureAll() = 0;
8f3ba4e8 152 virtual std::string Version() = 0;
32b9a14c 153 virtual bool NewVersion(pkgCache::VerIterator &Ver) = 0;
8f3ba4e8
DK
154 virtual std::string Description() = 0;
155 virtual std::string DescriptionLanguage() = 0;
a52f938b 156 virtual MD5SumValue Description_md5() = 0;
204fbdcc 157 virtual unsigned short VersionHash() = 0;
32b9a14c
DK
158 virtual bool UsePackage(pkgCache::PkgIterator &Pkg,
159 pkgCache::VerIterator &Ver) = 0;
f55ece0e
AL
160 virtual unsigned long Offset() = 0;
161 virtual unsigned long Size() = 0;
162
163 virtual bool Step() = 0;
164
45415543
AL
165 inline bool HasFileDeps() {return FoundFileDeps;};
166 virtual bool CollectFileProvides(pkgCache &Cache,
32b9a14c 167 pkgCache::VerIterator &Ver) {return true;};
45415543
AL
168
169 ListParser() : FoundFileDeps(false) {};
f55ece0e
AL
170 virtual ~ListParser() {};
171};
92fcbfc1 172 /*}}}*/
2e5f4e45 173
b2e465d6
AL
174bool pkgMakeStatusCache(pkgSourceList &List,OpProgress &Progress,
175 MMap **OutMap = 0,bool AllowMem = false);
176bool pkgMakeOnlyStatusCache(OpProgress &Progress,DynamicMMap **OutMap);
177
578bfd0a 178#endif