apt-key del: Ignore case when checking if a keyid exists in a keyring.
[ntk/apt.git] / apt-pkg / cachefile.h
CommitLineData
2d11135a
AL
1// -*- mode: cpp; mode: fold -*-
2// Description /*{{{*/
0077d829 3// $Id: cachefile.h,v 1.5 2002/04/27 04:28:04 jgg Exp $
2d11135a
AL
4/* ######################################################################
5
6 CacheFile - Simple wrapper class for opening, generating and whatnot
7
8 This class implements a simple 2 line mechanism to open various sorts
9 of caches. It can operate as root, as not root, show progress and so on,
10 it transparently handles everything necessary.
11
b2e465d6
AL
12 This means it can rebuild caches from the source list and instantiates
13 and prepares the standard policy mechanism.
14
2d11135a
AL
15 ##################################################################### */
16 /*}}}*/
17#ifndef PKGLIB_CACHEFILE_H
18#define PKGLIB_CACHEFILE_H
19
453b82a3
DK
20#include <stddef.h>
21
2d11135a 22#include <apt-pkg/depcache.h>
472ff00e 23#include <apt-pkg/macros.h>
453b82a3
DK
24#include <apt-pkg/pkgcache.h>
25#include <apt-pkg/cacheiterators.h>
472ff00e 26
b9dadc24
DK
27#ifndef APT_8_CLEANER_HEADERS
28#include <apt-pkg/acquire.h>
29#include <apt-pkg/policy.h>
30#include <apt-pkg/sourcelist.h>
31#endif
32
453b82a3 33class MMap;
472ff00e
DK
34class pkgPolicy;
35class pkgSourceList;
36class OpProgress;
2d11135a
AL
37
38class pkgCacheFile
39{
be9b62f7
MV
40 /** \brief dpointer placeholder (for later in case we need it) */
41 void *d;
42
2d11135a
AL
43 protected:
44
45 MMap *Map;
b2e465d6
AL
46 pkgCache *Cache;
47 pkgDepCache *DCache;
3f8621c5 48 pkgSourceList *SrcList;
2e5f4e45 49
2d11135a 50 public:
6b2f7a60 51 pkgPolicy *Policy;
b2e465d6 52
2d11135a 53 // We look pretty much exactly like a pointer to a dep cache
b2e465d6
AL
54 inline operator pkgCache &() {return *Cache;};
55 inline operator pkgCache *() {return Cache;};
56 inline operator pkgDepCache &() {return *DCache;};
57 inline operator pkgDepCache *() {return DCache;};
3f8621c5
DK
58 inline operator pkgPolicy &() {return *Policy;};
59 inline operator pkgPolicy *() {return Policy;};
60 inline operator pkgSourceList &() {return *SrcList;};
61 inline operator pkgSourceList *() {return SrcList;};
b2e465d6
AL
62 inline pkgDepCache *operator ->() {return DCache;};
63 inline pkgDepCache &operator *() {return *DCache;};
64 inline pkgDepCache::StateCache &operator [](pkgCache::PkgIterator const &I) {return (*DCache)[I];};
65 inline unsigned char &operator [](pkgCache::DepIterator const &I) {return (*DCache)[I];};
099a4759 66
2e5f4e45 67 bool BuildCaches(OpProgress *Progress = NULL,bool WithLock = true);
453b82a3 68 APT_DEPRECATED bool BuildCaches(OpProgress &Progress,bool const &WithLock = true) { return BuildCaches(&Progress, WithLock); };
3f8621c5 69 bool BuildSourceList(OpProgress *Progress = NULL);
2e5f4e45
DK
70 bool BuildPolicy(OpProgress *Progress = NULL);
71 bool BuildDepCache(OpProgress *Progress = NULL);
72 bool Open(OpProgress *Progress = NULL, bool WithLock = true);
3f8621c5 73 inline bool ReadOnlyOpen(OpProgress *Progress = NULL) { return Open(Progress, false); };
453b82a3 74 APT_DEPRECATED bool Open(OpProgress &Progress,bool const &WithLock = true) { return Open(&Progress, WithLock); };
8de79b68 75 static void RemoveCaches();
b2e465d6 76 void Close();
3f8621c5
DK
77
78 inline pkgCache* GetPkgCache() { BuildCaches(NULL, false); return Cache; };
79 inline pkgDepCache* GetDepCache() { BuildDepCache(); return DCache; };
80 inline pkgPolicy* GetPolicy() { BuildPolicy(); return Policy; };
81 inline pkgSourceList* GetSourceList() { BuildSourceList(); return SrcList; };
82
a8ef7efd
DK
83 inline bool IsPkgCacheBuilt() const { return (Cache != NULL); };
84 inline bool IsDepCacheBuilt() const { return (DCache != NULL); };
85 inline bool IsPolicyBuilt() const { return (Policy != NULL); };
86 inline bool IsSrcListBuilt() const { return (SrcList != NULL); };
87
2d11135a 88 pkgCacheFile();
2e5f4e45 89 virtual ~pkgCacheFile();
2d11135a
AL
90};
91
92#endif