From 953b8a119a76c92473b3eb5f085ab58aff9e648c Mon Sep 17 00:00:00 2001 From: Scott Wheeler Date: Sun, 13 Aug 2006 15:19:36 +0000 Subject: [PATCH] Add a simple function for checking for membership in the fieldListMap. git-svn-id: svn://anonsvn.kde.org/home/kde/trunk/kdesupport/taglib@572680 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- ogg/xiphcomment.cpp | 5 +++++ ogg/xiphcomment.h | 7 +++++++ 2 files changed, 12 insertions(+) diff --git a/ogg/xiphcomment.cpp b/ogg/xiphcomment.cpp index e1fe67af..2de04cd5 100644 --- a/ogg/xiphcomment.cpp +++ b/ogg/xiphcomment.cpp @@ -205,6 +205,11 @@ void Ogg::XiphComment::removeField(const String &key, const String &value) d->fieldListMap[key].clear(); } +bool Ogg::XiphComment::contains(const String &key) const +{ + return d->fieldListMap.contains(key) && !d->fieldListMap[key].isEmpty(); +} + ByteVector Ogg::XiphComment::render() const { return render(true); diff --git a/ogg/xiphcomment.h b/ogg/xiphcomment.h index dbcde9d5..b94b565d 100644 --- a/ogg/xiphcomment.h +++ b/ogg/xiphcomment.h @@ -156,6 +156,13 @@ namespace TagLib { */ void removeField(const String &key, const String &value = String::null); + /*! + * Returns true if the field is contained within the comment. + * + * \note This is safer than checking for membership in the FieldListMap. + */ + bool contains(const String &key) const; + /*! * Renders the comment to a ByteVector suitable for inserting into a file. */