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. */