]> git.saurik.com Git - apt.git/blame - apt-pkg/sourcelist.h
Fix typos in documentation (codespell)
[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>
5dd4c8b8 32#include <map>
094a497d 33#include <apt-pkg/pkgcache.h>
7037aab5 34#include <apt-pkg/tagfile.h>
0a843901 35
b9dadc24
DK
36#ifndef APT_8_CLEANER_HEADERS
37#include <apt-pkg/metaindex.h>
0a843901
AL
38using std::string;
39using std::vector;
b9dadc24 40#endif
6c139d6e 41
472ff00e
DK
42class pkgAcquire;
43class pkgIndexFile;
44class metaIndex;
45
6c139d6e
AL
46class pkgSourceList
47{
48 public:
49
b2e465d6
AL
50 // List of supported source list types
51 class Type
6c139d6e 52 {
b2e465d6 53 public:
6c139d6e 54
b2e465d6
AL
55 // Global list of Items supported
56 static Type **GlobalList;
57 static unsigned long GlobalListLen;
58 static Type *GetType(const char *Type);
59
60 const char *Name;
61 const char *Label;
62
73688d27 63 bool FixupURI(std::string &URI) const;
7037aab5
MV
64 virtual bool ParseStanza(std::vector<metaIndex *> &List,
65 pkgTagSection &Tags,
66 int stanza_n,
67 FileFd &Fd);
b9dadc24 68 virtual bool ParseLine(std::vector<metaIndex *> &List,
b2e465d6 69 const char *Buffer,
b9dadc24 70 unsigned long const &CurLine,std::string const &File) const;
73688d27 71 virtual bool CreateItem(std::vector<metaIndex *> &List,std::string const &URI,
b9dadc24
DK
72 std::string const &Dist,std::string const &Section,
73 std::map<std::string, std::string> const &Options) const = 0;
b2e465d6
AL
74 Type();
75 virtual ~Type() {};
6c139d6e 76 };
b2e465d6 77
b9dadc24 78 typedef std::vector<metaIndex *>::const_iterator const_iterator;
6c139d6e
AL
79
80 protected:
a7c835af 81
b9dadc24 82 std::vector<metaIndex *> SrcList;
6f447813 83
4194c9ae 84 int ParseFileDeb822(std::string File);
1fa78a8a 85 bool ParseFileOldStyle(std::string File);
6f447813 86
6c139d6e
AL
87 public:
88
89 bool ReadMainList();
b9dadc24 90 bool Read(std::string File);
34b53501
MV
91
92 // CNC:2003-03-03
93 void Reset();
b9dadc24
DK
94 bool ReadAppend(std::string File);
95 bool ReadSourceDir(std::string Dir);
6c139d6e
AL
96
97 // List accessors
a7c835af
AL
98 inline const_iterator begin() const {return SrcList.begin();};
99 inline const_iterator end() const {return SrcList.end();};
100 inline unsigned int size() const {return SrcList.size();};
101 inline bool empty() const {return SrcList.empty();};
0118833a 102
b2e465d6
AL
103 bool FindIndex(pkgCache::PkgFileIterator File,
104 pkgIndexFile *&Found) const;
b3d44315 105 bool GetIndexes(pkgAcquire *Owner, bool GetAll=false) const;
b2e465d6 106
2ec858bc
MV
107 // query last-modified time
108 time_t GetLastModifiedTime();
109
6c139d6e 110 pkgSourceList();
b9dadc24 111 pkgSourceList(std::string File);
1c193e02 112 ~pkgSourceList();
6c139d6e
AL
113};
114
6c139d6e 115#endif