]>
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
;
43 class IndexTarget
/*{{{*/
44 /** \brief Information about an index file. */
47 /** \brief A URI from which the index file can be downloaded. */
50 /** \brief A description of the index file. */
51 std::string Description
;
53 /** \brief A shorter description of the index file. */
54 std::string ShortDesc
;
56 /** \brief The key by which this index file should be
57 looked up within the meta index file. */
60 /** \brief Is it okay if the file isn't found in the meta index */
63 /** \brief If the file is downloaded compressed, do not unpack it */
66 /** \brief options with which this target was created
67 Prefer the usage of #Option if at all possible.
68 Beware: Not all of these options are intended for public use */
69 std::map
<std::string
, std::string
> Options
;
71 IndexTarget(std::string
const &MetaKey
, std::string
const &ShortDesc
,
72 std::string
const &LongDesc
, std::string
const &URI
, bool const IsOptional
,
73 bool const KeepCompressed
, std::map
<std::string
, std::string
> const &Options
);
88 std::string
Option(OptionKeys
const Key
) const;
89 std::string
Format(std::string format
) const;
105 // Global list of Items supported
106 static Type
**GlobalList
;
107 static unsigned long GlobalListLen
;
108 static Type
*GetType(const char *Type
) APT_PURE
;
112 virtual pkgRecords::Parser
*CreatePkgParser(pkgCache::PkgFileIterator
/*File*/) const {return 0;};
113 virtual pkgSrcRecords::Parser
*CreateSrcPkgParser(std::string
/*File*/) const {return 0;};
118 virtual const Type
*GetType() const = 0;
120 // Return descriptive strings of various sorts
121 virtual std::string
ArchiveInfo(pkgCache::VerIterator Ver
) const;
122 virtual std::string
SourceInfo(pkgSrcRecords::Parser
const &Record
,
123 pkgSrcRecords::File
const &File
) const;
124 virtual std::string
Describe(bool Short
= false) const = 0;
126 // Interface for acquire
127 virtual std::string
ArchiveURI(std::string
/*File*/) const {return std::string();};
129 // Interface for the record parsers
130 virtual pkgSrcRecords::Parser
*CreateSrcParser() const {return 0;};
132 // Interface for the Cache Generator
133 virtual bool Exists() const = 0;
134 virtual bool HasPackages() const = 0;
135 virtual unsigned long Size() const = 0;
136 virtual bool Merge(pkgCacheGenerator
&/*Gen*/, OpProgress
* /*Prog*/) const { return false; };
137 APT_DEPRECATED
virtual bool Merge(pkgCacheGenerator
&Gen
, OpProgress
&Prog
) const
138 { return Merge(Gen
, &Prog
); };
139 virtual bool MergeFileProvides(pkgCacheGenerator
&/*Gen*/,OpProgress
* /*Prog*/) const {return true;};
140 APT_DEPRECATED
virtual bool MergeFileProvides(pkgCacheGenerator
&Gen
, OpProgress
&Prog
) const
141 {return MergeFileProvides(Gen
, &Prog
);};
142 virtual pkgCache::PkgFileIterator
FindInCache(pkgCache
&Cache
) const;
144 static bool TranslationsAvailable();
145 static bool CheckLanguageCode(const char *Lang
);
146 static std::string
LanguageCode();
148 bool IsTrusted() const { return Trusted
; };
150 explicit pkgIndexFile(bool Trusted
);
151 virtual ~pkgIndexFile();
154 class pkgIndexTargetFile
: public pkgIndexFile
158 IndexTarget
const Target
;
160 std::string
IndexFileName() const;
163 virtual std::string
ArchiveURI(std::string File
) const APT_OVERRIDE
;
164 virtual std::string
Describe(bool Short
= false) const APT_OVERRIDE
;
165 virtual bool Exists() const APT_OVERRIDE
;
166 virtual unsigned long Size() const APT_OVERRIDE
;
168 pkgIndexTargetFile(IndexTarget
const &Target
, bool const Trusted
);
169 virtual ~pkgIndexTargetFile();