]>
git.saurik.com Git - apt.git/blob - apt-pkg/pkgcachegen.h
1 // -*- mode: cpp; mode: fold -*-
3 // $Id: pkgcachegen.h,v 1.17 1999/07/26 17:46:08 jgg Exp $
4 /* ######################################################################
6 Package Cache Generator - Generator for the cache structure.
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.
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
17 ##################################################################### */
19 // Header section: pkglib
20 #ifndef PKGLIB_PKGCACHEGEN_H
21 #define PKGLIB_PKGCACHEGEN_H
24 #pragma interface "apt-pkg/pkgcachegen.h"
27 #include <apt-pkg/pkgcache.h>
33 class pkgCacheGenerator
37 pkgCache::StringItem
*UniqHash
[26];
51 pkgCache::PackageFile
*CurrentFile
;
53 bool NewPackage(pkgCache::PkgIterator
&Pkg
,string Pkg
);
54 bool NewFileVer(pkgCache::VerIterator
&Ver
,ListParser
&List
);
55 unsigned long NewVersion(pkgCache::VerIterator
&Ver
,string VerStr
,unsigned long Next
);
57 unsigned long WriteUniqString(const char *S
,unsigned int Size
);
58 inline unsigned long WriteUniqString(string S
) {return WriteUniqString(S
.c_str(),S
.length());};
62 void DropProgress() {Progress
= 0;};
63 bool SelectFile(string File
,unsigned long Flags
= 0);
64 bool MergeList(ListParser
&List
,pkgCache::VerIterator
*Ver
= 0);
65 inline pkgCache
&GetCache() {return Cache
;};
66 inline pkgCache::PkgFileIterator
GetCurFile()
67 {return pkgCache::PkgFileIterator(Cache
,CurrentFile
);};
69 pkgCacheGenerator(DynamicMMap
&Map
,OpProgress
&Progress
);
73 bool pkgSrcCacheCheck(pkgSourceList
&List
);
74 bool pkgPkgCacheCheck(string CacheFile
);
75 bool pkgMakeStatusCache(pkgSourceList
&List
,OpProgress
&Progress
);
76 MMap
*pkgMakeStatusCacheMem(pkgSourceList
&List
,OpProgress
&Progress
);
78 // This is the abstract package list parser class.
79 class pkgCacheGenerator::ListParser
81 pkgCacheGenerator
*Owner
;
82 friend pkgCacheGenerator
;
85 pkgCache::VerIterator OldDepVer
;
86 map_ptrloc
*OldDepLast
;
90 inline unsigned long WriteUniqString(string S
) {return Owner
->WriteUniqString(S
);};
91 inline unsigned long WriteUniqString(const char *S
,unsigned int Size
) {return Owner
->WriteUniqString(S
,Size
);};
92 inline unsigned long WriteString(string S
) {return Owner
->Map
.WriteString(S
);};
93 inline unsigned long WriteString(const char *S
,unsigned int Size
) {return Owner
->Map
.WriteString(S
,Size
);};
94 bool NewDepends(pkgCache::VerIterator Ver
,string Package
,
95 string Version
,unsigned int Op
,
97 bool NewProvides(pkgCache::VerIterator Ver
,string Package
,string Version
);
101 // These all operate against the current section
102 virtual string
Package() = 0;
103 virtual string
Version() = 0;
104 virtual bool NewVersion(pkgCache::VerIterator Ver
) = 0;
105 virtual unsigned short VersionHash() = 0;
106 virtual bool UsePackage(pkgCache::PkgIterator Pkg
,
107 pkgCache::VerIterator Ver
) = 0;
108 virtual unsigned long Offset() = 0;
109 virtual unsigned long Size() = 0;
111 virtual bool Step() = 0;
113 virtual ~ListParser() {};
116 bool pkgMergeStatus(OpProgress
&Progress
,pkgCacheGenerator
&Gen
,
117 unsigned long &CurrentSize
,unsigned long TotalSize
);
118 bool pkgAddStatusSize(unsigned long &TotalSize
);