Res initialize glitch
[ntk/apt.git] / apt-pkg / pkgcachegen.h
CommitLineData
578bfd0a
AL
1// -*- mode: cpp; mode: fold -*-
2// Description /*{{{*/
dcb79bae 3// $Id: pkgcachegen.h,v 1.3 1998/07/05 05:33:57 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.
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
f55a958f
AL
32 bool NewPackage(pkgCache::PkgIterator &Pkg,string Pkg);
33 bool NewFileVer(pkgCache::VerIterator &Ver,ListParser &List);
34 unsigned long NewVersion(pkgCache::VerIterator &Ver,string VerStr,unsigned long Next);
578bfd0a 35
f55a958f
AL
36 unsigned long WriteUniqString(const char *S,unsigned int Size);
37 inline unsigned long WriteUniqString(string S) {return WriteUniqString(S);};
38
578bfd0a
AL
39 public:
40
41 // This is the abstract package list parser class.
42 class ListParser
43 {
44 pkgCacheGenerator *Owner;
45 friend pkgCacheGenerator;
46
47 protected:
48
f55a958f
AL
49 inline unsigned long WriteUniqString(string S) {return Owner->WriteUniqString(S);};
50 inline unsigned long WriteUniqString(const char *S,unsigned int Size) {return Owner->WriteUniqString(S,Size);};
578bfd0a
AL
51 inline unsigned long WriteString(string S) {return Owner->Map.WriteString(S);};
52 inline unsigned long WriteString(const char *S,unsigned int Size) {return Owner->Map.WriteString(S,Size);};
dcb79bae
AL
53 bool NewDepends(pkgCache::VerIterator Ver,string Package,
54 string Version,unsigned int Op,
55 unsigned int Type);
56 bool NewProvides(pkgCache::VerIterator Ver,string Package,string Version);
f55a958f 57
578bfd0a
AL
58 public:
59
60 // These all operate against the current section
61 virtual string Package() = 0;
62 virtual string Version() = 0;
63 virtual bool NewVersion(pkgCache::VerIterator Ver) = 0;
f55a958f
AL
64 virtual bool UsePackage(pkgCache::PkgIterator Pkg,
65 pkgCache::VerIterator Ver) = 0;
dcb79bae
AL
66 virtual unsigned long Offset() = 0;
67 virtual unsigned long Size() = 0;
68
578bfd0a 69 virtual bool Step() = 0;
dcb79bae 70
f55a958f 71 virtual ~ListParser() {};
578bfd0a
AL
72 };
73 friend ListParser;
74
75 bool SelectFile(string File,unsigned long Flags = 0);
76 bool MergeList(ListParser &List);
77
78 pkgCacheGenerator(DynamicMMap &Map);
79 ~pkgCacheGenerator();
80};
81
82#endif