]> git.saurik.com Git - apt.git/blob - apt-pkg/sourcelist.h
261dd81613739286ecb2d2bdec625d37317c0b82
[apt.git] / apt-pkg / sourcelist.h
1 // -*- mode: cpp; mode: fold -*-
2 // Description /*{{{*/
3 // $Id: sourcelist.h,v 1.12.2.1 2003/12/24 23:09:17 mdz Exp $
4 /* ######################################################################
5
6 SourceList - Manage a list of sources
7
8 The Source List class provides access to a list of sources. It
9 can read them from a file and generate a list of all the distinct
10 sources.
11
12 All sources have a type associated with them that defines the layout
13 of the archive. The exact format of the file is documented in
14 files.sgml.
15
16 The types are mapped through a list of type definitions which handle
17 the actual construction of the back end type. After loading a source
18 list all you have is a list of package index files that have the ability
19 to be Acquired.
20
21 The vendor machanism is similar, except the vendor types are hard
22 wired. Before loading the source list the vendor list is loaded.
23 This doesn't load key data, just the checks to perform.
24
25 ##################################################################### */
26 /*}}}*/
27 #ifndef PKGLIB_SOURCELIST_H
28 #define PKGLIB_SOURCELIST_H
29
30 #include <apt-pkg/pkgcache.h>
31 #include <apt-pkg/cacheiterators.h>
32 #include <apt-pkg/macros.h>
33
34 #include <time.h>
35
36 #include <string>
37 #include <vector>
38 #include <map>
39
40 #ifndef APT_8_CLEANER_HEADERS
41 #include <apt-pkg/tagfile.h>
42 #endif
43 #ifndef APT_8_CLEANER_HEADERS
44 #include <apt-pkg/metaindex.h>
45 using std::string;
46 using std::vector;
47 #endif
48
49 class FileFd;
50 class pkgTagSection;
51 class pkgAcquire;
52 class pkgIndexFile;
53 class metaIndex;
54
55 class pkgSource
56 {
57 protected:
58
59 std::vector<metaIndex *> SrcList;
60
61 };
62
63 class pkgSourceList : public pkgSource
64 {
65 public:
66
67 // List of supported source list types
68 class Type
69 {
70 public:
71
72 // Global list of Items supported
73 static Type **GlobalList;
74 static unsigned long GlobalListLen;
75 static Type *GetType(const char *Type) APT_PURE;
76
77 const char *Name;
78 const char *Label;
79
80 bool FixupURI(std::string &URI) const;
81 virtual bool ParseStanza(std::vector<metaIndex *> &List,
82 pkgTagSection &Tags,
83 int stanza_n,
84 FileFd &Fd);
85 virtual bool ParseLine(std::vector<metaIndex *> &List,
86 const char *Buffer,
87 unsigned long const &CurLine,std::string const &File) const;
88 virtual bool CreateItem(std::vector<metaIndex *> &List,std::string const &URI,
89 std::string const &Dist,std::string const &Section,
90 std::map<std::string, std::string> const &Options) const = 0;
91 Type();
92 virtual ~Type() {};
93 };
94
95 typedef std::vector<metaIndex *>::const_iterator const_iterator;
96
97 public:
98
99 std::vector<metaIndex *> SrcList;
100
101 int ParseFileDeb822(std::string File);
102 bool ParseFileOldStyle(std::string File);
103
104 public:
105
106 bool ReadMainList();
107 bool Read(std::string File);
108
109 // CNC:2003-03-03
110 void Reset();
111 bool ReadAppend(std::string File);
112 bool ReadSourceDir(std::string Dir);
113
114 // List accessors
115 inline const_iterator begin() const {return SrcList.begin();};
116 inline const_iterator end() const {return SrcList.end();};
117 inline unsigned int size() const {return SrcList.size();};
118 inline bool empty() const {return SrcList.empty();};
119
120 bool FindIndex(pkgCache::PkgFileIterator File,
121 pkgIndexFile *&Found) const;
122 bool GetIndexes(pkgAcquire *Owner, bool GetAll=false) const;
123
124 // query last-modified time
125 time_t GetLastModifiedTime();
126
127 pkgSourceList();
128 pkgSourceList(std::string File);
129 ~pkgSourceList();
130 };
131
132 #endif