]> git.saurik.com Git - apt.git/blame - apt-pkg/sourcelist.h
merged from lp:~mvo/apt/mvo
[apt.git] / apt-pkg / sourcelist.h
CommitLineData
6c139d6e
AL
1// -*- mode: cpp; mode: fold -*-
2// Description /*{{{*/
b3d44315 3// $Id: sourcelist.h,v 1.12.2.1 2003/12/24 23:09:17 mdz Exp $
6c139d6e
AL
4/* ######################################################################
5
6 SourceList - Manage a list of sources
7
8 The Source List class provides access to a list of sources. It
6fc33863
AL
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.
b2e465d6
AL
15
16 The types are mapped through a list of type definitions which handle
a7c835af
AL
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
b2e465d6 19 to be Acquired.
6c139d6e 20
a7c835af
AL
21 The vendor machanism is similar, except the vendor types are hard
22 wired. Before loading the source list the vendor list is loaded.
b3d44315 23 This doesn't load key data, just the checks to perform.
a7c835af 24
6c139d6e
AL
25 ##################################################################### */
26 /*}}}*/
6c139d6e
AL
27#ifndef PKGLIB_SOURCELIST_H
28#define PKGLIB_SOURCELIST_H
29
30#include <string>
31#include <vector>
094a497d 32#include <apt-pkg/pkgcache.h>
b3d44315 33#include <apt-pkg/metaindex.h>
0a843901
AL
34
35using std::string;
36using std::vector;
b2e465d6 37
6c139d6e
AL
38
39class pkgAquire;
40class pkgSourceList
41{
42 public:
43
b2e465d6
AL
44 // List of supported source list types
45 class Type
6c139d6e 46 {
b2e465d6 47 public:
6c139d6e 48
b2e465d6
AL
49 // Global list of Items supported
50 static Type **GlobalList;
51 static unsigned long GlobalListLen;
52 static Type *GetType(const char *Type);
53
54 const char *Name;
55 const char *Label;
56
57 bool FixupURI(string &URI) const;
b3d44315 58 virtual bool ParseLine(vector<metaIndex *> &List,
b2e465d6
AL
59 const char *Buffer,
60 unsigned long CurLine,string File) const;
b3d44315
MV
61 virtual bool CreateItem(vector<metaIndex *> &List,string URI,
62 string Dist,string Section) const = 0;
b2e465d6
AL
63 Type();
64 virtual ~Type() {};
6c139d6e 65 };
b2e465d6 66
b3d44315 67 typedef vector<metaIndex *>::const_iterator const_iterator;
6c139d6e
AL
68
69 protected:
a7c835af 70
b3d44315 71 vector<metaIndex *> SrcList;
6c139d6e
AL
72
73 public:
74
75 bool ReadMainList();
76 bool Read(string File);
34b53501
MV
77
78 // CNC:2003-03-03
79 void Reset();
80 bool ReadAppend(string File);
81 bool ReadSourceDir(string Dir);
6c139d6e
AL
82
83 // List accessors
a7c835af
AL
84 inline const_iterator begin() const {return SrcList.begin();};
85 inline const_iterator end() const {return SrcList.end();};
86 inline unsigned int size() const {return SrcList.size();};
87 inline bool empty() const {return SrcList.empty();};
0118833a 88
b2e465d6
AL
89 bool FindIndex(pkgCache::PkgFileIterator File,
90 pkgIndexFile *&Found) const;
b3d44315 91 bool GetIndexes(pkgAcquire *Owner, bool GetAll=false) const;
b2e465d6 92
6c139d6e 93 pkgSourceList();
1c193e02
AL
94 pkgSourceList(string File);
95 ~pkgSourceList();
6c139d6e
AL
96};
97
6c139d6e 98#endif