]> git.saurik.com Git - apt.git/blame - apt-pkg/pkgcachegen.h
More MD5
[apt.git] / apt-pkg / pkgcachegen.h
CommitLineData
578bfd0a
AL
1// -*- mode: cpp; mode: fold -*-
2// Description /*{{{*/
ddc1d8d0 3// $Id: pkgcachegen.h,v 1.17 1999/07/26 17:46:08 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 /*}}}*/
19// Header section: pkglib
20#ifndef PKGLIB_PKGCACHEGEN_H
21#define PKGLIB_PKGCACHEGEN_H
22
6c139d6e 23#ifdef __GNUG__
094a497d 24#pragma interface "apt-pkg/pkgcachegen.h"
6c139d6e
AL
25#endif
26
094a497d 27#include <apt-pkg/pkgcache.h>
b35d2f5f
AL
28
29class pkgSourceList;
30class OpProgress;
2d11135a 31class MMap;
578bfd0a
AL
32
33class pkgCacheGenerator
34{
f9eec0e7
AL
35 private:
36
37 pkgCache::StringItem *UniqHash[26];
38
578bfd0a
AL
39 public:
40
41 class ListParser;
f55ece0e 42 friend ListParser;
578bfd0a
AL
43
44 protected:
45
46 DynamicMMap &Map;
47 pkgCache Cache;
ddc1d8d0 48 OpProgress *Progress;
404ec98e 49
578bfd0a
AL
50 string PkgFileName;
51 pkgCache::PackageFile *CurrentFile;
52
f55a958f
AL
53 bool NewPackage(pkgCache::PkgIterator &Pkg,string Pkg);
54 bool NewFileVer(pkgCache::VerIterator &Ver,ListParser &List);
55 unsigned long NewVersion(pkgCache::VerIterator &Ver,string VerStr,unsigned long Next);
578bfd0a 56
f55a958f 57 unsigned long WriteUniqString(const char *S,unsigned int Size);
813c8eea
AL
58 inline unsigned long WriteUniqString(string S) {return WriteUniqString(S.c_str(),S.length());};
59
f55ece0e 60 public:
578bfd0a 61
ddc1d8d0 62 void DropProgress() {Progress = 0;};
578bfd0a 63 bool SelectFile(string File,unsigned long Flags = 0);
ddc1d8d0 64 bool MergeList(ListParser &List,pkgCache::VerIterator *Ver = 0);
ad00ae81 65 inline pkgCache &GetCache() {return Cache;};
b0b4efb9
AL
66 inline pkgCache::PkgFileIterator GetCurFile()
67 {return pkgCache::PkgFileIterator(Cache,CurrentFile);};
68
404ec98e 69 pkgCacheGenerator(DynamicMMap &Map,OpProgress &Progress);
578bfd0a
AL
70 ~pkgCacheGenerator();
71};
72
b35d2f5f
AL
73bool pkgSrcCacheCheck(pkgSourceList &List);
74bool pkgPkgCacheCheck(string CacheFile);
75bool pkgMakeStatusCache(pkgSourceList &List,OpProgress &Progress);
2d11135a 76MMap *pkgMakeStatusCacheMem(pkgSourceList &List,OpProgress &Progress);
b35d2f5f 77
f55ece0e
AL
78// This is the abstract package list parser class.
79class pkgCacheGenerator::ListParser
80{
81 pkgCacheGenerator *Owner;
82 friend pkgCacheGenerator;
83
f9eec0e7
AL
84 // Some cache items
85 pkgCache::VerIterator OldDepVer;
349cd3b8 86 map_ptrloc *OldDepLast;
f9eec0e7 87
f55ece0e 88 protected:
813c8eea 89
f55ece0e
AL
90 inline unsigned long WriteUniqString(string S) {return Owner->WriteUniqString(S);};
91 inline unsigned long WriteUniqString(const char *S,unsigned int Size) {return Owner->WriteUniqString(S,Size);};
92 inline unsigned long WriteString(string S) {return Owner->Map.WriteString(S);};
93 inline unsigned long WriteString(const char *S,unsigned int Size) {return Owner->Map.WriteString(S,Size);};
94 bool NewDepends(pkgCache::VerIterator Ver,string Package,
95 string Version,unsigned int Op,
96 unsigned int Type);
97 bool NewProvides(pkgCache::VerIterator Ver,string Package,string Version);
98
99 public:
100
101 // These all operate against the current section
102 virtual string Package() = 0;
103 virtual string Version() = 0;
104 virtual bool NewVersion(pkgCache::VerIterator Ver) = 0;
204fbdcc 105 virtual unsigned short VersionHash() = 0;
f55ece0e
AL
106 virtual bool UsePackage(pkgCache::PkgIterator Pkg,
107 pkgCache::VerIterator Ver) = 0;
108 virtual unsigned long Offset() = 0;
109 virtual unsigned long Size() = 0;
110
111 virtual bool Step() = 0;
112
113 virtual ~ListParser() {};
114};
115
ddc1d8d0
AL
116bool pkgMergeStatus(OpProgress &Progress,pkgCacheGenerator &Gen,
117 unsigned long &CurrentSize,unsigned long TotalSize);
118bool pkgAddStatusSize(unsigned long &TotalSize);
119
578bfd0a 120#endif