]> git.saurik.com Git - apt.git/blob - apt-pkg/sourcelist.h
079f3cb3d7345d6dda91169f8c86cfb0154c0ac5
[apt.git] / apt-pkg / sourcelist.h
1 // -*- mode: cpp; mode: fold -*-
2 // Description /*{{{*/
3 /* ######################################################################
4
5 SourceList - Manage a list of sources
6
7 The Source List class provides access to a list of sources. It
8 can read them from a file and generate a list of all the distinct
9 sources.
10
11 All sources have a type associated with them that defines the layout
12 of the archive. The exact format of the file is documented in
13 files.sgml.
14
15 The types are mapped through a list of type definitions which handle
16 the actual construction of the back end type. After loading a source
17 list all you have is a list of package index files that have the ability
18 to be Acquired.
19
20 The vendor machanism is similar, except the vendor types are hard
21 wired. Before loading the source list the vendor list is loaded.
22 This doesn't load key data, just the checks to perform.
23
24 ##################################################################### */
25 /*}}}*/
26 #ifndef PKGLIB_SOURCELIST_H
27 #define PKGLIB_SOURCELIST_H
28
29 #include <apt-pkg/pkgcache.h>
30 #include <apt-pkg/cacheiterators.h>
31 #include <apt-pkg/macros.h>
32
33 #include <time.h>
34
35 #include <string>
36 #include <vector>
37 #include <map>
38
39 #ifndef APT_8_CLEANER_HEADERS
40 #include <apt-pkg/tagfile.h>
41 #endif
42 #ifndef APT_8_CLEANER_HEADERS
43 #include <apt-pkg/metaindex.h>
44 using std::string;
45 using std::vector;
46 #endif
47
48 class FileFd;
49 class pkgTagSection;
50 class pkgAcquire;
51 class pkgIndexFile;
52 class metaIndex;
53
54 class pkgSourceList
55 {
56 void * const d;
57 public:
58
59 // List of supported source list types
60 class Type
61 {
62 public:
63
64 // Global list of Items supported
65 static Type **GlobalList;
66 static unsigned long GlobalListLen;
67 static Type *GetType(const char *Type) APT_PURE;
68
69 char const * const Name;
70 char const * const Label;
71
72 bool FixupURI(std::string &URI) const;
73 virtual bool ParseStanza(std::vector<metaIndex *> &List,
74 pkgTagSection &Tags,
75 unsigned int const stanza_n,
76 FileFd &Fd);
77 virtual bool ParseLine(std::vector<metaIndex *> &List,
78 const char *Buffer,
79 unsigned int const CurLine,std::string const &File) const;
80 virtual bool CreateItem(std::vector<metaIndex *> &List,std::string const &URI,
81 std::string const &Dist,std::string const &Section,
82 std::map<std::string, std::string> const &Options) const = 0;
83 Type(char const * const Name, char const * const Label);
84 virtual ~Type();
85 };
86
87 typedef std::vector<metaIndex *>::const_iterator const_iterator;
88
89 protected:
90
91 std::vector<metaIndex *> SrcList;
92
93 private:
94 APT_HIDDEN bool ParseFileDeb822(std::string const &File);
95 APT_HIDDEN bool ParseFileOldStyle(std::string const &File);
96
97 public:
98
99 bool ReadMainList();
100 bool Read(std::string const &File);
101
102 // CNC:2003-03-03
103 void Reset();
104 bool ReadAppend(std::string const &File);
105 bool ReadSourceDir(std::string const &Dir);
106
107 // List accessors
108 inline const_iterator begin() const {return SrcList.begin();};
109 inline const_iterator end() const {return SrcList.end();};
110 inline unsigned int size() const {return SrcList.size();};
111 inline bool empty() const {return SrcList.empty();};
112
113 bool FindIndex(pkgCache::PkgFileIterator File,
114 pkgIndexFile *&Found) const;
115 bool GetIndexes(pkgAcquire *Owner, bool GetAll=false) const;
116
117 // query last-modified time
118 time_t GetLastModifiedTime();
119
120 pkgSourceList();
121 virtual ~pkgSourceList();
122 };
123
124 #endif