From f105aaba433f5a8b9c4326dd0d704501bf07d1e5 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Thu, 6 Nov 2014 12:53:59 +0100 Subject: 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). --- apt-pkg/metaindex.cc | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 apt-pkg/metaindex.cc (limited to 'apt-pkg/metaindex.cc') 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 +#include + +#include + +#include +#include + /*}}}*/ + +#if (APT_PKG_MAJOR >= 4 && APT_PKG_MINOR >= 13) +std::string metaIndex::LocalFileName() const { return ""; } +#else +#include +std::string metaIndex::LocalFileName() const +{ + debReleaseIndex const * deb = dynamic_cast(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::iterator I = (*Indexes).begin(); + I != (*Indexes).end(); ++I) + delete *I; + delete Indexes; +} -- cgit v1.2.3