Base revisions
[ntk/apt.git] / apt-pkg / pkgcachegen.h
CommitLineData
578bfd0a
AL
1// -*- mode: cpp; mode: fold -*-
2// Description /*{{{*/
3// $Id: pkgcachegen.h,v 1.1 1998/07/02 02:58:13 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
10 ##################################################################### */
11 /*}}}*/
12// Header section: pkglib
13#ifndef PKGLIB_PKGCACHEGEN_H
14#define PKGLIB_PKGCACHEGEN_H
15
16#include <pkglib/pkgcache.h>
17
18class pkgCacheGenerator
19{
20 public:
21
22 class ListParser;
23
24 protected:
25
26 DynamicMMap &Map;
27 pkgCache Cache;
28
29 string PkgFileName;
30 pkgCache::PackageFile *CurrentFile;
31
32 bool NewPackage(pkgCache::PkgIterator Pkg,string Pkg);
33 bool NewFileVer(pkgCache::VerIterator Ver,ListParser &List);
34 unsigned long NewVersion(pkgCache::VerIterator &Ver,unsigned long Next);
35
36 public:
37
38 // This is the abstract package list parser class.
39 class ListParser
40 {
41 pkgCacheGenerator *Owner;
42 friend pkgCacheGenerator;
43
44 protected:
45
46 inline unsigned long WriteString(string S) {return Owner->Map.WriteString(S);};
47 inline unsigned long WriteString(const char *S,unsigned int Size) {return Owner->Map.WriteString(S,Size);};
48
49 public:
50
51 // These all operate against the current section
52 virtual string Package() = 0;
53 virtual string Version() = 0;
54 virtual bool NewVersion(pkgCache::VerIterator Ver) = 0;
55 virtual bool NewPackage(pkgCache::PkgIterator Pkg) = 0;
56 virtual bool UsePackage(pkgCache::PkgIterator Pkg) = 0;
57
58 virtual bool Step() = 0;
59 };
60 friend ListParser;
61
62 bool SelectFile(string File,unsigned long Flags = 0);
63 bool MergeList(ListParser &List);
64
65 pkgCacheGenerator(DynamicMMap &Map);
66 ~pkgCacheGenerator();
67};
68
69#endif