sourcelist.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. // -*- mode: cpp; mode: fold -*-
  2. // Description /*{{{*/
  3. // $Id: sourcelist.h,v 1.9 2001/02/20 07:03:17 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 type. After loading a source list all
  14. you have is a list of package index files that have the ability
  15. to be Acquired.
  16. ##################################################################### */
  17. /*}}}*/
  18. #ifndef PKGLIB_SOURCELIST_H
  19. #define PKGLIB_SOURCELIST_H
  20. #include <string>
  21. #include <vector>
  22. #include <apt-pkg/pkgcache.h>
  23. #include <apt-pkg/indexfile.h>
  24. #ifdef __GNUG__
  25. #pragma interface "apt-pkg/sourcelist.h"
  26. #endif
  27. class pkgAquire;
  28. class pkgSourceList
  29. {
  30. public:
  31. // List of supported source list types
  32. class Type
  33. {
  34. public:
  35. // Global list of Items supported
  36. static Type **GlobalList;
  37. static unsigned long GlobalListLen;
  38. static Type *GetType(const char *Type);
  39. const char *Name;
  40. const char *Label;
  41. bool FixupURI(string &URI) const;
  42. virtual bool ParseLine(vector<pkgIndexFile *> &List,
  43. const char *Buffer,
  44. unsigned long CurLine,string File) const;
  45. virtual bool CreateItem(vector<pkgIndexFile *> &List,string URI,
  46. string Dist,string Section) const = 0;
  47. Type();
  48. virtual ~Type() {};
  49. };
  50. typedef vector<pkgIndexFile *>::const_iterator const_iterator;
  51. protected:
  52. vector<pkgIndexFile *> List;
  53. public:
  54. bool ReadMainList();
  55. bool Read(string File);
  56. // List accessors
  57. inline const_iterator begin() const {return List.begin();};
  58. inline const_iterator end() const {return List.end();};
  59. inline unsigned int size() const {return List.size();};
  60. inline bool empty() const {return List.empty();};
  61. bool FindIndex(pkgCache::PkgFileIterator File,
  62. pkgIndexFile *&Found) const;
  63. bool GetIndexes(pkgAcquire *Owner) const;
  64. pkgSourceList();
  65. pkgSourceList(string File);
  66. };
  67. #endif