]> git.saurik.com Git - apt.git/blob - apt-pkg/pkgcachegen.h
Checkpoint
[apt.git] / apt-pkg / pkgcachegen.h
1 // -*- mode: cpp; mode: fold -*-
2 // Description /*{{{*/
3 // $Id: pkgcachegen.h,v 1.2 1998/07/04 05:57:38 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
18 class 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,string VerStr,unsigned long Next);
35
36 unsigned long WriteUniqString(const char *S,unsigned int Size);
37 inline unsigned long WriteUniqString(string S) {return WriteUniqString(S);};
38
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
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);};
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);};
53
54 public:
55
56 // These all operate against the current section
57 virtual string Package() = 0;
58 virtual string Version() = 0;
59 virtual bool NewVersion(pkgCache::VerIterator Ver) = 0;
60 virtual bool NewPackage(pkgCache::PkgIterator Pkg) = 0;
61 virtual bool UsePackage(pkgCache::PkgIterator Pkg,
62 pkgCache::VerIterator Ver) = 0;
63
64 virtual bool Step() = 0;
65 virtual ~ListParser() {};
66 };
67 friend ListParser;
68
69 bool SelectFile(string File,unsigned long Flags = 0);
70 bool MergeList(ListParser &List);
71
72 pkgCacheGenerator(DynamicMMap &Map);
73 ~pkgCacheGenerator();
74 };
75
76 #endif