]> git.saurik.com Git - apt-legacy.git/blame_incremental - apt-pkg/pkgcachegen.h
Fix compilation of http when embedding into Cydia.
[apt-legacy.git] / apt-pkg / pkgcachegen.h
... / ...
CommitLineData
1// -*- mode: cpp; mode: fold -*-
2// Description /*{{{*/
3// $Id: pkgcachegen.h,v 1.19 2002/07/08 03:13:30 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#ifndef PKGLIB_PKGCACHEGEN_H
20#define PKGLIB_PKGCACHEGEN_H
21
22
23#include <apt-pkg/pkgcache.h>
24#include <apt-pkg/md5.h>
25
26class pkgSourceList;
27class OpProgress;
28class MMap;
29class pkgIndexFile;
30
31class pkgCacheGenerator /*{{{*/
32{
33 private:
34
35 pkgCache::StringItem *UniqHash[26];
36
37 public:
38
39 class ListParser;
40 friend class ListParser;
41
42 protected:
43
44 DynamicMMap &Map;
45 pkgCache Cache;
46 OpProgress *Progress;
47
48 string PkgFileName;
49 pkgCache::PackageFile *CurrentFile;
50
51 // Flag file dependencies
52 bool FoundFileDeps;
53
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);
61
62 public:
63
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());};
66
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);};
74
75 bool HasFileDeps() {return FoundFileDeps;};
76 bool MergeFileProvides(ListParser &List);
77
78 pkgCacheGenerator(DynamicMMap *Map,OpProgress *Progress);
79 ~pkgCacheGenerator();
80};
81 /*}}}*/
82// This is the abstract package list parser class. /*{{{*/
83class pkgCacheGenerator::ListParser
84{
85 pkgCacheGenerator *Owner;
86 friend class pkgCacheGenerator;
87
88 // Some cache items
89 pkgCache::VerIterator OldDepVer;
90 map_ptrloc *OldDepLast;
91
92 // Flag file dependencies
93 bool FoundFileDeps;
94
95 protected:
96
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,
104 unsigned int Type);
105 bool NewDepends(pkgCache::VerIterator Ver,const srkString &Package,
106 const srkString &Version,unsigned int Op,
107 unsigned int Type);
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);
113
114 public:
115
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;
128
129 virtual bool Step() = 0;
130
131 inline bool HasFileDeps() {return FoundFileDeps;};
132 virtual bool CollectFileProvides(pkgCache &Cache,
133 pkgCache::VerIterator Ver) {return true;};
134
135 ListParser() : FoundFileDeps(false) {};
136 virtual ~ListParser() {};
137};
138 /*}}}*/
139bool pkgMakeStatusCache(pkgSourceList &List,OpProgress &Progress,
140 MMap **OutMap = 0,bool AllowMem = false);
141bool pkgMakeOnlyStatusCache(OpProgress &Progress,DynamicMMap **OutMap);
142
143#ifdef APT_COMPATIBILITY
144#if APT_COMPATIBILITY != 986
145#warning "Using APT_COMPATIBILITY"
146#endif
147MMap *pkgMakeStatusCacheMem(pkgSourceList &List,OpProgress &Progress)
148{
149 MMap *Map = 0;
150 if (pkgMakeStatusCache(List,Progress,&Map,true) == false)
151 return 0;
152 return Map;
153}
154#endif
155
156#endif