From 071c691a9a14d0263158b6141cf5ad26fd9736ae Mon Sep 17 00:00:00 2001 From: Scott Wheeler Date: Sun, 13 Aug 2006 15:25:48 +0000 Subject: [PATCH] Make removeField() actually remove the map content, not just empty the list. Also added an erase method to Map that works on keys rather than itterators. git-svn-id: svn://anonsvn.kde.org/home/kde/trunk/kdesupport/taglib@572681 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- ogg/xiphcomment.cpp | 2 +- toolkit/tmap.h | 5 +++++ toolkit/tmap.tcc | 8 ++++++++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/ogg/xiphcomment.cpp b/ogg/xiphcomment.cpp index 2de04cd5..5c99f957 100644 --- a/ogg/xiphcomment.cpp +++ b/ogg/xiphcomment.cpp @@ -202,7 +202,7 @@ void Ogg::XiphComment::removeField(const String &key, const String &value) } } else - d->fieldListMap[key].clear(); + d->fieldListMap.erase(key); } bool Ogg::XiphComment::contains(const String &key) const diff --git a/toolkit/tmap.h b/toolkit/tmap.h index 55731ee4..9daf979c 100644 --- a/toolkit/tmap.h +++ b/toolkit/tmap.h @@ -131,6 +131,11 @@ namespace TagLib { */ Map &erase(Iterator it); + /*! + * Erase the item with \a key from the list. + */ + Map &erase(const Key &key); + /*! * Returns a reference to the value associated with \a key. * diff --git a/toolkit/tmap.tcc b/toolkit/tmap.tcc index afb7db4c..e2755d6f 100644 --- a/toolkit/tmap.tcc +++ b/toolkit/tmap.tcc @@ -130,6 +130,14 @@ Map &Map::erase(Iterator it) return *this; } +template +Map &Map::erase(const Key &key) +{ + detach(); + d->map.erase(find(key)); + return *this; +} + template TagLib::uint Map::size() const { -- 2.40.0