apt: apt-pkg/sourcelist.h Source File

apt 3.2.0 commandline package manager

sourcelist.h
1// -*- mode: cpp; mode: fold -*-
2// Description /*{{{*/
3/* ######################################################################
4
5 SourceList - Manage a list of sources
6
7 The Source List class provides access to a list of sources. It
8 can read them from a file and generate a list of all the distinct
9 sources.
10
11 All sources have a type associated with them that defines the layout
12 of the archive. The exact format of the file is documented in
13 files.sgml.
14
15 The types are mapped through a list of type definitions which handle
16 the actual construction of the back end type. After loading a source
17 list all you have is a list of package index files that have the ability
18 to be Acquired.
19
20 ##################################################################### */
21 /*}}}*/
22#ifndef PKGLIB_SOURCELIST_H
23#define PKGLIB_SOURCELIST_H
24
25#include <apt-pkg/macros.h>
26#include <apt-pkg/pkgcache.h>
27
28#include <ctime>
29
30#include <map>
31#include <string>
32#include <vector>
33
34
35class FileFd;
36class pkgTagSection;
37class pkgAcquire;
38class pkgIndexFile;
39class metaIndex;
40class CommandLine;
41
42 class APT_PUBLIC pkgSourceList
43{
44 void * const d;
45 std::vector<pkgIndexFile*> VolatileFiles;
46 public:
47
48 // List of supported source list types
49 class Type
50 {
51 public:
52
53 // Global list of Items supported
54 static Type **GlobalList;
55 static unsigned long GlobalListLen;
56 static Type *GetType(const char *Type) APT_PURE;
57
58 char const * const Name;
59 char const * const Label;
60
61 bool FixupURI(std::string &URI) const;
62 virtual bool ParseStanza(std::vector<metaIndex *> &List,
63 pkgTagSection &Tags,
64 unsigned int const stanza_n,
65 FileFd &Fd);
66 virtual bool ParseLine(std::vector<metaIndex *> &List,
67 const char *Buffer,
68 unsigned int const CurLine,std::string const &File) const;
69 virtual bool CreateItem(std::vector<metaIndex *> &List,std::string const &URI,
70 std::string const &Dist,std::string const &Section,
71 std::map<std::string, std::string> const &Options) const = 0;
72 Type(char const * const Name, char const * const Label);
73 virtual ~Type();
74 };
75
76 typedef std::vector<metaIndex *>::const_iterator const_iterator;
77
78 protected:
79
80 std::vector<metaIndex *> SrcList;
81
82 private:
83 APT_HIDDEN bool ParseFileDeb822(std::string const &File);
84 APT_HIDDEN bool ParseFileOldStyle(std::string const &File);
85
86 public:
87
88 bool ReadMainList();
89 bool Read(std::string const &File);
90
91 // CNC:2003-03-03
92 void Reset();
93 bool ReadAppend(std::string const &File);
94 bool ReadSourceDir(std::string const &Dir);
95
96 // List accessors
97 inline const_iterator begin() const {return SrcList.begin();};
98 inline const_iterator end() const {return SrcList.end();};
99 inline unsigned int size() const {return SrcList.size();};
100 inline bool empty() const {return SrcList.empty();};
101
102 bool FindIndex(pkgCache::PkgFileIterator File,
103 pkgIndexFile *&Found) const;
104 bool GetIndexes(pkgAcquire *Owner, bool GetAll=false) const;
105
106 // query last-modified time
107 time_t GetLastModifiedTime();
108
123 void AddVolatileFile(pkgIndexFile * const File);
124 bool AddVolatileFile(std::string const &File);
125 bool AddVolatileFile(std::string const &File, std::vector<std::string> * const VolatileCmdL);
126 void AddVolatileFiles(CommandLine &CmdL, std::vector<std::string> * const VolatileCmdL);
127
129 std::vector<pkgIndexFile*> GetVolatileFiles() const;
130
131 pkgSourceList();
132 virtual ~pkgSourceList();
133};
134
135#endif
CommandLine
Definition cmndline.h:52
FileFd
Definition fileutl.h:43
URI
Definition strutl.h:221
metaIndex
Definition metaindex.h:21
pkgAcquire
The core download scheduler. {{{.
Definition acquire.h:94
pkgIndexFile
Definition indexfile.h:103
pkgTagSection
Definition tagfile.h:46
pkgcache.h
pkgCache - Structure definitions for the cache file