]>
git.saurik.com Git - apt-legacy.git/blob - apt-pkg/pkgcachegen.h
7c523c7f7e49d7c8bc5a0554defac265e972ffc1
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
[24];
36 pkgCache::StringItem
*SpecHash
[2];
41 friend class ListParser
;
43 enum srkLevel
{ srkRunOfTheMillNormal
, srkReasonablySpecial
, srkSeriouslyUnique
};
52 pkgCache::PackageFile
*CurrentFile
;
54 // Flag file dependencies
57 bool NewPackage(pkgCache::PkgIterator
&Pkg
,const string
&PkgName
);
58 bool NewPackage(pkgCache::PkgIterator
&Pkg
,const srkString
&PkgName
);
59 bool NewFileVer(pkgCache::VerIterator
&Ver
,ListParser
&List
);
60 bool NewFileDesc(pkgCache::DescIterator
&Desc
,ListParser
&List
);
61 unsigned long NewVersion(pkgCache::VerIterator
&Ver
,const string
&VerStr
,unsigned long Next
);
62 unsigned long NewVersion(pkgCache::VerIterator
&Ver
,const srkString
&VerStr
,unsigned long Next
);
63 map_ptrloc
NewDescription(pkgCache::DescIterator
&Desc
,const string
&Lang
,const MD5SumValue
&md5sum
,map_ptrloc Next
);
67 unsigned long WriteUniqString(const char *S
,unsigned int Size
);
68 inline unsigned long WriteUniqString(const string
&S
) {return WriteUniqString(S
.c_str(),S
.length());};
69 unsigned long WriteString(const srkString
&S
, enum srkLevel level
);
71 void DropProgress() {Progress
= 0;};
72 bool SelectFile(const string
&File
,const string
&Site
,pkgIndexFile
const &Index
,
73 unsigned long Flags
= 0);
74 bool MergeList(ListParser
&List
,pkgCache::VerIterator
*Ver
= 0);
75 inline pkgCache
&GetCache() {return Cache
;};
76 inline pkgCache::PkgFileIterator
GetCurFile()
77 {return pkgCache::PkgFileIterator(Cache
,CurrentFile
);};
79 bool HasFileDeps() {return FoundFileDeps
;};
80 bool MergeFileProvides(ListParser
&List
);
82 pkgCacheGenerator(DynamicMMap
*Map
,OpProgress
*Progress
);
86 // This is the abstract package list parser class. /*{{{*/
87 class pkgCacheGenerator::ListParser
89 pkgCacheGenerator
*Owner
;
90 friend class pkgCacheGenerator
;
93 pkgCache::VerIterator OldDepVer
;
94 map_ptrloc
*OldDepLast
;
96 // Flag file dependencies
101 inline unsigned long WriteUniqString(string S
) {return Owner
->WriteUniqString(S
);};
102 inline unsigned long WriteUniqString(const char *S
,unsigned int Size
) {return Owner
->WriteUniqString(S
,Size
);};
103 inline unsigned long WriteString(const string
&S
) {return Owner
->Map
.WriteString(S
);};
104 inline unsigned long WriteString(const char *S
,unsigned int Size
) {return Owner
->Map
.WriteString(S
,Size
);};
105 inline unsigned long WriteString(const srkString
&S
) {return Owner
->WriteString(S
, srkReasonablySpecial
);};
106 bool NewDepends(pkgCache::VerIterator Ver
,const string
&Package
,
107 const string
&Version
,unsigned int Op
,
109 bool NewDepends(pkgCache::VerIterator Ver
,const srkString
&Package
,
110 const srkString
&Version
,unsigned int Op
,
112 bool NewProvides(pkgCache::VerIterator Ver
,const string
&Package
,
113 const string
&Version
);
114 bool NewProvides(pkgCache::VerIterator Ver
,const srkString
&Package
,
115 const srkString
&Version
);
116 bool NewTag(pkgCache::PkgIterator Pkg
,const char *NameStart
,unsigned int NameSize
);
120 // These all operate against the current section
121 virtual string
Package() = 0;
122 virtual string
Version() = 0;
123 virtual bool NewVersion(pkgCache::VerIterator Ver
) = 0;
124 virtual string
Description() = 0;
125 virtual string
DescriptionLanguage() = 0;
126 virtual MD5SumValue
Description_md5() = 0;
127 virtual unsigned short VersionHash() = 0;
128 virtual bool UsePackage(pkgCache::PkgIterator Pkg
,
129 pkgCache::VerIterator Ver
) = 0;
130 virtual unsigned long Offset() = 0;
131 virtual unsigned long Size() = 0;
133 virtual bool Step() = 0;
135 inline bool HasFileDeps() {return FoundFileDeps
;};
136 virtual bool CollectFileProvides(pkgCache
&Cache
,
137 pkgCache::VerIterator Ver
) {return true;};
139 ListParser() : FoundFileDeps(false) {};
140 virtual ~ListParser() {};
143 bool pkgMakeStatusCache(pkgSourceList
&List
,OpProgress
&Progress
,
144 MMap
**OutMap
= 0,bool AllowMem
= false);
145 bool pkgMakeOnlyStatusCache(OpProgress
&Progress
,DynamicMMap
**OutMap
);
147 #ifdef APT_COMPATIBILITY
148 #if APT_COMPATIBILITY != 986
149 #warning "Using APT_COMPATIBILITY"
151 MMap
*pkgMakeStatusCacheMem(pkgSourceList
&List
,OpProgress
&Progress
)
154 if (pkgMakeStatusCache(List
,Progress
,&Map
,true) == false)