]>
Commit | Line | Data |
---|---|---|
b2e465d6 AL |
1 | // -*- mode: cpp; mode: fold -*- |
2 | // Description /*{{{*/ | |
7db98ffc | 3 | // $Id: indexfile.h,v 1.6.2.1 2003/12/24 23:09:17 mdz Exp $ |
b2e465d6 AL |
4 | /* ###################################################################### |
5 | ||
6 | Index File - Abstraction for an index of archive/source file. | |
7 | ||
a52f938b | 8 | There are 4 primary sorts of index files, all represented by this |
b2e465d6 AL |
9 | class: |
10 | ||
11 | Binary index files | |
a52f938b | 12 | Binary translation files |
1e3f4083 | 13 | Binary index files describing the local system |
b2e465d6 AL |
14 | Source index files |
15 | ||
16 | They are all bundled together here, and the interfaces for | |
17 | sources.list, acquire, cache gen and record parsing all use this class | |
1e3f4083 | 18 | to access the underlying representation. |
b2e465d6 AL |
19 | |
20 | ##################################################################### */ | |
21 | /*}}}*/ | |
22 | #ifndef PKGLIB_INDEXFILE_H | |
23 | #define PKGLIB_INDEXFILE_H | |
24 | ||
b2e465d6 AL |
25 | #include <apt-pkg/srcrecords.h> |
26 | #include <apt-pkg/pkgrecords.h> | |
453b82a3 DK |
27 | #include <apt-pkg/pkgcache.h> |
28 | #include <apt-pkg/cacheiterators.h> | |
472ff00e | 29 | #include <apt-pkg/macros.h> |
0a843901 | 30 | |
e3c1cfc7 | 31 | #include <map> |
453b82a3 DK |
32 | #include <string> |
33 | ||
a4f6bdc8 DK |
34 | #ifndef APT_8_CLEANER_HEADERS |
35 | using std::string; | |
36 | #endif | |
453b82a3 | 37 | #ifndef APT_10_CLEANER_HEADERS |
b2e465d6 | 38 | class pkgAcquire; |
453b82a3 DK |
39 | #endif |
40 | ||
b2e465d6 AL |
41 | class pkgCacheGenerator; |
42 | class OpProgress; | |
472ff00e | 43 | |
e3c1cfc7 DK |
44 | class IndexTarget /*{{{*/ |
45 | /** \brief Information about an index file. */ | |
46 | { | |
47 | public: | |
48 | /** \brief A URI from which the index file can be downloaded. */ | |
49 | std::string URI; | |
50 | ||
51 | /** \brief A description of the index file. */ | |
52 | std::string Description; | |
53 | ||
54 | /** \brief A shorter description of the index file. */ | |
55 | std::string ShortDesc; | |
56 | ||
57 | /** \brief The key by which this index file should be | |
58 | looked up within the meta index file. */ | |
59 | std::string MetaKey; | |
60 | ||
61 | /** \brief Is it okay if the file isn't found in the meta index */ | |
62 | bool IsOptional; | |
63 | ||
001c76fe DK |
64 | /** \brief options with which this target was created |
65 | Prefer the usage of #Option if at all possible. | |
66 | Beware: Not all of these options are intended for public use */ | |
e3c1cfc7 DK |
67 | std::map<std::string, std::string> Options; |
68 | ||
69 | IndexTarget(std::string const &MetaKey, std::string const &ShortDesc, | |
70 | std::string const &LongDesc, std::string const &URI, bool const IsOptional, | |
71 | std::map<std::string, std::string> const &Options); | |
72 | ||
001c76fe DK |
73 | enum OptionKeys { |
74 | SITE, | |
75 | RELEASE, | |
76 | COMPONENT, | |
77 | LANGUAGE, | |
78 | ARCHITECTURE, | |
79 | BASE_URI, | |
80 | REPO_URI, | |
81 | CREATED_BY, | |
8881b11e DK |
82 | TARGET_OF, |
83 | FILENAME, | |
001c76fe DK |
84 | }; |
85 | std::string Option(OptionKeys const Key) const; | |
8881b11e | 86 | std::string Format(std::string format) const; |
e3c1cfc7 DK |
87 | }; |
88 | /*}}}*/ | |
89 | ||
b2e465d6 AL |
90 | class pkgIndexFile |
91 | { | |
7db98ffc MZ |
92 | protected: |
93 | bool Trusted; | |
e3c1cfc7 | 94 | |
b2e465d6 AL |
95 | public: |
96 | ||
97 | class Type | |
98 | { | |
99 | public: | |
e3c1cfc7 | 100 | |
b2e465d6 AL |
101 | // Global list of Items supported |
102 | static Type **GlobalList; | |
103 | static unsigned long GlobalListLen; | |
a02db58f | 104 | static Type *GetType(const char *Type) APT_PURE; |
b2e465d6 AL |
105 | |
106 | const char *Label; | |
107 | ||
db5c1b54 | 108 | virtual pkgRecords::Parser *CreatePkgParser(pkgCache::PkgFileIterator /*File*/) const {return 0;}; |
a49e7948 | 109 | virtual pkgSrcRecords::Parser *CreateSrcPkgParser(std::string /*File*/) const {return 0;}; |
b2e465d6 | 110 | Type(); |
0432d731 | 111 | virtual ~Type() {}; |
b2e465d6 AL |
112 | }; |
113 | ||
114 | virtual const Type *GetType() const = 0; | |
115 | ||
116 | // Return descriptive strings of various sorts | |
8f3ba4e8 DK |
117 | virtual std::string ArchiveInfo(pkgCache::VerIterator Ver) const; |
118 | virtual std::string SourceInfo(pkgSrcRecords::Parser const &Record, | |
b2e465d6 | 119 | pkgSrcRecords::File const &File) const; |
e3c1cfc7 | 120 | virtual std::string Describe(bool Short = false) const = 0; |
b2e465d6 AL |
121 | |
122 | // Interface for acquire | |
8f3ba4e8 | 123 | virtual std::string ArchiveURI(std::string /*File*/) const {return std::string();}; |
b2e465d6 AL |
124 | |
125 | // Interface for the record parsers | |
126 | virtual pkgSrcRecords::Parser *CreateSrcParser() const {return 0;}; | |
127 | ||
128 | // Interface for the Cache Generator | |
129 | virtual bool Exists() const = 0; | |
130 | virtual bool HasPackages() const = 0; | |
131 | virtual unsigned long Size() const = 0; | |
65512241 | 132 | virtual bool Merge(pkgCacheGenerator &/*Gen*/, OpProgress* /*Prog*/) const { return false; }; |
453b82a3 | 133 | APT_DEPRECATED virtual bool Merge(pkgCacheGenerator &Gen, OpProgress &Prog) const |
2e5f4e45 | 134 | { return Merge(Gen, &Prog); }; |
65512241 | 135 | virtual bool MergeFileProvides(pkgCacheGenerator &/*Gen*/,OpProgress* /*Prog*/) const {return true;}; |
453b82a3 | 136 | APT_DEPRECATED virtual bool MergeFileProvides(pkgCacheGenerator &Gen, OpProgress &Prog) const |
2e5f4e45 | 137 | {return MergeFileProvides(Gen, &Prog);}; |
b2e465d6 | 138 | virtual pkgCache::PkgFileIterator FindInCache(pkgCache &Cache) const; |
7db98ffc | 139 | |
770c32ec | 140 | static bool TranslationsAvailable(); |
a52f938b | 141 | static bool CheckLanguageCode(const char *Lang); |
8f3ba4e8 | 142 | static std::string LanguageCode(); |
a52f938b | 143 | |
7db98ffc | 144 | bool IsTrusted() const { return Trusted; }; |
e3c1cfc7 DK |
145 | |
146 | pkgIndexFile(bool Trusted); | |
b2e465d6 AL |
147 | virtual ~pkgIndexFile() {}; |
148 | }; | |
149 | ||
e3c1cfc7 DK |
150 | class pkgIndexTargetFile : public pkgIndexFile |
151 | { | |
152 | protected: | |
153 | IndexTarget const Target; | |
154 | ||
155 | std::string IndexFileName() const; | |
156 | ||
157 | public: | |
158 | virtual std::string ArchiveURI(std::string File) const; | |
159 | virtual std::string Describe(bool Short = false) const; | |
160 | virtual bool Exists() const; | |
161 | virtual unsigned long Size() const; | |
162 | ||
163 | pkgIndexTargetFile(IndexTarget const &Target, bool const Trusted); | |
164 | }; | |
165 | ||
b2e465d6 | 166 | #endif |