]> git.saurik.com Git - apt.git/blame - apt-pkg/indexfile.h
use free() instead of delete() when realloc is used
[apt.git] / apt-pkg / indexfile.h
CommitLineData
b2e465d6
AL
1// -*- mode: cpp; mode: fold -*-
2// Description /*{{{*/
7db98ffc 3// $Id: indexfile.h,v 1.6.2.1 2003/12/24 23:09:17 mdz Exp $
b2e465d6
AL
4/* ######################################################################
5
6 Index File - Abstraction for an index of archive/source file.
7
a52f938b 8 There are 4 primary sorts of index files, all represented by this
b2e465d6
AL
9 class:
10
11 Binary index files
a52f938b 12 Binary translation files
1e3f4083 13 Binary index files describing the local system
b2e465d6
AL
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
1e3f4083 18 to access the underlying representation.
b2e465d6
AL
19
20 ##################################################################### */
21 /*}}}*/
22#ifndef PKGLIB_INDEXFILE_H
23#define PKGLIB_INDEXFILE_H
24
b2e465d6
AL
25#include <apt-pkg/srcrecords.h>
26#include <apt-pkg/pkgrecords.h>
453b82a3
DK
27#include <apt-pkg/pkgcache.h>
28#include <apt-pkg/cacheiterators.h>
472ff00e 29#include <apt-pkg/macros.h>
0a843901 30
453b82a3
DK
31#include <string>
32
a4f6bdc8
DK
33#ifndef APT_8_CLEANER_HEADERS
34using std::string;
35#endif
453b82a3 36#ifndef APT_10_CLEANER_HEADERS
b2e465d6 37class pkgAcquire;
453b82a3
DK
38#endif
39
b2e465d6
AL
40class pkgCacheGenerator;
41class OpProgress;
472ff00e 42
b2e465d6
AL
43class pkgIndexFile
44{
7db98ffc
MZ
45 protected:
46 bool Trusted;
47
b2e465d6
AL
48 public:
49
50 class Type
51 {
52 public:
53
54 // Global list of Items supported
55 static Type **GlobalList;
56 static unsigned long GlobalListLen;
a02db58f 57 static Type *GetType(const char *Type) APT_PURE;
b2e465d6
AL
58
59 const char *Label;
60
db5c1b54 61 virtual pkgRecords::Parser *CreatePkgParser(pkgCache::PkgFileIterator /*File*/) const {return 0;};
b2e465d6 62 Type();
0432d731 63 virtual ~Type() {};
b2e465d6
AL
64 };
65
66 virtual const Type *GetType() const = 0;
67
68 // Return descriptive strings of various sorts
8f3ba4e8
DK
69 virtual std::string ArchiveInfo(pkgCache::VerIterator Ver) const;
70 virtual std::string SourceInfo(pkgSrcRecords::Parser const &Record,
b2e465d6 71 pkgSrcRecords::File const &File) const;
8f3ba4e8 72 virtual std::string Describe(bool Short = false) const = 0;
b2e465d6
AL
73
74 // Interface for acquire
8f3ba4e8 75 virtual std::string ArchiveURI(std::string /*File*/) const {return std::string();};
b2e465d6
AL
76
77 // Interface for the record parsers
78 virtual pkgSrcRecords::Parser *CreateSrcParser() const {return 0;};
79
80 // Interface for the Cache Generator
81 virtual bool Exists() const = 0;
82 virtual bool HasPackages() const = 0;
83 virtual unsigned long Size() const = 0;
65512241 84 virtual bool Merge(pkgCacheGenerator &/*Gen*/, OpProgress* /*Prog*/) const { return false; };
453b82a3 85 APT_DEPRECATED virtual bool Merge(pkgCacheGenerator &Gen, OpProgress &Prog) const
2e5f4e45 86 { return Merge(Gen, &Prog); };
65512241 87 virtual bool MergeFileProvides(pkgCacheGenerator &/*Gen*/,OpProgress* /*Prog*/) const {return true;};
453b82a3 88 APT_DEPRECATED virtual bool MergeFileProvides(pkgCacheGenerator &Gen, OpProgress &Prog) const
2e5f4e45 89 {return MergeFileProvides(Gen, &Prog);};
b2e465d6 90 virtual pkgCache::PkgFileIterator FindInCache(pkgCache &Cache) const;
7db98ffc 91
770c32ec 92 static bool TranslationsAvailable();
a52f938b 93 static bool CheckLanguageCode(const char *Lang);
8f3ba4e8 94 static std::string LanguageCode();
a52f938b 95
7db98ffc 96 bool IsTrusted() const { return Trusted; };
b2e465d6 97
7db98ffc 98 pkgIndexFile(bool Trusted): Trusted(Trusted) {};
b2e465d6
AL
99 virtual ~pkgIndexFile() {};
100};
101
102#endif