]> git.saurik.com Git - apt.git/blob - apt-pkg/sourcelist.h
debian/control: Set Standards-Version to 3.9.7
[apt.git] / apt-pkg / sourcelist.h
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/pkgcache.h>
26 #include <apt-pkg/cacheiterators.h>
27 #include <apt-pkg/macros.h>
28
29 #include <time.h>
30
31 #include <string>
32 #include <vector>
33 #include <map>
34
35 #ifndef APT_8_CLEANER_HEADERS
36 #include <apt-pkg/tagfile.h>
37 #endif
38 #ifndef APT_8_CLEANER_HEADERS
39 #include <apt-pkg/metaindex.h>
40 using std::string;
41 using std::vector;
42 #endif
43
44 class FileFd;
45 class pkgTagSection;
46 class pkgAcquire;
47 class pkgIndexFile;
48 class metaIndex;
49 class CommandLine;
50
51 class pkgSourceList
52 {
53 void * const d;
54 std::vector<pkgIndexFile*> VolatileFiles;
55 public:
56
57 // List of supported source list types
58 class Type
59 {
60 public:
61
62 // Global list of Items supported
63 static Type **GlobalList;
64 static unsigned long GlobalListLen;
65 static Type *GetType(const char *Type) APT_PURE;
66
67 char const * const Name;
68 char const * const Label;
69
70 bool FixupURI(std::string &URI) const;
71 virtual bool ParseStanza(std::vector<metaIndex *> &List,
72 pkgTagSection &Tags,
73 unsigned int const stanza_n,
74 FileFd &Fd);
75 virtual bool ParseLine(std::vector<metaIndex *> &List,
76 const char *Buffer,
77 unsigned int const CurLine,std::string const &File) const;
78 virtual bool CreateItem(std::vector<metaIndex *> &List,std::string const &URI,
79 std::string const &Dist,std::string const &Section,
80 std::map<std::string, std::string> const &Options) const = 0;
81 Type(char const * const Name, char const * const Label);
82 virtual ~Type();
83 };
84
85 typedef std::vector<metaIndex *>::const_iterator const_iterator;
86
87 protected:
88
89 std::vector<metaIndex *> SrcList;
90
91 private:
92 APT_HIDDEN bool ParseFileDeb822(std::string const &File);
93 APT_HIDDEN bool ParseFileOldStyle(std::string const &File);
94
95 public:
96
97 bool ReadMainList();
98 bool Read(std::string const &File);
99
100 // CNC:2003-03-03
101 void Reset();
102 bool ReadAppend(std::string const &File);
103 bool ReadSourceDir(std::string const &Dir);
104
105 // List accessors
106 inline const_iterator begin() const {return SrcList.begin();};
107 inline const_iterator end() const {return SrcList.end();};
108 inline unsigned int size() const {return SrcList.size();};
109 inline bool empty() const {return SrcList.empty();};
110
111 bool FindIndex(pkgCache::PkgFileIterator File,
112 pkgIndexFile *&Found) const;
113 bool GetIndexes(pkgAcquire *Owner, bool GetAll=false) const;
114
115 // query last-modified time
116 time_t GetLastModifiedTime();
117
118 /** \brief add file for parsing, but not to the cache
119 *
120 * pkgIndexFiles origining from pkgSourcesList are included in
121 * srcpkgcache, the status files added via #AddStatusFiles are
122 * included in pkgcache, but these files here are not included in
123 * any cache to have the possibility of having a file included just
124 * for a single run like a local .deb/.dsc file.
125 *
126 * The volatile files do not count as "normal" sourceslist entries,
127 * can't be iterated over with #begin and #end and can't be
128 * downloaded, but they can be found via #FindIndex.
129 *
130 * @param File is an index file; pointer-ownership is transferred
131 */
132 void AddVolatileFile(pkgIndexFile * const File);
133 bool AddVolatileFile(std::string const &File);
134 void AddVolatileFiles(CommandLine &CmdL, std::vector<const char*> * const VolatileCmdL);
135
136 /** @return list of files registered with #AddVolatileFile */
137 std::vector<pkgIndexFile*> GetVolatileFiles() const;
138
139 pkgSourceList();
140 virtual ~pkgSourceList();
141 };
142
143 #endif