sourcelist.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. // -*- mode: cpp; mode: fold -*-
  2. // Description /*{{{*/
  3. // $Id: sourcelist.h,v 1.12.2.1 2003/12/24 23:09:17 mdz Exp $
  4. /* ######################################################################
  5. SourceList - Manage a list of sources
  6. The Source List class provides access to a list of sources. It
  7. can read them from a file and generate a list of all the distinct
  8. sources.
  9. All sources have a type associated with them that defines the layout
  10. of the archive. The exact format of the file is documented in
  11. files.sgml.
  12. The types are mapped through a list of type definitions which handle
  13. the actual construction of the back end type. After loading a source
  14. list all you have is a list of package index files that have the ability
  15. to be Acquired.
  16. The vendor machanism is similar, except the vendor types are hard
  17. wired. Before loading the source list the vendor list is loaded.
  18. This doesn't load key data, just the checks to perform.
  19. ##################################################################### */
  20. /*}}}*/
  21. #ifndef PKGLIB_SOURCELIST_H
  22. #define PKGLIB_SOURCELIST_H
  23. #include <string>
  24. #include <vector>
  25. #include <map>
  26. #include <apt-pkg/pkgcache.h>
  27. #include <apt-pkg/metaindex.h>
  28. using std::string;
  29. using std::vector;
  30. class pkgAquire;
  31. class pkgSourceList
  32. {
  33. public:
  34. // List of supported source list types
  35. class Type
  36. {
  37. public:
  38. // Global list of Items supported
  39. static Type **GlobalList;
  40. static unsigned long GlobalListLen;
  41. static Type *GetType(const char *Type);
  42. const char *Name;
  43. const char *Label;
  44. bool FixupURI(string &URI) const;
  45. virtual bool ParseLine(vector<metaIndex *> &List,
  46. const char *Buffer,
  47. unsigned long const &CurLine,string const &File) const;
  48. virtual bool CreateItem(vector<metaIndex *> &List,string const &URI,
  49. string const &Dist,string const &Section,
  50. std::map<string, string> const &Options) const = 0;
  51. Type();
  52. virtual ~Type() {};
  53. };
  54. typedef vector<metaIndex *>::const_iterator const_iterator;
  55. protected:
  56. vector<metaIndex *> SrcList;
  57. public:
  58. bool ReadMainList();
  59. bool Read(string File);
  60. // CNC:2003-03-03
  61. void Reset();
  62. bool ReadAppend(string File);
  63. bool ReadSourceDir(string Dir);
  64. // List accessors
  65. inline const_iterator begin() const {return SrcList.begin();};
  66. inline const_iterator end() const {return SrcList.end();};
  67. inline unsigned int size() const {return SrcList.size();};
  68. inline bool empty() const {return SrcList.empty();};
  69. bool FindIndex(pkgCache::PkgFileIterator File,
  70. pkgIndexFile *&Found) const;
  71. bool GetIndexes(pkgAcquire *Owner, bool GetAll=false) const;
  72. // query last-modified time
  73. time_t GetLastModifiedTime();
  74. pkgSourceList();
  75. pkgSourceList(string File);
  76. ~pkgSourceList();
  77. };
  78. #endif