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