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