sourcelist.h 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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 <apt-pkg/pkgcache.h>
  26. #include <apt-pkg/metaindex.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. // List of supported source list types
  37. class Type
  38. {
  39. public:
  40. // Global list of Items supported
  41. static Type **GlobalList;
  42. static unsigned long GlobalListLen;
  43. static Type *GetType(const char *Type);
  44. const char *Name;
  45. const char *Label;
  46. bool FixupURI(string &URI) const;
  47. virtual bool ParseLine(vector<metaIndex *> &List,
  48. const char *Buffer,
  49. unsigned long CurLine,string File) const;
  50. virtual bool CreateItem(vector<metaIndex *> &List,string URI,
  51. string Dist,string Section) const = 0;
  52. Type();
  53. virtual ~Type() {};
  54. };
  55. typedef vector<metaIndex *>::const_iterator const_iterator;
  56. protected:
  57. vector<metaIndex *> SrcList;
  58. public:
  59. bool ReadMainList();
  60. bool Read(string File);
  61. // List accessors
  62. inline const_iterator begin() const {return SrcList.begin();};
  63. inline const_iterator end() const {return SrcList.end();};
  64. inline unsigned int size() const {return SrcList.size();};
  65. inline bool empty() const {return SrcList.empty();};
  66. bool FindIndex(pkgCache::PkgFileIterator File,
  67. pkgIndexFile *&Found) const;
  68. bool GetIndexes(pkgAcquire *Owner, bool GetAll=false) const;
  69. pkgSourceList();
  70. pkgSourceList(string File);
  71. ~pkgSourceList();
  72. };
  73. #endif