]>
git.saurik.com Git - apt.git/blob - apt-pkg/indexfile.h
562b9f7b83f613c0cda7cb0b9823783cba30aec9
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
);
90 std::string
Option(OptionKeys
const Key
) const;
91 bool OptionBool(OptionKeys
const Key
) const;
92 std::string
Format(std::string format
) const;
108 // Global list of Items supported
109 static Type
**GlobalList
;
110 static unsigned long GlobalListLen
;
111 static Type
*GetType(const char * const Type
) APT_PURE
;
115 virtual pkgRecords::Parser
*CreatePkgParser(pkgCache::PkgFileIterator
const &/*File*/) const {return 0;};
116 virtual pkgSrcRecords::Parser
*CreateSrcPkgParser(std::string
const &/*File*/) const {return 0;};
121 virtual const Type
*GetType() const = 0;
123 // Return descriptive strings of various sorts
124 virtual std::string
ArchiveInfo(pkgCache::VerIterator
const &Ver
) const;
125 virtual std::string
SourceInfo(pkgSrcRecords::Parser
const &Record
,
126 pkgSrcRecords::File
const &File
) const;
127 virtual std::string
Describe(bool const Short
= false) const = 0;
129 // Interface for acquire
130 virtual std::string
ArchiveURI(std::string
const &/*File*/) const {return std::string();};
132 // Interface for the record parsers
133 virtual pkgSrcRecords::Parser
*CreateSrcParser() const {return 0;};
135 // Interface for the Cache Generator
136 virtual bool Exists() const = 0;
137 virtual bool HasPackages() const = 0;
138 virtual unsigned long Size() const = 0;
139 virtual bool Merge(pkgCacheGenerator
&/*Gen*/, OpProgress
* const /*Prog*/) { return true; };
140 virtual pkgCache::PkgFileIterator
FindInCache(pkgCache
&Cache
) const;
142 static bool TranslationsAvailable();
143 static bool CheckLanguageCode(const char * const Lang
);
144 static std::string
LanguageCode();
146 bool IsTrusted() const { return Trusted
; };
148 explicit pkgIndexFile(bool const Trusted
);
149 virtual ~pkgIndexFile();
152 class pkgDebianIndexFile
: public pkgIndexFile
155 virtual std::string
IndexFileName() const = 0;
156 virtual std::string
GetComponent() const = 0;
157 virtual std::string
GetArchitecture() const = 0;
158 virtual std::string
GetProgressDescription() const = 0;
159 virtual uint8_t GetIndexFlags() const = 0;
160 virtual bool OpenListFile(FileFd
&Pkg
, std::string
const &FileName
) = 0;
161 APT_HIDDEN
virtual pkgCacheListParser
* CreateListParser(FileFd
&Pkg
);
164 virtual bool Merge(pkgCacheGenerator
&Gen
, OpProgress
* const Prog
) APT_OVERRIDE
;
165 virtual pkgCache::PkgFileIterator
FindInCache(pkgCache
&Cache
) const APT_OVERRIDE
;
167 pkgDebianIndexFile(bool const Trusted
);
168 virtual ~pkgDebianIndexFile();
171 class pkgDebianIndexTargetFile
: public pkgDebianIndexFile
175 IndexTarget
const Target
;
177 virtual std::string
IndexFileName() const APT_OVERRIDE
;
178 virtual std::string
GetComponent() const APT_OVERRIDE
;
179 virtual std::string
GetArchitecture() const APT_OVERRIDE
;
180 virtual std::string
GetProgressDescription() const APT_OVERRIDE
;
181 virtual bool OpenListFile(FileFd
&Pkg
, std::string
const &FileName
) APT_OVERRIDE
;
184 virtual std::string
ArchiveURI(std::string
const &File
) const APT_OVERRIDE
;
185 virtual std::string
Describe(bool const Short
= false) const APT_OVERRIDE
;
186 virtual bool Exists() const APT_OVERRIDE
;
187 virtual unsigned long Size() const APT_OVERRIDE
;
189 pkgDebianIndexTargetFile(IndexTarget
const &Target
, bool const Trusted
);
190 virtual ~pkgDebianIndexTargetFile();
193 class pkgDebianIndexRealFile
: public pkgDebianIndexFile
199 virtual std::string
IndexFileName() const APT_OVERRIDE
;
200 virtual std::string
GetProgressDescription() const APT_OVERRIDE
;
201 virtual bool OpenListFile(FileFd
&Pkg
, std::string
const &FileName
) APT_OVERRIDE
;
203 virtual std::string
Describe(bool const /*Short*/ = false) const APT_OVERRIDE
;
204 virtual bool Exists() const APT_OVERRIDE
;
205 virtual unsigned long Size() const APT_OVERRIDE
;
206 virtual std::string
ArchiveURI(std::string
const &/*File*/) const APT_OVERRIDE
;
208 pkgDebianIndexRealFile(std::string
const &File
, bool const Trusted
);
209 virtual ~pkgDebianIndexRealFile();