]> git.saurik.com Git - apt.git/blob - apt-pkg/sourcelist.h
* cmdline/apt-mark:
[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 <apt-pkg/pkgcache.h>
33 #include <apt-pkg/metaindex.h>
34
35 using std::string;
36 using std::vector;
37
38 #ifdef __GNUG__
39 #pragma interface "apt-pkg/sourcelist.h"
40 #endif
41
42 class pkgAquire;
43 class pkgSourceList
44 {
45 public:
46
47 // List of supported source list types
48 class Type
49 {
50 public:
51
52 // Global list of Items supported
53 static Type **GlobalList;
54 static unsigned long GlobalListLen;
55 static Type *GetType(const char *Type);
56
57 const char *Name;
58 const char *Label;
59
60 bool FixupURI(string &URI) const;
61 virtual bool ParseLine(vector<metaIndex *> &List,
62 const char *Buffer,
63 unsigned long CurLine,string File) const;
64 virtual bool CreateItem(vector<metaIndex *> &List,string URI,
65 string Dist,string Section) const = 0;
66 Type();
67 virtual ~Type() {};
68 };
69
70 typedef vector<metaIndex *>::const_iterator const_iterator;
71
72 protected:
73
74 vector<metaIndex *> SrcList;
75
76 public:
77
78 bool ReadMainList();
79 bool Read(string File);
80
81 // CNC:2003-03-03
82 void Reset();
83 bool ReadAppend(string File);
84 bool ReadSourceDir(string Dir);
85
86 // List accessors
87 inline const_iterator begin() const {return SrcList.begin();};
88 inline const_iterator end() const {return SrcList.end();};
89 inline unsigned int size() const {return SrcList.size();};
90 inline bool empty() const {return SrcList.empty();};
91
92 bool FindIndex(pkgCache::PkgFileIterator File,
93 pkgIndexFile *&Found) const;
94 bool GetIndexes(pkgAcquire *Owner, bool GetAll=false) const;
95
96 pkgSourceList();
97 pkgSourceList(string File);
98 ~pkgSourceList();
99 };
100
101 #endif