apt  2.2.4
About: Apt (Advanced Package Tool) is a management system for software packages (Debian/Ubuntu). Release series 2.2.
  Fossies Dox: apt-2.2.4.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

indexfile.h
Go to the documentation of this file.
1 // -*- mode: cpp; mode: fold -*-
2 // Description /*{{{*/
3 /* ######################################################################
4 
5  Index File - Abstraction for an index of archive/source file.
6 
7  There are 4 primary sorts of index files, all represented by this
8  class:
9 
10  Binary index files
11  Binary translation files
12  Binary index files describing the local system
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
17  to access the underlying representation.
18 
19  ##################################################################### */
20  /*}}}*/
21 #ifndef PKGLIB_INDEXFILE_H
22 #define PKGLIB_INDEXFILE_H
23 
24 #include <apt-pkg/macros.h>
25 #include <apt-pkg/pkgcache.h>
26 #include <apt-pkg/pkgrecords.h>
27 #include <apt-pkg/srcrecords.h>
28 
29 #include <map>
30 #include <string>
31 
32 
33 class pkgCacheGenerator;
34 class pkgCacheListParser;
35 class OpProgress;
36 
37 class APT_PUBLIC IndexTarget /*{{{*/
38 /** \brief Information about an index file. */
39 {
40  public:
41  /** \brief A URI from which the index file can be downloaded. */
42  std::string URI;
43 
44  /** \brief A description of the index file. */
45  std::string Description;
46 
47  /** \brief A shorter description of the index file. */
48  std::string ShortDesc;
49 
50  /** \brief The key by which this index file should be
51  looked up within the meta index file. */
52  std::string MetaKey;
53 
54  /** \brief Is it okay if the file isn't found in the meta index */
55  bool IsOptional;
56 
57  /** \brief If the file is downloaded compressed, do not unpack it */
59 
60  /** \brief options with which this target was created
61  Prefer the usage of #Option if at all possible.
62  Beware: Not all of these options are intended for public use */
63  std::map<std::string, std::string> Options;
64 
65  IndexTarget(std::string const &MetaKey, std::string const &ShortDesc,
66  std::string const &LongDesc, std::string const &URI, bool const IsOptional,
67  bool const KeepCompressed, std::map<std::string, std::string> const &Options);
68 
70  {
94  };
95  std::string Option(OptionKeys const Key) const;
96  bool OptionBool(OptionKeys const Key) const;
97  std::string Format(std::string format) const;
98 };
99  /*}}}*/
100 
102 {
103  void * const d;
104  protected:
105  bool Trusted;
106 
107  public:
108 
110  {
111  public:
112 
113  // Global list of Items supported
114  static Type **GlobalList;
115  static unsigned long GlobalListLen;
116  static Type *GetType(const char * const Type) APT_PURE;
117 
118  const char *Label;
119 
120  virtual pkgRecords::Parser *CreatePkgParser(pkgCache::PkgFileIterator const &/*File*/) const {return 0;};
121  virtual pkgSrcRecords::Parser *CreateSrcPkgParser(std::string const &/*File*/) const {return 0;};
122  Type();
123  virtual ~Type() {};
124  };
125 
126  virtual const Type *GetType() const = 0;
127 
128  // Return descriptive strings of various sorts
129  virtual std::string ArchiveInfo(pkgCache::VerIterator const &Ver) const;
130  virtual std::string SourceInfo(pkgSrcRecords::Parser const &Record,
131  pkgSrcRecords::File const &File) const;
132  virtual std::string Describe(bool const Short = false) const = 0;
133 
134  // Interface for acquire
135  virtual std::string ArchiveURI(std::string const &/*File*/) const {return std::string();};
136 
137  // Interface for the record parsers
138  virtual pkgSrcRecords::Parser *CreateSrcParser() const {return 0;};
139 
140  // Interface for the Cache Generator
141  virtual bool Exists() const = 0;
142  virtual bool HasPackages() const = 0;
143  virtual unsigned long Size() const = 0;
144  virtual bool Merge(pkgCacheGenerator &/*Gen*/, OpProgress* const /*Prog*/) { return true; };
145  virtual pkgCache::PkgFileIterator FindInCache(pkgCache &Cache) const;
146 
147  bool IsTrusted() const { return Trusted; };
148 
149  explicit pkgIndexFile(bool const Trusted);
150  virtual ~~pkgIndexFile();
151 };
152 
154 {
155 protected:
156  virtual std::string IndexFileName() const = 0;
157  virtual std::string GetComponent() const = 0;
158  virtual std::string GetArchitecture() const = 0;
159  virtual std::string GetProgressDescription() const = 0;
160  virtual uint8_t GetIndexFlags() const = 0;
161  virtual bool OpenListFile(FileFd &Pkg, std::string const &FileName) = 0;
162  APT_HIDDEN virtual pkgCacheListParser * CreateListParser(FileFd &Pkg);
163 
164 public:
165  virtual bool Merge(pkgCacheGenerator &Gen, OpProgress* const Prog) APT_OVERRIDE;
166  virtual pkgCache::PkgFileIterator FindInCache(pkgCache &Cache) const APT_OVERRIDE;
167 
168  explicit pkgDebianIndexFile(bool const Trusted);
169  virtual ~~pkgDebianIndexFile();
170 };
171 
173 {
174  void * const d;
175 protected:
177 
178  virtual std::string IndexFileName() const APT_OVERRIDE;
179  virtual std::string GetComponent() const APT_OVERRIDE;
180  virtual std::string GetArchitecture() const APT_OVERRIDE;
181  virtual std::string GetProgressDescription() const APT_OVERRIDE;
182  virtual bool OpenListFile(FileFd &Pkg, std::string const &FileName) APT_OVERRIDE;
183 
184 public:
185  virtual std::string ArchiveURI(std::string const &File) const APT_OVERRIDE;
186  virtual std::string Describe(bool const Short = false) const APT_OVERRIDE;
187  virtual bool Exists() const APT_OVERRIDE;
188  virtual unsigned long Size() const APT_OVERRIDE;
189  IndexTarget GetIndexTarget() const APT_HIDDEN;
190 
191  pkgDebianIndexTargetFile(IndexTarget const &Target, bool const Trusted);
192  virtual ~pkgDebianIndexTargetFile();
193 };
194 
196 {
197  void * const d;
198 protected:
199  std::string File;
200 
201  virtual std::string IndexFileName() const APT_OVERRIDE;
202  virtual std::string GetProgressDescription() const APT_OVERRIDE;
203  virtual bool OpenListFile(FileFd &Pkg, std::string const &FileName) APT_OVERRIDE;
204 public:
205  virtual std::string Describe(bool const /*Short*/ = false) const APT_OVERRIDE;
206  virtual bool Exists() const APT_OVERRIDE;
207  virtual unsigned long Size() const APT_OVERRIDE;
208  virtual std::string ArchiveURI(std::string const &/*File*/) const APT_OVERRIDE;
209 
210  pkgDebianIndexRealFile(std::string const &File, bool const Trusted);
211  virtual ~pkgDebianIndexRealFile();
212 };
213 
214 #endif
return false
Definition: fileutl.h:39
Information about an index file.
Definition: indexfile.h:39
bool IsOptional
Is it okay if the file isn't found in the meta index.
Definition: indexfile.h:55
bool KeepCompressed
If the file is downloaded compressed, do not unpack it.
Definition: indexfile.h:58
std::string Description
A description of the index file.
Definition: indexfile.h:45
std::string ShortDesc
A shorter description of the index file.
Definition: indexfile.h:48
std::map< std::string, std::string > Options
options with which this target was created Prefer the usage of Option if at all possible....
Definition: indexfile.h:63
std::string URI
A URI from which the index file can be downloaded.
Definition: indexfile.h:42
@ DEFAULTENABLED
Definition: indexfile.h:84
@ ARCHITECTURE
Definition: indexfile.h:75
@ ALLOW_DOWNGRADE_TO_INSECURE
Definition: indexfile.h:92
@ COMPRESSIONTYPES
Definition: indexfile.h:83
@ KEEPCOMPRESSEDAS
Definition: indexfile.h:87
@ EXISTING_FILENAME
Definition: indexfile.h:81
@ INRELEASE_PATH
Definition: indexfile.h:93
@ ALLOW_INSECURE
Definition: indexfile.h:90
@ SOURCESENTRY
Definition: indexfile.h:85
std::string MetaKey
The key by which this index file should be looked up within the meta index file.
Definition: indexfile.h:52
Definition: strutl.h:193
virtual bool OpenListFile(FileFd &Pkg, std::string const &FileName)=0
virtual std::string IndexFileName() const =0
virtual std::string GetArchitecture() const =0
virtual std::string GetComponent() const =0
virtual uint8_t GetIndexFlags() const =0
virtual std::string GetProgressDescription() const =0
IndexTarget const Target
Definition: indexfile.h:176
const char * Label
Definition: indexfile.h:118
virtual pkgRecords::Parser * CreatePkgParser(pkgCache::PkgFileIterator const &) const
Definition: indexfile.h:120
static Type ** GlobalList
Definition: indexfile.h:114
virtual pkgSrcRecords::Parser * CreateSrcPkgParser(std::string const &) const
Definition: indexfile.h:121
static unsigned long GlobalListLen
Definition: indexfile.h:115
virtual ~Type()
Definition: indexfile.h:123
virtual std::string ArchiveURI(std::string const &) const
Definition: indexfile.h:135
bool IsTrusted() const
Definition: indexfile.h:147
bool Trusted
Definition: indexfile.h:105
virtual const Type * GetType() const =0
virtual unsigned long Size() const =0
virtual bool Merge(pkgCacheGenerator &, OpProgress *const)
Definition: indexfile.h:144
virtual std::string Describe(bool const Short=false) const =0
void *const d
Definition: indexfile.h:103
virtual bool HasPackages() const =0
virtual bool Exists() const =0
virtual pkgSrcRecords::Parser * CreateSrcParser() const
Definition: indexfile.h:138
#define APT_OVERRIDE
Definition: macros.h:111
#define APT_PURE
Definition: macros.h:56
#define APT_PUBLIC
Definition: macros.h:77
#define APT_HIDDEN
Definition: macros.h:78
pkgCache - Structure definitions for the cache file
static std::string GetArchitecture(pkgCacheFile &CacheFile, pkgCache::PkgIterator P)