Commit | Line | Data |
---|---|---|
6c139d6e AL |
1 | // -*- mode: cpp; mode: fold -*- |
2 | // Description /*{{{*/ | |
a7c835af | 3 | // $Id: sourcelist.h,v 1.10 2001/03/13 06:51:46 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 AL |
33 | #include <apt-pkg/indexfile.h> |
34 | ||
6c139d6e | 35 | #ifdef __GNUG__ |
094a497d | 36 | #pragma interface "apt-pkg/sourcelist.h" |
6c139d6e AL |
37 | #endif |
38 | ||
39 | class pkgAquire; | |
40 | class pkgSourceList | |
41 | { | |
42 | public: | |
43 | ||
a7c835af AL |
44 | // An available vendor |
45 | struct Vendor | |
46 | { | |
47 | string VendorID; | |
48 | string FingerPrint; | |
49 | string Description; | |
50 | ||
51 | /* Lets revisit these.. | |
52 | bool MatchFingerPrint(string FingerPrint); | |
53 | string FingerPrintDescr();*/ | |
54 | }; | |
55 | ||
b2e465d6 AL |
56 | // List of supported source list types |
57 | class Type | |
6c139d6e | 58 | { |
b2e465d6 | 59 | public: |
6c139d6e | 60 | |
b2e465d6 AL |
61 | // Global list of Items supported |
62 | static Type **GlobalList; | |
63 | static unsigned long GlobalListLen; | |
64 | static Type *GetType(const char *Type); | |
65 | ||
66 | const char *Name; | |
67 | const char *Label; | |
68 | ||
69 | bool FixupURI(string &URI) const; | |
70 | virtual bool ParseLine(vector<pkgIndexFile *> &List, | |
a7c835af | 71 | Vendor const *Vendor, |
b2e465d6 AL |
72 | const char *Buffer, |
73 | unsigned long CurLine,string File) const; | |
74 | virtual bool CreateItem(vector<pkgIndexFile *> &List,string URI, | |
a7c835af AL |
75 | string Dist,string Section, |
76 | Vendor const *Vendor) const = 0; | |
77 | ||
b2e465d6 AL |
78 | Type(); |
79 | virtual ~Type() {}; | |
6c139d6e | 80 | }; |
b2e465d6 AL |
81 | |
82 | typedef vector<pkgIndexFile *>::const_iterator const_iterator; | |
6c139d6e AL |
83 | |
84 | protected: | |
a7c835af AL |
85 | |
86 | vector<pkgIndexFile *> SrcList; | |
87 | vector<Vendor const *> VendorList; | |
6c139d6e AL |
88 | |
89 | public: | |
90 | ||
91 | bool ReadMainList(); | |
92 | bool Read(string File); | |
a7c835af | 93 | bool ReadVendors(); |
6c139d6e AL |
94 | |
95 | // List accessors | |
a7c835af AL |
96 | inline const_iterator begin() const {return SrcList.begin();}; |
97 | inline const_iterator end() const {return SrcList.end();}; | |
98 | inline unsigned int size() const {return SrcList.size();}; | |
99 | inline bool empty() const {return SrcList.empty();}; | |
0118833a | 100 | |
b2e465d6 AL |
101 | bool FindIndex(pkgCache::PkgFileIterator File, |
102 | pkgIndexFile *&Found) const; | |
103 | bool GetIndexes(pkgAcquire *Owner) const; | |
104 | ||
6c139d6e AL |
105 | pkgSourceList(); |
106 | pkgSourceList(string File); | |
107 | }; | |
108 | ||
6c139d6e | 109 | #endif |