]> git.saurik.com Git - apt.git/blame - apt-pkg/metaindex.cc
doc/files.dbk: Improve documentation for {src,}pkgcache.bin
[apt.git] / apt-pkg / metaindex.cc
CommitLineData
f105aaba 1// Include Files /*{{{*/
b07aeb1a 2#include <apt-pkg/pkgcachegen.h>
f105aaba
DK
3#include <apt-pkg/indexfile.h>
4#include <apt-pkg/metaindex.h>
5
6#include <stddef.h>
7
8#include <string>
9#include <vector>
10 /*}}}*/
11
b07aeb1a
DK
12std::string metaIndex::Describe() const
13{
14 return "Release";
15}
16
3fd89e62 17pkgCache::RlsFileIterator metaIndex::FindInCache(pkgCache &Cache, bool const) const
b07aeb1a
DK
18{
19 return pkgCache::RlsFileIterator(Cache);
20}
21
22bool metaIndex::Merge(pkgCacheGenerator &Gen,OpProgress *) const
23{
24 return Gen.SelectReleaseFile("", "");
25}
26
f105aaba
DK
27metaIndex::metaIndex(std::string const &URI, std::string const &Dist,
28 char const * const Type)
5ad0096a 29: d(NULL), Indexes(NULL), Type(Type), URI(URI), Dist(Dist), Trusted(TRI_UNSET),
b0d40854 30 Date(0), ValidUntil(0), SupportsAcquireByHash(false), LoadedSuccessfully(TRI_UNSET)
f105aaba
DK
31{
32 /* nothing */
33}
34
35metaIndex::~metaIndex()
36{
37 if (Indexes == 0)
38 return;
39 for (std::vector<pkgIndexFile *>::iterator I = (*Indexes).begin();
40 I != (*Indexes).end(); ++I)
41 delete *I;
42 delete Indexes;
43}
5ad0096a
DK
44
45// one line Getters for public fields /*{{{*/
46APT_PURE std::string metaIndex::GetURI() const { return URI; }
47APT_PURE std::string metaIndex::GetDist() const { return Dist; }
48APT_PURE const char* metaIndex::GetType() const { return Type; }
49APT_PURE metaIndex::TriState metaIndex::GetTrusted() const { return Trusted; }
b0d40854 50APT_PURE std::string metaIndex::GetSignedBy() const { return SignedBy; }
5ad0096a
DK
51APT_PURE std::string metaIndex::GetCodename() const { return Codename; }
52APT_PURE std::string metaIndex::GetSuite() const { return Suite; }
53APT_PURE bool metaIndex::GetSupportsAcquireByHash() const { return SupportsAcquireByHash; }
54APT_PURE time_t metaIndex::GetValidUntil() const { return ValidUntil; }
55APT_PURE time_t metaIndex::GetDate() const { return this->Date; }
56APT_PURE metaIndex::TriState metaIndex::GetLoadedSuccessfully() const { return LoadedSuccessfully; }
57
58APT_PURE bool metaIndex::CheckDist(string const &MaybeDist) const
59{
60 return (this->Codename == MaybeDist
61 || this->Suite == MaybeDist);
62}
63APT_PURE std::string metaIndex::GetExpectedDist() const
64{
65 // TODO: Used to be an explicit value set in the constructor
66 return "";
67}
68 /*}}}*/
69APT_PURE metaIndex::checkSum *metaIndex::Lookup(string const &MetaKey) const /*{{{*/
70{
71 std::map<std::string, metaIndex::checkSum* >::const_iterator sum = Entries.find(MetaKey);
72 if (sum == Entries.end())
73 return NULL;
74 return sum->second;
75}
76 /*}}}*/
77APT_PURE bool metaIndex::Exists(string const &MetaKey) const /*{{{*/
78{
79 return Entries.find(MetaKey) != Entries.end();
80}
81 /*}}}*/
82std::vector<std::string> metaIndex::MetaKeys() const /*{{{*/
83{
84 std::vector<std::string> keys;
85 std::map<string,checkSum *>::const_iterator I = Entries.begin();
86 while(I != Entries.end()) {
87 keys.push_back((*I).first);
88 ++I;
89 }
90 return keys;
91}
92 /*}}}*/
93void metaIndex::swapLoad(metaIndex * const OldMetaIndex) /*{{{*/
94{
95 std::swap(Entries, OldMetaIndex->Entries);
96 std::swap(Date, OldMetaIndex->Date);
97 std::swap(ValidUntil, OldMetaIndex->ValidUntil);
98 std::swap(SupportsAcquireByHash, OldMetaIndex->SupportsAcquireByHash);
99 std::swap(LoadedSuccessfully, OldMetaIndex->LoadedSuccessfully);
100}
101 /*}}}*/