]> git.saurik.com Git - apt.git/blame - apt-pkg/pkgcachegen.h
* apt-pkg/contrib/cmdline.cc:
[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>
b35d2f5f
AL
25
26class pkgSourceList;
27class OpProgress;
2d11135a 28class MMap;
b2e465d6 29class pkgIndexFile;
578bfd0a 30
92fcbfc1 31class pkgCacheGenerator /*{{{*/
578bfd0a 32{
f9eec0e7
AL
33 private:
34
35 pkgCache::StringItem *UniqHash[26];
36
578bfd0a
AL
37 public:
38
39 class ListParser;
b2e465d6 40 friend class ListParser;
578bfd0a
AL
41
42 protected:
43
44 DynamicMMap &Map;
45 pkgCache Cache;
ddc1d8d0 46 OpProgress *Progress;
404ec98e 47
578bfd0a
AL
48 string PkgFileName;
49 pkgCache::PackageFile *CurrentFile;
45415543
AL
50
51 // Flag file dependencies
52 bool FoundFileDeps;
578bfd0a 53
5bf15716
DK
54 bool NewGroup(pkgCache::GrpIterator &Grp,const string &Name);
55 bool NewPackage(pkgCache::PkgIterator &Pkg,const string &Name, const string &Arch);
f55a958f 56 bool NewFileVer(pkgCache::VerIterator &Ver,ListParser &List);
a52f938b 57 bool NewFileDesc(pkgCache::DescIterator &Desc,ListParser &List);
25396fb0
DK
58 bool NewDepends(pkgCache::PkgIterator &Pkg, pkgCache::VerIterator &Ver,
59 string const &Version, unsigned int const &Op,
60 unsigned int const &Type, map_ptrloc *OldDepLast);
171c75f1 61 unsigned long NewVersion(pkgCache::VerIterator &Ver,const string &VerStr,unsigned long Next);
a52f938b 62 map_ptrloc NewDescription(pkgCache::DescIterator &Desc,const string &Lang,const MD5SumValue &md5sum,map_ptrloc Next);
578bfd0a 63
b2e465d6
AL
64 public:
65
f55a958f 66 unsigned long WriteUniqString(const char *S,unsigned int Size);
171c75f1 67 inline unsigned long WriteUniqString(const string &S) {return WriteUniqString(S.c_str(),S.length());};
813c8eea 68
ddc1d8d0 69 void DropProgress() {Progress = 0;};
171c75f1 70 bool SelectFile(const string &File,const string &Site,pkgIndexFile const &Index,
b2e465d6 71 unsigned long Flags = 0);
ddc1d8d0 72 bool MergeList(ListParser &List,pkgCache::VerIterator *Ver = 0);
ad00ae81 73 inline pkgCache &GetCache() {return Cache;};
b0b4efb9
AL
74 inline pkgCache::PkgFileIterator GetCurFile()
75 {return pkgCache::PkgFileIterator(Cache,CurrentFile);};
45415543
AL
76
77 bool HasFileDeps() {return FoundFileDeps;};
78 bool MergeFileProvides(ListParser &List);
25396fb0
DK
79 bool FinishCache(OpProgress &Progress);
80
b2e465d6 81 pkgCacheGenerator(DynamicMMap *Map,OpProgress *Progress);
578bfd0a
AL
82 ~pkgCacheGenerator();
83};
92fcbfc1
DK
84 /*}}}*/
85// This is the abstract package list parser class. /*{{{*/
f55ece0e
AL
86class pkgCacheGenerator::ListParser
87{
88 pkgCacheGenerator *Owner;
b2e465d6 89 friend class pkgCacheGenerator;
f55ece0e 90
f9eec0e7
AL
91 // Some cache items
92 pkgCache::VerIterator OldDepVer;
349cd3b8 93 map_ptrloc *OldDepLast;
45415543
AL
94
95 // Flag file dependencies
96 bool FoundFileDeps;
f9eec0e7 97
f55ece0e 98 protected:
813c8eea 99
f55ece0e
AL
100 inline unsigned long WriteUniqString(string S) {return Owner->WriteUniqString(S);};
101 inline unsigned long WriteUniqString(const char *S,unsigned int Size) {return Owner->WriteUniqString(S,Size);};
171c75f1 102 inline unsigned long WriteString(const string &S) {return Owner->Map.WriteString(S);};
f55ece0e 103 inline unsigned long WriteString(const char *S,unsigned int Size) {return Owner->Map.WriteString(S,Size);};
5bf15716 104 bool NewDepends(pkgCache::VerIterator Ver,const string &Package, const string &Arch,
171c75f1 105 const string &Version,unsigned int Op,
f55ece0e 106 unsigned int Type);
67e0766f
DK
107 bool NewProvides(pkgCache::VerIterator Ver,const string &PkgName,
108 const string &PkgArch, const string &Version);
f55ece0e
AL
109
110 public:
111
112 // These all operate against the current section
113 virtual string Package() = 0;
5bf15716 114 virtual string Architecture() = 0;
857e9c13 115 virtual bool ArchitectureAll() = 0;
f55ece0e
AL
116 virtual string Version() = 0;
117 virtual bool NewVersion(pkgCache::VerIterator Ver) = 0;
a52f938b
OS
118 virtual string Description() = 0;
119 virtual string DescriptionLanguage() = 0;
120 virtual MD5SumValue Description_md5() = 0;
204fbdcc 121 virtual unsigned short VersionHash() = 0;
f55ece0e
AL
122 virtual bool UsePackage(pkgCache::PkgIterator Pkg,
123 pkgCache::VerIterator Ver) = 0;
124 virtual unsigned long Offset() = 0;
125 virtual unsigned long Size() = 0;
126
127 virtual bool Step() = 0;
128
45415543
AL
129 inline bool HasFileDeps() {return FoundFileDeps;};
130 virtual bool CollectFileProvides(pkgCache &Cache,
131 pkgCache::VerIterator Ver) {return true;};
132
133 ListParser() : FoundFileDeps(false) {};
f55ece0e
AL
134 virtual ~ListParser() {};
135};
92fcbfc1 136 /*}}}*/
b2e465d6
AL
137bool pkgMakeStatusCache(pkgSourceList &List,OpProgress &Progress,
138 MMap **OutMap = 0,bool AllowMem = false);
139bool pkgMakeOnlyStatusCache(OpProgress &Progress,DynamicMMap **OutMap);
140
141#ifdef APT_COMPATIBILITY
142#if APT_COMPATIBILITY != 986
143#warning "Using APT_COMPATIBILITY"
144#endif
145MMap *pkgMakeStatusCacheMem(pkgSourceList &List,OpProgress &Progress)
146{
147 MMap *Map = 0;
148 if (pkgMakeStatusCache(List,Progress,&Map,true) == false)
149 return 0;
150 return Map;
151}
152#endif
ddc1d8d0 153
578bfd0a 154#endif