| 1 | // -*- mode: cpp; mode: fold -*- |
| 2 | // Description /*{{{*/ |
| 3 | // $Id: sourcelist.h,v 1.9 2001/02/20 07:03:17 jgg 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 type. After loading a source list all |
| 18 | you have is a list of package index files that have the ability |
| 19 | to be Acquired. |
| 20 | |
| 21 | ##################################################################### */ |
| 22 | /*}}}*/ |
| 23 | #ifndef PKGLIB_SOURCELIST_H |
| 24 | #define PKGLIB_SOURCELIST_H |
| 25 | |
| 26 | #include <string> |
| 27 | #include <vector> |
| 28 | #include <apt-pkg/pkgcache.h> |
| 29 | #include <apt-pkg/indexfile.h> |
| 30 | |
| 31 | #ifdef __GNUG__ |
| 32 | #pragma interface "apt-pkg/sourcelist.h" |
| 33 | #endif |
| 34 | |
| 35 | class pkgAquire; |
| 36 | class pkgSourceList |
| 37 | { |
| 38 | public: |
| 39 | |
| 40 | // List of supported source list types |
| 41 | class Type |
| 42 | { |
| 43 | public: |
| 44 | |
| 45 | // Global list of Items supported |
| 46 | static Type **GlobalList; |
| 47 | static unsigned long GlobalListLen; |
| 48 | static Type *GetType(const char *Type); |
| 49 | |
| 50 | const char *Name; |
| 51 | const char *Label; |
| 52 | |
| 53 | bool FixupURI(string &URI) const; |
| 54 | virtual bool ParseLine(vector<pkgIndexFile *> &List, |
| 55 | const char *Buffer, |
| 56 | unsigned long CurLine,string File) const; |
| 57 | virtual bool CreateItem(vector<pkgIndexFile *> &List,string URI, |
| 58 | string Dist,string Section) const = 0; |
| 59 | |
| 60 | Type(); |
| 61 | virtual ~Type() {}; |
| 62 | }; |
| 63 | |
| 64 | typedef vector<pkgIndexFile *>::const_iterator const_iterator; |
| 65 | |
| 66 | protected: |
| 67 | |
| 68 | vector<pkgIndexFile *> List; |
| 69 | |
| 70 | public: |
| 71 | |
| 72 | bool ReadMainList(); |
| 73 | bool Read(string File); |
| 74 | |
| 75 | // List accessors |
| 76 | inline const_iterator begin() const {return List.begin();}; |
| 77 | inline const_iterator end() const {return List.end();}; |
| 78 | inline unsigned int size() const {return List.size();}; |
| 79 | inline bool empty() const {return List.empty();}; |
| 80 | |
| 81 | bool FindIndex(pkgCache::PkgFileIterator File, |
| 82 | pkgIndexFile *&Found) const; |
| 83 | bool GetIndexes(pkgAcquire *Owner) const; |
| 84 | |
| 85 | pkgSourceList(); |
| 86 | pkgSourceList(string File); |
| 87 | }; |
| 88 | |
| 89 | #endif |