]>
git.saurik.com Git - apt.git/blob - apt-pkg/indexfile.h
1 // -*- mode: cpp; mode: fold -*-
3 /* ######################################################################
5 Index File - Abstraction for an index of archive/source file.
7 There are 4 primary sorts of index files, all represented by this
11 Binary translation files
12 Binary index files describing the local system
15 They are all bundled together here, and the interfaces for
16 sources.list, acquire, cache gen and record parsing all use this class
17 to access the underlying representation.
19 ##################################################################### */
21 #ifndef PKGLIB_INDEXFILE_H
22 #define PKGLIB_INDEXFILE_H
24 #include <apt-pkg/srcrecords.h>
25 #include <apt-pkg/pkgrecords.h>
26 #include <apt-pkg/pkgcache.h>
27 #include <apt-pkg/cacheiterators.h>
28 #include <apt-pkg/macros.h>
33 #ifndef APT_8_CLEANER_HEADERS
36 #ifndef APT_10_CLEANER_HEADERS
40 class pkgCacheGenerator
;
41 class pkgCacheListParser
;
44 class IndexTarget
/*{{{*/
45 /** \brief Information about an index file. */
48 /** \brief A URI from which the index file can be downloaded. */
51 /** \brief A description of the index file. */
52 std::string Description
;
54 /** \brief A shorter description of the index file. */
55 std::string ShortDesc
;
57 /** \brief The key by which this index file should be
58 looked up within the meta index file. */
61 /** \brief Is it okay if the file isn't found in the meta index */
64 /** \brief If the file is downloaded compressed, do not unpack it */
67 /** \brief options with which this target was created
68 Prefer the usage of #Option if at all possible.
69 Beware: Not all of these options are intended for public use */
70 std::map
<std::string
, std::string
> Options
;
72 IndexTarget(std::string
const &MetaKey
, std::string
const &ShortDesc
,
73 std::string
const &LongDesc
, std::string
const &URI
, bool const IsOptional
,
74 bool const KeepCompressed
, std::map
<std::string
, std::string
> const &Options
);
94 std::string
Option(OptionKeys
const Key
) const;
95 bool OptionBool(OptionKeys
const Key
) const;
96 std::string
Format(std::string format
) const;
112 // Global list of Items supported
113 static Type
**GlobalList
;
114 static unsigned long GlobalListLen
;
115 static Type
*GetType(const char * const Type
) APT_PURE
;
119 virtual pkgRecords::Parser
*CreatePkgParser(pkgCache::PkgFileIterator
const &/*File*/) const {return 0;};
120 virtual pkgSrcRecords::Parser
*CreateSrcPkgParser(std::string
const &/*File*/) const {return 0;};
125 virtual const Type
*GetType() const = 0;
127 // Return descriptive strings of various sorts
128 virtual std::string
ArchiveInfo(pkgCache::VerIterator
const &Ver
) const;
129 virtual std::string
SourceInfo(pkgSrcRecords::Parser
const &Record
,
130 pkgSrcRecords::File
const &File
) const;
131 virtual std::string
Describe(bool const Short
= false) const = 0;
133 // Interface for acquire
134 virtual std::string
ArchiveURI(std::string
const &/*File*/) const {return std::string();};
136 // Interface for the record parsers
137 virtual pkgSrcRecords::Parser
*CreateSrcParser() const {return 0;};
139 // Interface for the Cache Generator
140 virtual bool Exists() const = 0;
141 virtual bool HasPackages() const = 0;
142 virtual unsigned long Size() const = 0;
143 virtual bool Merge(pkgCacheGenerator
&/*Gen*/, OpProgress
* const /*Prog*/) { return true; };
144 virtual pkgCache::PkgFileIterator
FindInCache(pkgCache
&Cache
) const;
146 APT_DEPRECATED_MSG("These methods make no sense anymore with multi-language support") static bool TranslationsAvailable();
147 /* No intern need for this method anymore as the check for correctness
148 is already done in getLanguages(). Note also that this check is
149 rather bad (doesn't take three character like ast into account).*/
150 APT_DEPRECATED_MSG("These methods make no sense anymore with multi-language support") static bool CheckLanguageCode(const char * const Lang
);
151 /* As we have now possibly more than one LanguageCode this method is
152 superseeded by a) private classmembers or b) getLanguages() */
153 APT_DEPRECATED_MSG("These methods make no sense anymore with multi-language support") static std::string
LanguageCode();
155 bool IsTrusted() const { return Trusted
; };
157 explicit pkgIndexFile(bool const Trusted
);
158 virtual ~pkgIndexFile();
161 class pkgDebianIndexFile
: public pkgIndexFile
164 virtual std::string
IndexFileName() const = 0;
165 virtual std::string
GetComponent() const = 0;
166 virtual std::string
GetArchitecture() const = 0;
167 virtual std::string
GetProgressDescription() const = 0;
168 virtual uint8_t GetIndexFlags() const = 0;
169 virtual bool OpenListFile(FileFd
&Pkg
, std::string
const &FileName
) = 0;
170 APT_HIDDEN
virtual pkgCacheListParser
* CreateListParser(FileFd
&Pkg
);
173 virtual bool Merge(pkgCacheGenerator
&Gen
, OpProgress
* const Prog
) APT_OVERRIDE
;
174 virtual pkgCache::PkgFileIterator
FindInCache(pkgCache
&Cache
) const APT_OVERRIDE
;
176 explicit pkgDebianIndexFile(bool const Trusted
);
177 virtual ~pkgDebianIndexFile();
180 class pkgDebianIndexTargetFile
: public pkgDebianIndexFile
184 IndexTarget
const Target
;
186 virtual std::string
IndexFileName() const APT_OVERRIDE
;
187 virtual std::string
GetComponent() const APT_OVERRIDE
;
188 virtual std::string
GetArchitecture() const APT_OVERRIDE
;
189 virtual std::string
GetProgressDescription() const APT_OVERRIDE
;
190 virtual bool OpenListFile(FileFd
&Pkg
, std::string
const &FileName
) APT_OVERRIDE
;
193 virtual std::string
ArchiveURI(std::string
const &File
) const APT_OVERRIDE
;
194 virtual std::string
Describe(bool const Short
= false) const APT_OVERRIDE
;
195 virtual bool Exists() const APT_OVERRIDE
;
196 virtual unsigned long Size() const APT_OVERRIDE
;
198 pkgDebianIndexTargetFile(IndexTarget
const &Target
, bool const Trusted
);
199 virtual ~pkgDebianIndexTargetFile();
202 class pkgDebianIndexRealFile
: public pkgDebianIndexFile
208 virtual std::string
IndexFileName() const APT_OVERRIDE
;
209 virtual std::string
GetProgressDescription() const APT_OVERRIDE
;
210 virtual bool OpenListFile(FileFd
&Pkg
, std::string
const &FileName
) APT_OVERRIDE
;
212 virtual std::string
Describe(bool const /*Short*/ = false) const APT_OVERRIDE
;
213 virtual bool Exists() const APT_OVERRIDE
;
214 virtual unsigned long Size() const APT_OVERRIDE
;
215 virtual std::string
ArchiveURI(std::string
const &/*File*/) const APT_OVERRIDE
;
217 pkgDebianIndexRealFile(std::string
const &File
, bool const Trusted
);
218 virtual ~pkgDebianIndexRealFile();