sourcelist.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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. #ifndef APT_8_CLEANER_HEADERS
  28. #include <apt-pkg/metaindex.h>
  29. using std::string;
  30. using std::vector;
  31. #endif
  32. class pkgAcquire;
  33. class pkgIndexFile;
  34. class metaIndex;
  35. class pkgSourceList
  36. {
  37. public:
  38. // List of supported source list types
  39. class Type
  40. {
  41. public:
  42. // Global list of Items supported
  43. static Type **GlobalList;
  44. static unsigned long GlobalListLen;
  45. static Type *GetType(const char *Type);
  46. const char *Name;
  47. const char *Label;
  48. bool FixupURI(std::string &URI) const;
  49. virtual bool ParseLine(std::vector<metaIndex *> &List,
  50. const char *Buffer,
  51. unsigned long const &CurLine,std::string const &File) const;
  52. virtual bool CreateItem(std::vector<metaIndex *> &List,std::string const &URI,
  53. std::string const &Dist,std::string const &Section,
  54. std::map<std::string, std::string> const &Options) const = 0;
  55. Type();
  56. virtual ~Type() {};
  57. };
  58. typedef std::vector<metaIndex *>::const_iterator const_iterator;
  59. protected:
  60. std::vector<metaIndex *> SrcList;
  61. public:
  62. bool ReadMainList();
  63. bool Read(std::string File);
  64. // CNC:2003-03-03
  65. void Reset();
  66. bool ReadAppend(std::string File);
  67. bool ReadSourceDir(std::string Dir);
  68. // List accessors
  69. inline const_iterator begin() const {return SrcList.begin();};
  70. inline const_iterator end() const {return SrcList.end();};
  71. inline unsigned int size() const {return SrcList.size();};
  72. inline bool empty() const {return SrcList.empty();};
  73. bool FindIndex(pkgCache::PkgFileIterator File,
  74. pkgIndexFile *&Found) const;
  75. bool GetIndexes(pkgAcquire *Owner, bool GetAll=false) const;
  76. // query last-modified time
  77. time_t GetLastModifiedTime();
  78. pkgSourceList();
  79. pkgSourceList(std::string File);
  80. ~pkgSourceList();
  81. };
  82. #endif