|
apt @VERSION@
|
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 00035 using std::string; 00036 using std::vector; 00037 00038 00039 class pkgAcquire; 00040 class pkgIndexFile; 00041 class metaIndex; 00042 00043 class pkgSourceList 00044 { 00045 public: 00046 00047 // List of supported source list types 00048 class Type 00049 { 00050 public: 00051 00052 // Global list of Items supported 00053 static Type **GlobalList; 00054 static unsigned long GlobalListLen; 00055 static Type *GetType(const char *Type); 00056 00057 const char *Name; 00058 const char *Label; 00059 00060 bool FixupURI(string &URI) const; 00061 virtual bool ParseLine(vector<metaIndex *> &List, 00062 const char *Buffer, 00063 unsigned long const &CurLine,string const &File) const; 00064 virtual bool CreateItem(vector<metaIndex *> &List,string const &URI, 00065 string const &Dist,string const &Section, 00066 std::map<string, string> const &Options) const = 0; 00067 Type(); 00068 virtual ~Type() {}; 00069 }; 00070 00071 typedef vector<metaIndex *>::const_iterator const_iterator; 00072 00073 protected: 00074 00075 vector<metaIndex *> SrcList; 00076 00077 public: 00078 00079 bool ReadMainList(); 00080 bool Read(string File); 00081 00082 // CNC:2003-03-03 00083 void Reset(); 00084 bool ReadAppend(string File); 00085 bool ReadSourceDir(string Dir); 00086 00087 // List accessors 00088 inline const_iterator begin() const {return SrcList.begin();}; 00089 inline const_iterator end() const {return SrcList.end();}; 00090 inline unsigned int size() const {return SrcList.size();}; 00091 inline bool empty() const {return SrcList.empty();}; 00092 00093 bool FindIndex(pkgCache::PkgFileIterator File, 00094 pkgIndexFile *&Found) const; 00095 bool GetIndexes(pkgAcquire *Owner, bool GetAll=false) const; 00096 00097 // query last-modified time 00098 time_t GetLastModifiedTime(); 00099 00100 pkgSourceList(); 00101 pkgSourceList(string File); 00102 ~pkgSourceList(); 00103 }; 00104 00105 #endif
1.7.4