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