Join with aliencode
[ntk/apt.git] / apt-pkg / pkgcachegen.h
CommitLineData
578bfd0a
AL
1// -*- mode: cpp; mode: fold -*-
2// Description /*{{{*/
b2e465d6 3// $Id: pkgcachegen.h,v 1.18 2001/02/20 07:03:17 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#ifdef __GNUG__
094a497d 23#pragma interface "apt-pkg/pkgcachegen.h"
6c139d6e
AL
24#endif
25
094a497d 26#include <apt-pkg/pkgcache.h>
b35d2f5f
AL
27
28class pkgSourceList;
29class OpProgress;
2d11135a 30class MMap;
b2e465d6 31class pkgIndexFile;
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;
b2e465d6 42 friend class 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
b2e465d6
AL
57 public:
58
f55a958f 59 unsigned long WriteUniqString(const char *S,unsigned int Size);
813c8eea
AL
60 inline unsigned long WriteUniqString(string S) {return WriteUniqString(S.c_str(),S.length());};
61
ddc1d8d0 62 void DropProgress() {Progress = 0;};
b2e465d6
AL
63 bool SelectFile(string File,string Site,pkgIndexFile const &Index,
64 unsigned long Flags = 0);
ddc1d8d0 65 bool MergeList(ListParser &List,pkgCache::VerIterator *Ver = 0);
ad00ae81 66 inline pkgCache &GetCache() {return Cache;};
b0b4efb9
AL
67 inline pkgCache::PkgFileIterator GetCurFile()
68 {return pkgCache::PkgFileIterator(Cache,CurrentFile);};
69
b2e465d6 70 pkgCacheGenerator(DynamicMMap *Map,OpProgress *Progress);
578bfd0a
AL
71 ~pkgCacheGenerator();
72};
73
f55ece0e
AL
74// This is the abstract package list parser class.
75class pkgCacheGenerator::ListParser
76{
77 pkgCacheGenerator *Owner;
b2e465d6 78 friend class pkgCacheGenerator;
f55ece0e 79
f9eec0e7
AL
80 // Some cache items
81 pkgCache::VerIterator OldDepVer;
349cd3b8 82 map_ptrloc *OldDepLast;
f9eec0e7 83
f55ece0e 84 protected:
813c8eea 85
f55ece0e
AL
86 inline unsigned long WriteUniqString(string S) {return Owner->WriteUniqString(S);};
87 inline unsigned long WriteUniqString(const char *S,unsigned int Size) {return Owner->WriteUniqString(S,Size);};
88 inline unsigned long WriteString(string S) {return Owner->Map.WriteString(S);};
89 inline unsigned long WriteString(const char *S,unsigned int Size) {return Owner->Map.WriteString(S,Size);};
90 bool NewDepends(pkgCache::VerIterator Ver,string Package,
91 string Version,unsigned int Op,
92 unsigned int Type);
93 bool NewProvides(pkgCache::VerIterator Ver,string Package,string Version);
94
95 public:
96
97 // These all operate against the current section
98 virtual string Package() = 0;
99 virtual string Version() = 0;
100 virtual bool NewVersion(pkgCache::VerIterator Ver) = 0;
204fbdcc 101 virtual unsigned short VersionHash() = 0;
f55ece0e
AL
102 virtual bool UsePackage(pkgCache::PkgIterator Pkg,
103 pkgCache::VerIterator Ver) = 0;
104 virtual unsigned long Offset() = 0;
105 virtual unsigned long Size() = 0;
106
107 virtual bool Step() = 0;
108
109 virtual ~ListParser() {};
110};
111
b2e465d6
AL
112bool pkgMakeStatusCache(pkgSourceList &List,OpProgress &Progress,
113 MMap **OutMap = 0,bool AllowMem = false);
114bool pkgMakeOnlyStatusCache(OpProgress &Progress,DynamicMMap **OutMap);
115
116#ifdef APT_COMPATIBILITY
117#if APT_COMPATIBILITY != 986
118#warning "Using APT_COMPATIBILITY"
119#endif
120MMap *pkgMakeStatusCacheMem(pkgSourceList &List,OpProgress &Progress)
121{
122 MMap *Map = 0;
123 if (pkgMakeStatusCache(List,Progress,&Map,true) == false)
124 return 0;
125 return Map;
126}
127#endif
ddc1d8d0 128
578bfd0a 129#endif