apt @VERSION@

sourcelist.h

00001 // -*- mode: cpp; mode: fold -*-
00002 // Description                                                          /*{{{*/
00003 // $Id: sourcelist.h,v 1.12.2.1 2003/12/24 23:09:17 mdz Exp $
00004 /* ######################################################################
00005 
00006    SourceList - Manage a list of sources
00007    
00008    The Source List class provides access to a list of sources. It 
00009    can read them from a file and generate a list of all the distinct
00010    sources.
00011    
00012    All sources have a type associated with them that defines the layout
00013    of the archive. The exact format of the file is documented in
00014    files.sgml.
00015 
00016    The types are mapped through a list of type definitions which handle
00017    the actual construction of the back end type. After loading a source 
00018    list all you have is a list of package index files that have the ability
00019    to be Acquired.
00020    
00021    The vendor machanism is similar, except the vendor types are hard 
00022    wired. Before loading the source list the vendor list is loaded.
00023    This doesn't load key data, just the checks to perform.
00024    
00025    ##################################################################### */
00026                                                                         /*}}}*/
00027 #ifndef PKGLIB_SOURCELIST_H
00028 #define PKGLIB_SOURCELIST_H
00029 
00030 #include <string>
00031 #include <vector>
00032 #include <map>
00033 #include <apt-pkg/pkgcache.h>
00034 #include <apt-pkg/metaindex.h>
00035 
00036 using std::string;
00037 using std::vector;
00038     
00039 
00040 class pkgAquire;
00041 class pkgSourceList
00042 {
00043    public:
00044    
00045    // List of supported source list types
00046    class Type
00047    {
00048       public:
00049       
00050       // Global list of Items supported
00051       static Type **GlobalList;
00052       static unsigned long GlobalListLen;
00053       static Type *GetType(const char *Type);
00054 
00055       const char *Name;
00056       const char *Label;
00057 
00058       bool FixupURI(string &URI) const;
00059       virtual bool ParseLine(vector<metaIndex *> &List,
00060                              const char *Buffer,
00061                              unsigned long const &CurLine,string const &File) const;
00062       virtual bool CreateItem(vector<metaIndex *> &List,string const &URI,
00063                               string const &Dist,string const &Section,
00064                               std::map<string, string> const &Options) const = 0;
00065       Type();
00066       virtual ~Type() {};
00067    };
00068    
00069    typedef vector<metaIndex *>::const_iterator const_iterator;
00070    
00071    protected:
00072 
00073    vector<metaIndex *> SrcList;
00074    
00075    public:
00076 
00077    bool ReadMainList();
00078    bool Read(string File);
00079 
00080    // CNC:2003-03-03
00081    void Reset();
00082    bool ReadAppend(string File);
00083    bool ReadSourceDir(string Dir);
00084    
00085    // List accessors
00086    inline const_iterator begin() const {return SrcList.begin();};
00087    inline const_iterator end() const {return SrcList.end();};
00088    inline unsigned int size() const {return SrcList.size();};
00089    inline bool empty() const {return SrcList.empty();};
00090 
00091    bool FindIndex(pkgCache::PkgFileIterator File,
00092                   pkgIndexFile *&Found) const;
00093    bool GetIndexes(pkgAcquire *Owner, bool GetAll=false) const;
00094    
00095    pkgSourceList();
00096    pkgSourceList(string File);
00097    ~pkgSourceList();      
00098 };
00099 
00100 #endif