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