* merged the apt--curl-https branch
[ntk/apt.git] / apt-pkg / indexfile.h
1 // -*- mode: cpp; mode: fold -*-
2 // Description /*{{{*/
3 // $Id: indexfile.h,v 1.6.2.1 2003/12/24 23:09:17 mdz Exp $
4 /* ######################################################################
5
6 Index File - Abstraction for an index of archive/source file.
7
8 There are 4 primary sorts of index files, all represented by this
9 class:
10
11 Binary index files
12 Binary translation files
13 Bianry index files decribing the local system
14 Source index files
15
16 They are all bundled together here, and the interfaces for
17 sources.list, acquire, cache gen and record parsing all use this class
18 to acess the underlying representation.
19
20 ##################################################################### */
21 /*}}}*/
22 #ifndef PKGLIB_INDEXFILE_H
23 #define PKGLIB_INDEXFILE_H
24
25 #ifdef __GNUG__
26 #pragma interface "apt-pkg/indexfile.h"
27 #endif
28
29 #include <string>
30 #include <apt-pkg/pkgcache.h>
31 #include <apt-pkg/srcrecords.h>
32 #include <apt-pkg/pkgrecords.h>
33
34 using std::string;
35
36 class pkgAcquire;
37 class pkgCacheGenerator;
38 class OpProgress;
39 class pkgIndexFile
40 {
41 protected:
42 bool Trusted;
43
44 public:
45
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 *Label;
56
57 virtual pkgRecords::Parser *CreatePkgParser(pkgCache::PkgFileIterator /*File*/) const {return 0;};
58 Type();
59 virtual ~Type() {};
60 };
61
62 virtual const Type *GetType() const = 0;
63
64 // Return descriptive strings of various sorts
65 virtual string ArchiveInfo(pkgCache::VerIterator Ver) const;
66 virtual string SourceInfo(pkgSrcRecords::Parser const &Record,
67 pkgSrcRecords::File const &File) const;
68 virtual string Describe(bool Short = false) const = 0;
69
70 // Interface for acquire
71 virtual string ArchiveURI(string /*File*/) const {return string();};
72
73 // Interface for the record parsers
74 virtual pkgSrcRecords::Parser *CreateSrcParser() const {return 0;};
75
76 // Interface for the Cache Generator
77 virtual bool Exists() const = 0;
78 virtual bool HasPackages() const = 0;
79 virtual unsigned long Size() const = 0;
80 virtual bool Merge(pkgCacheGenerator &/*Gen*/,OpProgress &/*Prog*/) const {return false;};
81 virtual bool MergeFileProvides(pkgCacheGenerator &/*Gen*/,OpProgress &/*Prog*/) const {return true;};
82 virtual pkgCache::PkgFileIterator FindInCache(pkgCache &Cache) const;
83
84 static bool TranslationsAvailable();
85 static bool CheckLanguageCode(const char *Lang);
86 static string LanguageCode();
87
88 bool IsTrusted() const { return Trusted; };
89
90 pkgIndexFile(bool Trusted): Trusted(Trusted) {};
91 virtual ~pkgIndexFile() {};
92 };
93
94 #endif