summaryrefslogtreecommitdiff
path: root/apt-pkg/metaindex.cc
diff options
context:
space:
mode:
authorDavid Kalnischkies <david@kalnischkies.de>2014-11-06 12:53:59 +0100
committerDavid Kalnischkies <david@kalnischkies.de>2014-11-08 14:26:00 +0100
commitf105aaba433f5a8b9c4326dd0d704501bf07d1e5 (patch)
treee614eea939eedd34bfcb37e42c60261d2f654d60 /apt-pkg/metaindex.cc
parent60b64ffc3468579183abc1bac0179943d782a52e (diff)
better non-virtual metaIndex.LocalFileName() implementation
We can't add a new virtual method without breaking the ABI, but we can freely add new methods, so for older ABIs we just implement this method with a dynamic_cast, so that clients can be more ignorant about the API here and especially don't need to pull a very dirty trick by assuming internal knowledge (like apt-get did here).
Diffstat (limited to 'apt-pkg/metaindex.cc')
-rw-r--r--apt-pkg/metaindex.cc40
1 files changed, 40 insertions, 0 deletions
diff --git a/apt-pkg/metaindex.cc b/apt-pkg/metaindex.cc
new file mode 100644
index 000000000..31a8ec009
--- /dev/null
+++ b/apt-pkg/metaindex.cc
@@ -0,0 +1,40 @@
+// Include Files /*{{{*/
+#include <apt-pkg/indexfile.h>
+#include <apt-pkg/metaindex.h>
+
+#include <stddef.h>
+
+#include <string>
+#include <vector>
+ /*}}}*/
+
+#if (APT_PKG_MAJOR >= 4 && APT_PKG_MINOR >= 13)
+std::string metaIndex::LocalFileName() const { return ""; }
+#else
+#include <apt-pkg/debmetaindex.h>
+std::string metaIndex::LocalFileName() const
+{
+ debReleaseIndex const * deb = dynamic_cast<debReleaseIndex const*>(this);
+ if (deb != NULL)
+ return deb->LocalFileName();
+
+ return "";
+}
+#endif
+
+metaIndex::metaIndex(std::string const &URI, std::string const &Dist,
+ char const * const Type)
+: Indexes(NULL), Type(Type), URI(URI), Dist(Dist), Trusted(false)
+{
+ /* nothing */
+}
+
+metaIndex::~metaIndex()
+{
+ if (Indexes == 0)
+ return;
+ for (std::vector<pkgIndexFile *>::iterator I = (*Indexes).begin();
+ I != (*Indexes).end(); ++I)
+ delete *I;
+ delete Indexes;
+}