]>
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 | ||
1dd20368 DK |
6 | #include <apt-pkg/debmetaindex.h> |
7 | ||
f105aaba DK |
8 | #include <string> |
9 | #include <vector> | |
10 | /*}}}*/ | |
11 | ||
b07aeb1a DK |
12 | std::string metaIndex::Describe() const |
13 | { | |
14 | return "Release"; | |
15 | } | |
16 | ||
3fd89e62 | 17 | pkgCache::RlsFileIterator metaIndex::FindInCache(pkgCache &Cache, bool const) const |
b07aeb1a DK |
18 | { |
19 | return pkgCache::RlsFileIterator(Cache); | |
20 | } | |
21 | ||
22 | bool metaIndex::Merge(pkgCacheGenerator &Gen,OpProgress *) const | |
23 | { | |
24 | return Gen.SelectReleaseFile("", ""); | |
25 | } | |
26 | ||
f105aaba DK |
27 | metaIndex::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 | ||
35 | metaIndex::~metaIndex() | |
36 | { | |
830a1b8c DK |
37 | if (Indexes != 0) |
38 | { | |
39 | for (std::vector<pkgIndexFile *>::iterator I = (*Indexes).begin(); | |
40 | I != (*Indexes).end(); ++I) | |
41 | delete *I; | |
42 | delete Indexes; | |
43 | } | |
44 | for (auto const &E: Entries) | |
45 | delete E.second; | |
f105aaba | 46 | } |
5ad0096a DK |
47 | |
48 | // one line Getters for public fields /*{{{*/ | |
49 | APT_PURE std::string metaIndex::GetURI() const { return URI; } | |
50 | APT_PURE std::string metaIndex::GetDist() const { return Dist; } | |
51 | APT_PURE const char* metaIndex::GetType() const { return Type; } | |
52 | APT_PURE metaIndex::TriState metaIndex::GetTrusted() const { return Trusted; } | |
b0d40854 | 53 | APT_PURE std::string metaIndex::GetSignedBy() const { return SignedBy; } |
5ad0096a DK |
54 | APT_PURE std::string metaIndex::GetCodename() const { return Codename; } |
55 | APT_PURE std::string metaIndex::GetSuite() const { return Suite; } | |
56 | APT_PURE bool metaIndex::GetSupportsAcquireByHash() const { return SupportsAcquireByHash; } | |
57 | APT_PURE time_t metaIndex::GetValidUntil() const { return ValidUntil; } | |
58 | APT_PURE time_t metaIndex::GetDate() const { return this->Date; } | |
59 | APT_PURE metaIndex::TriState metaIndex::GetLoadedSuccessfully() const { return LoadedSuccessfully; } | |
60 | ||
61 | APT_PURE bool metaIndex::CheckDist(string const &MaybeDist) const | |
62 | { | |
63 | return (this->Codename == MaybeDist | |
64 | || this->Suite == MaybeDist); | |
65 | } | |
66 | APT_PURE std::string metaIndex::GetExpectedDist() const | |
67 | { | |
d96c997e | 68 | return Dist; |
5ad0096a DK |
69 | } |
70 | /*}}}*/ | |
71 | APT_PURE metaIndex::checkSum *metaIndex::Lookup(string const &MetaKey) const /*{{{*/ | |
72 | { | |
73 | std::map<std::string, metaIndex::checkSum* >::const_iterator sum = Entries.find(MetaKey); | |
74 | if (sum == Entries.end()) | |
75 | return NULL; | |
76 | return sum->second; | |
77 | } | |
78 | /*}}}*/ | |
79 | APT_PURE bool metaIndex::Exists(string const &MetaKey) const /*{{{*/ | |
80 | { | |
81 | return Entries.find(MetaKey) != Entries.end(); | |
82 | } | |
83 | /*}}}*/ | |
84 | std::vector<std::string> metaIndex::MetaKeys() const /*{{{*/ | |
85 | { | |
86 | std::vector<std::string> keys; | |
87 | std::map<string,checkSum *>::const_iterator I = Entries.begin(); | |
88 | while(I != Entries.end()) { | |
89 | keys.push_back((*I).first); | |
90 | ++I; | |
91 | } | |
92 | return keys; | |
93 | } | |
94 | /*}}}*/ | |
95 | void metaIndex::swapLoad(metaIndex * const OldMetaIndex) /*{{{*/ | |
96 | { | |
97 | std::swap(Entries, OldMetaIndex->Entries); | |
98 | std::swap(Date, OldMetaIndex->Date); | |
99 | std::swap(ValidUntil, OldMetaIndex->ValidUntil); | |
100 | std::swap(SupportsAcquireByHash, OldMetaIndex->SupportsAcquireByHash); | |
101 | std::swap(LoadedSuccessfully, OldMetaIndex->LoadedSuccessfully); | |
102 | } | |
103 | /*}}}*/ | |
1dd20368 DK |
104 | |
105 | bool metaIndex::IsArchitectureSupported(std::string const &arch) const /*{{{*/ | |
106 | { | |
107 | debReleaseIndex const * const deb = dynamic_cast<debReleaseIndex const *>(this); | |
108 | if (deb != NULL) | |
109 | return deb->IsArchitectureSupported(arch); | |
110 | return true; | |
111 | } | |
112 | /*}}}*/ | |
a628ca52 DK |
113 | bool metaIndex::IsArchitectureAllSupportedFor(IndexTarget const &target) const/*{{{*/ |
114 | { | |
115 | debReleaseIndex const * const deb = dynamic_cast<debReleaseIndex const *>(this); | |
116 | if (deb != NULL) | |
117 | return deb->IsArchitectureAllSupportedFor(target); | |
118 | return true; | |
119 | } | |
120 | /*}}}*/ |