]>
git.saurik.com Git - apt-legacy.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 #include <apt-pkg/pkgcache.h>
24 #include <apt-pkg/md5.h>
31 class pkgCacheGenerator
/*{{{*/
35 pkgCache::StringItem
*UniqHash
[26];
40 friend class ListParser
;
49 pkgCache::PackageFile
*CurrentFile
;
51 // Flag file dependencies
54 bool NewPackage(pkgCache::PkgIterator
&Pkg
,const string
&PkgName
);
55 bool NewPackage(pkgCache::PkgIterator
&Pkg
,const srkString
&PkgName
);
56 bool NewFileVer(pkgCache::VerIterator
&Ver
,ListParser
&List
);
57 bool NewFileDesc(pkgCache::DescIterator
&Desc
,ListParser
&List
);
58 unsigned long NewVersion(pkgCache::VerIterator
&Ver
,const string
&VerStr
,unsigned long Next
);
59 unsigned long NewVersion(pkgCache::VerIterator
&Ver
,const srkString
&VerStr
,unsigned long Next
);
60 map_ptrloc
NewDescription(pkgCache::DescIterator
&Desc
,const string
&Lang
,const MD5SumValue
&md5sum
,map_ptrloc Next
);
64 unsigned long WriteUniqString(const char *S
,unsigned int Size
);
65 inline unsigned long WriteUniqString(const string
&S
) {return WriteUniqString(S
.c_str(),S
.length());};
67 void DropProgress() {Progress
= 0;};
68 bool SelectFile(const string
&File
,const string
&Site
,pkgIndexFile
const &Index
,
69 unsigned long Flags
= 0);
70 bool MergeList(ListParser
&List
,pkgCache::VerIterator
*Ver
= 0);
71 inline pkgCache
&GetCache() {return Cache
;};
72 inline pkgCache::PkgFileIterator
GetCurFile()
73 {return pkgCache::PkgFileIterator(Cache
,CurrentFile
);};
75 bool HasFileDeps() {return FoundFileDeps
;};
76 bool MergeFileProvides(ListParser
&List
);
78 pkgCacheGenerator(DynamicMMap
*Map
,OpProgress
*Progress
);
82 // This is the abstract package list parser class. /*{{{*/
83 class pkgCacheGenerator::ListParser
85 pkgCacheGenerator
*Owner
;
86 friend class pkgCacheGenerator
;
89 pkgCache::VerIterator OldDepVer
;
90 map_ptrloc
*OldDepLast
;
92 // Flag file dependencies
97 inline unsigned long WriteUniqString(string S
) {return Owner
->WriteUniqString(S
);};
98 inline unsigned long WriteUniqString(const char *S
,unsigned int Size
) {return Owner
->WriteUniqString(S
,Size
);};
99 inline unsigned long WriteString(const string
&S
) {return Owner
->Map
.WriteString(S
);};
100 inline unsigned long WriteString(const char *S
,unsigned int Size
) {return Owner
->Map
.WriteString(S
,Size
);};
101 inline unsigned long WriteString(const srkString
&S
) {return Owner
->Map
.WriteString(S
.Start
,S
.Size
);};
102 bool NewDepends(pkgCache::VerIterator Ver
,const string
&Package
,
103 const string
&Version
,unsigned int Op
,
105 bool NewDepends(pkgCache::VerIterator Ver
,const srkString
&Package
,
106 const srkString
&Version
,unsigned int Op
,
108 bool NewProvides(pkgCache::VerIterator Ver
,const string
&Package
,
109 const string
&Version
);
110 bool NewProvides(pkgCache::VerIterator Ver
,const srkString
&Package
,
111 const srkString
&Version
);
112 bool NewTag(pkgCache::PkgIterator Pkg
,const char *NameStart
,unsigned int NameSize
);
116 // These all operate against the current section
117 virtual string
Package() = 0;
118 virtual string
Version() = 0;
119 virtual bool NewVersion(pkgCache::VerIterator Ver
) = 0;
120 virtual string
Description() = 0;
121 virtual string
DescriptionLanguage() = 0;
122 virtual MD5SumValue
Description_md5() = 0;
123 virtual unsigned short VersionHash() = 0;
124 virtual bool UsePackage(pkgCache::PkgIterator Pkg
,
125 pkgCache::VerIterator Ver
) = 0;
126 virtual unsigned long Offset() = 0;
127 virtual unsigned long Size() = 0;
129 virtual bool Step() = 0;
131 inline bool HasFileDeps() {return FoundFileDeps
;};
132 virtual bool CollectFileProvides(pkgCache
&Cache
,
133 pkgCache::VerIterator Ver
) {return true;};
135 ListParser() : FoundFileDeps(false) {};
136 virtual ~ListParser() {};
139 bool pkgMakeStatusCache(pkgSourceList
&List
,OpProgress
&Progress
,
140 MMap
**OutMap
= 0,bool AllowMem
= false);
141 bool pkgMakeOnlyStatusCache(OpProgress
&Progress
,DynamicMMap
**OutMap
);
143 #ifdef APT_COMPATIBILITY
144 #if APT_COMPATIBILITY != 986
145 #warning "Using APT_COMPATIBILITY"
147 MMap
*pkgMakeStatusCacheMem(pkgSourceList
&List
,OpProgress
&Progress
)
150 if (pkgMakeStatusCache(List
,Progress
,&Map
,true) == false)