cleanup headers and especially #includes everywhere
[ntk/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 <apt-pkg/pkgcache.h>
31 #include <apt-pkg/cacheiterators.h>
32
33 #include <time.h>
34
35 #include <string>
36 #include <vector>
37 #include <map>
38
39 #ifndef APT_8_CLEANER_HEADERS
40 #include <apt-pkg/tagfile.h>
41 #endif
42 #ifndef APT_8_CLEANER_HEADERS
43 #include <apt-pkg/metaindex.h>
44 using std::string;
45 using std::vector;
46 #endif
47
48 class FileFd;
49 class pkgTagSection;
50 class pkgAcquire;
51 class pkgIndexFile;
52 class metaIndex;
53
54 class pkgSourceList
55 {
56 public:
57
58 // List of supported source list types
59 class Type
60 {
61 public:
62
63 // Global list of Items supported
64 static Type **GlobalList;
65 static unsigned long GlobalListLen;
66 static Type *GetType(const char *Type);
67
68 const char *Name;
69 const char *Label;
70
71 bool FixupURI(std::string &URI) const;
72 virtual bool ParseStanza(std::vector<metaIndex *> &List,
73 pkgTagSection &Tags,
74 int stanza_n,
75 FileFd &Fd);
76 virtual bool ParseLine(std::vector<metaIndex *> &List,
77 const char *Buffer,
78 unsigned long const &CurLine,std::string const &File) const;
79 virtual bool CreateItem(std::vector<metaIndex *> &List,std::string const &URI,
80 std::string const &Dist,std::string const &Section,
81 std::map<std::string, std::string> const &Options) const = 0;
82 Type();
83 virtual ~Type() {};
84 };
85
86 typedef std::vector<metaIndex *>::const_iterator const_iterator;
87
88 protected:
89
90 std::vector<metaIndex *> SrcList;
91
92 int ParseFileDeb822(std::string File);
93 bool ParseFileOldStyle(std::string File);
94
95 public:
96
97 bool ReadMainList();
98 bool Read(std::string File);
99
100 // CNC:2003-03-03
101 void Reset();
102 bool ReadAppend(std::string File);
103 bool ReadSourceDir(std::string Dir);
104
105 // List accessors
106 inline const_iterator begin() const {return SrcList.begin();};
107 inline const_iterator end() const {return SrcList.end();};
108 inline unsigned int size() const {return SrcList.size();};
109 inline bool empty() const {return SrcList.empty();};
110
111 bool FindIndex(pkgCache::PkgFileIterator File,
112 pkgIndexFile *&Found) const;
113 bool GetIndexes(pkgAcquire *Owner, bool GetAll=false) const;
114
115 // query last-modified time
116 time_t GetLastModifiedTime();
117
118 pkgSourceList();
119 pkgSourceList(std::string File);
120 ~pkgSourceList();
121 };
122
123 #endif