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