]>
Commit | Line | Data |
---|---|---|
6c139d6e AL |
1 | // -*- mode: cpp; mode: fold -*- |
2 | // Description /*{{{*/ | |
1c193e02 | 3 | // $Id: sourcelist.h,v 1.12 2002/07/01 21:41:11 jgg Exp $ |
6c139d6e AL |
4 | /* ###################################################################### |
5 | ||
6 | SourceList - Manage a list of sources | |
7 | ||
8 | The Source List class provides access to a list of sources. It | |
6fc33863 AL |
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. | |
b2e465d6 AL |
15 | |
16 | The types are mapped through a list of type definitions which handle | |
a7c835af AL |
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 | |
b2e465d6 | 19 | to be Acquired. |
6c139d6e | 20 | |
a7c835af AL |
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 preform. | |
24 | ||
6c139d6e AL |
25 | ##################################################################### */ |
26 | /*}}}*/ | |
6c139d6e AL |
27 | #ifndef PKGLIB_SOURCELIST_H |
28 | #define PKGLIB_SOURCELIST_H | |
29 | ||
30 | #include <string> | |
31 | #include <vector> | |
094a497d | 32 | #include <apt-pkg/pkgcache.h> |
b2e465d6 | 33 | #include <apt-pkg/indexfile.h> |
0a843901 AL |
34 | |
35 | using std::string; | |
36 | using std::vector; | |
b2e465d6 | 37 | |
6c139d6e | 38 | #ifdef __GNUG__ |
094a497d | 39 | #pragma interface "apt-pkg/sourcelist.h" |
6c139d6e AL |
40 | #endif |
41 | ||
42 | class pkgAquire; | |
43 | class pkgSourceList | |
44 | { | |
45 | public: | |
46 | ||
a7c835af AL |
47 | // An available vendor |
48 | struct Vendor | |
49 | { | |
50 | string VendorID; | |
51 | string FingerPrint; | |
52 | string Description; | |
53 | ||
54 | /* Lets revisit these.. | |
55 | bool MatchFingerPrint(string FingerPrint); | |
56 | string FingerPrintDescr();*/ | |
57 | }; | |
58 | ||
b2e465d6 AL |
59 | // List of supported source list types |
60 | class Type | |
6c139d6e | 61 | { |
b2e465d6 | 62 | public: |
6c139d6e | 63 | |
b2e465d6 AL |
64 | // Global list of Items supported |
65 | static Type **GlobalList; | |
66 | static unsigned long GlobalListLen; | |
67 | static Type *GetType(const char *Type); | |
68 | ||
69 | const char *Name; | |
70 | const char *Label; | |
71 | ||
72 | bool FixupURI(string &URI) const; | |
73 | virtual bool ParseLine(vector<pkgIndexFile *> &List, | |
a7c835af | 74 | Vendor const *Vendor, |
b2e465d6 AL |
75 | const char *Buffer, |
76 | unsigned long CurLine,string File) const; | |
77 | virtual bool CreateItem(vector<pkgIndexFile *> &List,string URI, | |
a7c835af AL |
78 | string Dist,string Section, |
79 | Vendor const *Vendor) const = 0; | |
80 | ||
b2e465d6 AL |
81 | Type(); |
82 | virtual ~Type() {}; | |
6c139d6e | 83 | }; |
b2e465d6 AL |
84 | |
85 | typedef vector<pkgIndexFile *>::const_iterator const_iterator; | |
6c139d6e AL |
86 | |
87 | protected: | |
a7c835af AL |
88 | |
89 | vector<pkgIndexFile *> SrcList; | |
90 | vector<Vendor const *> VendorList; | |
6c139d6e AL |
91 | |
92 | public: | |
93 | ||
94 | bool ReadMainList(); | |
95 | bool Read(string File); | |
a7c835af | 96 | bool ReadVendors(); |
6c139d6e AL |
97 | |
98 | // List accessors | |
a7c835af AL |
99 | inline const_iterator begin() const {return SrcList.begin();}; |
100 | inline const_iterator end() const {return SrcList.end();}; | |
101 | inline unsigned int size() const {return SrcList.size();}; | |
102 | inline bool empty() const {return SrcList.empty();}; | |
0118833a | 103 | |
b2e465d6 AL |
104 | bool FindIndex(pkgCache::PkgFileIterator File, |
105 | pkgIndexFile *&Found) const; | |
106 | bool GetIndexes(pkgAcquire *Owner) const; | |
107 | ||
6c139d6e | 108 | pkgSourceList(); |
1c193e02 AL |
109 | pkgSourceList(string File); |
110 | ~pkgSourceList(); | |
6c139d6e AL |
111 | }; |
112 | ||
6c139d6e | 113 | #endif |