]>
git.saurik.com Git - apt.git/blob - apt-pkg/pkgcachegen.h
1 // -*- mode: cpp; mode: fold -*-
3 // $Id: pkgcachegen.h,v 1.19 2002/07/08 03:13:30 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 #ifndef PKGLIB_PKGCACHEGEN_H
20 #define PKGLIB_PKGCACHEGEN_H
23 #pragma interface "apt-pkg/pkgcachegen.h"
26 #include <apt-pkg/pkgcache.h>
33 class pkgCacheGenerator
37 pkgCache::StringItem
*UniqHash
[26];
42 friend class ListParser
;
51 pkgCache::PackageFile
*CurrentFile
;
53 // Flag file dependencies
56 bool NewPackage(pkgCache::PkgIterator
&Pkg
,string Pkg
);
57 bool NewFileVer(pkgCache::VerIterator
&Ver
,ListParser
&List
);
58 unsigned long NewVersion(pkgCache::VerIterator
&Ver
,string VerStr
,unsigned long Next
);
62 unsigned long WriteUniqString(const char *S
,unsigned int Size
);
63 inline unsigned long WriteUniqString(string S
) {return WriteUniqString(S
.c_str(),S
.length());};
65 void DropProgress() {Progress
= 0;};
66 bool SelectFile(string File
,string Site
,pkgIndexFile
const &Index
,
67 unsigned long Flags
= 0);
68 bool MergeList(ListParser
&List
,pkgCache::VerIterator
*Ver
= 0);
69 inline pkgCache
&GetCache() {return Cache
;};
70 inline pkgCache::PkgFileIterator
GetCurFile()
71 {return pkgCache::PkgFileIterator(Cache
,CurrentFile
);};
73 bool HasFileDeps() {return FoundFileDeps
;};
74 bool MergeFileProvides(ListParser
&List
);
76 pkgCacheGenerator(DynamicMMap
*Map
,OpProgress
*Progress
);
80 // This is the abstract package list parser class.
81 class pkgCacheGenerator::ListParser
83 pkgCacheGenerator
*Owner
;
84 friend class pkgCacheGenerator
;
87 pkgCache::VerIterator OldDepVer
;
88 map_ptrloc
*OldDepLast
;
90 // Flag file dependencies
95 inline unsigned long WriteUniqString(string S
) {return Owner
->WriteUniqString(S
);};
96 inline unsigned long WriteUniqString(const char *S
,unsigned int Size
) {return Owner
->WriteUniqString(S
,Size
);};
97 inline unsigned long WriteString(string S
) {return Owner
->Map
.WriteString(S
);};
98 inline unsigned long WriteString(const char *S
,unsigned int Size
) {return Owner
->Map
.WriteString(S
,Size
);};
99 bool NewDepends(pkgCache::VerIterator Ver
,string Package
,
100 string Version
,unsigned int Op
,
102 bool NewProvides(pkgCache::VerIterator Ver
,string Package
,string Version
);
106 // These all operate against the current section
107 virtual string
Package() = 0;
108 virtual string
Version() = 0;
109 virtual bool NewVersion(pkgCache::VerIterator Ver
) = 0;
110 virtual unsigned short VersionHash() = 0;
111 virtual bool UsePackage(pkgCache::PkgIterator Pkg
,
112 pkgCache::VerIterator Ver
) = 0;
113 virtual unsigned long Offset() = 0;
114 virtual unsigned long Size() = 0;
116 virtual bool Step() = 0;
118 inline bool HasFileDeps() {return FoundFileDeps
;};
119 virtual bool CollectFileProvides(pkgCache
&Cache
,
120 pkgCache::VerIterator Ver
) {return true;};
122 ListParser() : FoundFileDeps(false) {};
123 virtual ~ListParser() {};
126 bool pkgMakeStatusCache(pkgSourceList
&List
,OpProgress
&Progress
,
127 MMap
**OutMap
= 0,bool AllowMem
= false);
128 bool pkgMakeOnlyStatusCache(OpProgress
&Progress
,DynamicMMap
**OutMap
);
130 #ifdef APT_COMPATIBILITY
131 #if APT_COMPATIBILITY != 986
132 #warning "Using APT_COMPATIBILITY"
134 MMap
*pkgMakeStatusCacheMem(pkgSourceList
&List
,OpProgress
&Progress
)
137 if (pkgMakeStatusCache(List
,Progress
,&Map
,true) == false)