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