]> git.saurik.com Git - apt.git/blob - apt-pkg/pkgcachegen.h
Working cache generator
[apt.git] / apt-pkg / pkgcachegen.h
1 // -*- mode: cpp; mode: fold -*-
2 // Description /*{{{*/
3 // $Id: pkgcachegen.h,v 1.5 1998/07/12 23:58:35 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 #ifdef __GNUG__
17 #pragma interface "apt-pkg/pkgcachegen.h"
18 #endif
19
20 #include <apt-pkg/pkgcache.h>
21
22 class pkgCacheGenerator
23 {
24 public:
25
26 class ListParser;
27
28 protected:
29
30 DynamicMMap &Map;
31 pkgCache Cache;
32
33 string PkgFileName;
34 pkgCache::PackageFile *CurrentFile;
35
36 bool NewPackage(pkgCache::PkgIterator &Pkg,string Pkg);
37 bool NewFileVer(pkgCache::VerIterator &Ver,ListParser &List);
38 unsigned long NewVersion(pkgCache::VerIterator &Ver,string VerStr,unsigned long Next);
39
40 unsigned long WriteUniqString(const char *S,unsigned int Size);
41 inline unsigned long WriteUniqString(string S) {return WriteUniqString(S);};
42
43 public:
44
45 // This is the abstract package list parser class.
46 class ListParser
47 {
48 pkgCacheGenerator *Owner;
49 friend pkgCacheGenerator;
50
51 protected:
52
53 inline unsigned long WriteUniqString(string S) {return Owner->WriteUniqString(S);};
54 inline unsigned long WriteUniqString(const char *S,unsigned int Size) {return Owner->WriteUniqString(S,Size);};
55 inline unsigned long WriteString(string S) {return Owner->Map.WriteString(S);};
56 inline unsigned long WriteString(const char *S,unsigned int Size) {return Owner->Map.WriteString(S,Size);};
57 bool NewDepends(pkgCache::VerIterator Ver,string Package,
58 string Version,unsigned int Op,
59 unsigned int Type);
60 bool NewProvides(pkgCache::VerIterator Ver,string Package,string Version);
61
62 public:
63
64 // These all operate against the current section
65 virtual string Package() = 0;
66 virtual string Version() = 0;
67 virtual bool NewVersion(pkgCache::VerIterator Ver) = 0;
68 virtual bool UsePackage(pkgCache::PkgIterator Pkg,
69 pkgCache::VerIterator Ver) = 0;
70 virtual unsigned long Offset() = 0;
71 virtual unsigned long Size() = 0;
72
73 virtual bool Step() = 0;
74
75 virtual ~ListParser() {};
76 };
77 friend ListParser;
78
79 bool SelectFile(string File,unsigned long Flags = 0);
80 bool MergeList(ListParser &List);
81
82 pkgCacheGenerator(DynamicMMap &Map);
83 ~pkgCacheGenerator();
84 };
85
86 #endif