sourcelist.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. // -*- mode: cpp; mode: fold -*-
  2. // Description /*{{{*/
  3. // $Id: sourcelist.h,v 1.12 2002/07/01 21:41:11 jgg 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 preform.
  19. ##################################################################### */
  20. /*}}}*/
  21. #ifndef PKGLIB_SOURCELIST_H
  22. #define PKGLIB_SOURCELIST_H
  23. #include <string>
  24. #include <vector>
  25. #include <apt-pkg/pkgcache.h>
  26. #include <apt-pkg/indexfile.h>
  27. using std::string;
  28. using std::vector;
  29. #ifdef __GNUG__
  30. #pragma interface "apt-pkg/sourcelist.h"
  31. #endif
  32. class pkgAquire;
  33. class pkgSourceList
  34. {
  35. public:
  36. // An available vendor
  37. struct Vendor
  38. {
  39. string VendorID;
  40. string FingerPrint;
  41. string Description;
  42. /* Lets revisit these..
  43. bool MatchFingerPrint(string FingerPrint);
  44. string FingerPrintDescr();*/
  45. };
  46. // List of supported source list types
  47. class Type
  48. {
  49. public:
  50. // Global list of Items supported
  51. static Type **GlobalList;
  52. static unsigned long GlobalListLen;
  53. static Type *GetType(const char *Type);
  54. const char *Name;
  55. const char *Label;
  56. bool FixupURI(string &URI) const;
  57. virtual bool ParseLine(vector<pkgIndexFile *> &List,
  58. Vendor const *Vendor,
  59. const char *Buffer,
  60. unsigned long CurLine,string File) const;
  61. virtual bool CreateItem(vector<pkgIndexFile *> &List,string URI,
  62. string Dist,string Section,
  63. Vendor const *Vendor) const = 0;
  64. Type();
  65. virtual ~Type() {};
  66. };
  67. typedef vector<pkgIndexFile *>::const_iterator const_iterator;
  68. protected:
  69. vector<pkgIndexFile *> SrcList;
  70. vector<Vendor const *> VendorList;
  71. public:
  72. bool ReadMainList();
  73. bool Read(string File);
  74. bool ReadVendors();
  75. // List accessors
  76. inline const_iterator begin() const {return SrcList.begin();};
  77. inline const_iterator end() const {return SrcList.end();};
  78. inline unsigned int size() const {return SrcList.size();};
  79. inline bool empty() const {return SrcList.empty();};
  80. bool FindIndex(pkgCache::PkgFileIterator File,
  81. pkgIndexFile *&Found) const;
  82. bool GetIndexes(pkgAcquire *Owner) const;
  83. pkgSourceList();
  84. pkgSourceList(string File);
  85. ~pkgSourceList();
  86. };
  87. #endif