sourcelist.h 3.0 KB

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