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)  

sourcelist.h
Go to the documentation of this file.
1 // -*- mode: cpp; mode: fold -*-
2 // Description /*{{{*/
3 /* ######################################################################
4 
5  SourceList - Manage a list of sources
6 
7  The Source List class provides access to a list of sources. It
8  can read them from a file and generate a list of all the distinct
9  sources.
10 
11  All sources have a type associated with them that defines the layout
12  of the archive. The exact format of the file is documented in
13  files.sgml.
14 
15  The types are mapped through a list of type definitions which handle
16  the actual construction of the back end type. After loading a source
17  list all you have is a list of package index files that have the ability
18  to be Acquired.
19 
20  ##################################################################### */
21  /*}}}*/
22 #ifndef PKGLIB_SOURCELIST_H
23 #define PKGLIB_SOURCELIST_H
24 
25 #include <apt-pkg/macros.h>
26 #include <apt-pkg/pkgcache.h>
27 
28 #include <time.h>
29 
30 #include <map>
31 #include <string>
32 #include <vector>
33 
34 
35 class FileFd;
36 class pkgTagSection;
37 class pkgAcquire;
38 class pkgIndexFile;
39 class metaIndex;
40 class CommandLine;
41 
43 {
44  void * const d;
45  std::vector<pkgIndexFile*> VolatileFiles;
46  public:
47 
48  // List of supported source list types
49  class Type
50  {
51  public:
52 
53  // Global list of Items supported
54  static Type **GlobalList;
55  static unsigned long GlobalListLen;
56  static Type *GetType(const char *Type) APT_PURE;
57 
58  char const * const Name;
59  char const * const Label;
60 
61  bool FixupURI(std::string &URI) const;
62  virtual bool ParseStanza(std::vector<metaIndex *> &List,
63  pkgTagSection &Tags,
64  unsigned int const stanza_n,
65  FileFd &Fd);
66  virtual bool ParseLine(std::vector<metaIndex *> &List,
67  const char *Buffer,
68  unsigned int const CurLine,std::string const &File) const;
69  virtual bool CreateItem(std::vector<metaIndex *> &List,std::string const &URI,
70  std::string const &Dist,std::string const &Section,
71  std::map<std::string, std::string> const &Options) const = 0;
72  Type(char const * const Name, char const * const Label);
73  virtual ~~Type();
74  };
75 
76  typedef std::vector<metaIndex *>::const_iterator const_iterator;
77 
78  protected:
79 
80  std::vector<metaIndex *> SrcList;
81 
82  private:
83  APT_HIDDEN bool ParseFileDeb822(std::string const &File);
84  APT_HIDDEN bool ParseFileOldStyle(std::string const &File);
85 
86  public:
87 
88  bool ReadMainList();
89  bool Read(std::string const &File);
90 
91  // CNC:2003-03-03
92  void Reset();
93  bool ReadAppend(std::string const &File);
94  bool ReadSourceDir(std::string const &Dir);
95 
96  // List accessors
97  inline const_iterator begin() const {return SrcList.begin();};
98  inline const_iterator end() const {return SrcList.end();};
99  inline unsigned int size() const {return SrcList.size();};
100  inline bool empty() const {return SrcList.empty();};
101 
102  bool FindIndex(pkgCache::PkgFileIterator File,
103  pkgIndexFile *&Found) const;
104  bool GetIndexes(pkgAcquire *Owner, bool GetAll=false) const;
105 
106  // query last-modified time
107  time_t GetLastModifiedTime();
108 
109  /** \brief add file for parsing, but not to the cache
110  *
111  * pkgIndexFiles originating from pkgSourcesList are included in
112  * srcpkgcache, the status files added via #AddStatusFiles are
113  * included in pkgcache, but these files here are not included in
114  * any cache to have the possibility of having a file included just
115  * for a single run like a local .deb/.dsc file.
116  *
117  * The volatile files do not count as "normal" sourceslist entries,
118  * can't be iterated over with #begin and #end and can't be
119  * downloaded, but they can be found via #FindIndex.
120  *
121  * @param File is an index file; pointer-ownership is transferred
122  */
123  void AddVolatileFile(pkgIndexFile * const File);
124  bool AddVolatileFile(std::string const &File);
125  bool AddVolatileFile(std::string const &File, std::vector<std::string> * const VolatileCmdL);
126  void AddVolatileFiles(CommandLine &CmdL, std::vector<std::string> * const VolatileCmdL);
127 
128  /** @return list of files registered with #AddVolatileFile */
129  std::vector<pkgIndexFile*> GetVolatileFiles() const;
130 
131  pkgSourceList();
132  virtual ~~pkgSourceList();
133 };
134 
135 #endif
Definition: fileutl.h:39
Definition: strutl.h:193
Represents the process by which a pkgAcquire object should retrieve a file or a collection of files.
Definition: acquire-item.h:59
static Type ** GlobalList
Definition: sourcelist.h:54
virtual bool CreateItem(std::vector< metaIndex * > &List, std::string const &URI, std::string const &Dist, std::string const &Section, std::map< std::string, std::string > const &Options) const =0
char const *const Name
Definition: sourcelist.h:58
static unsigned long GlobalListLen
Definition: sourcelist.h:55
char const *const Label
Definition: sourcelist.h:59
const_iterator begin() const
Definition: sourcelist.h:97
std::vector< metaIndex * > SrcList
Definition: sourcelist.h:80
bool empty() const
Definition: sourcelist.h:100
unsigned int size() const
Definition: sourcelist.h:99
std::vector< pkgIndexFile * > VolatileFiles
Definition: sourcelist.h:45
const_iterator end() const
Definition: sourcelist.h:98
void *const d
Definition: sourcelist.h:44
std::vector< metaIndex * >::const_iterator const_iterator
Definition: sourcelist.h:76
#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