From 771a5cd65e1bd857823bd82d273d25e2b121c28f Mon Sep 17 00:00:00 2001 From: Scott Wheeler Date: Sat, 10 Apr 2004 17:55:23 +0000 Subject: [PATCH] Adding accessors for the various tag type for FLAC tags (similar to those in MPEG::File). CCMAIL:Jorn Baayen git-svn-id: svn://anonsvn.kde.org/home/kde/trunk/kdesupport/taglib@302658 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- flac/flacfile.cpp | 34 +++++++++++++++++++++++++++++++ flac/flacfile.h | 52 ++++++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 83 insertions(+), 3 deletions(-) diff --git a/flac/flacfile.cpp b/flac/flacfile.cpp index 046eef54..50fa324b 100644 --- a/flac/flacfile.cpp +++ b/flac/flacfile.cpp @@ -24,6 +24,8 @@ #include #include +#include +#include #include "flacfile.h" #include "flactag.h" @@ -214,6 +216,38 @@ void FLAC::File::save() } +ID3v2::Tag *FLAC::File::ID3v2Tag(bool create) +{ + if(!create || d->ID3v2Tag) + return d->ID3v2Tag; + + // no ID3v2 tag exists and we've been asked to create one + + d->ID3v2Tag = new ID3v2::Tag; + return d->ID3v2Tag; +} + +ID3v1::Tag *FLAC::File::ID3v1Tag(bool create) +{ + if(!create || d->ID3v1Tag) + return d->ID3v1Tag; + + // no ID3v1 tag exists and we've been asked to create one + + d->ID3v1Tag = new ID3v1::Tag; + return d->ID3v1Tag; +} + +Ogg::XiphComment *FLAC::File::xiphComment(bool create) +{ + if(!create || d->comment) + return d->comment; + + // no XiphComment exists and we've been asked to create one + + d->comment = new Ogg::XiphComment; + return d->comment; +} void FLAC::File::setID3v2FrameFactory(const ID3v2::FrameFactory *factory) { d->ID3v2FrameFactory = factory; diff --git a/flac/flacfile.h b/flac/flacfile.h index 2096fe6f..81dc1810 100644 --- a/flac/flacfile.h +++ b/flac/flacfile.h @@ -29,7 +29,10 @@ namespace TagLib { class Tag; - namespace ID3v2 { class FrameFactory; } + + namespace ID3v2 { class FrameFactory; class Tag; } + namespace ID3v1 { class Tag; } + namespace Ogg { class XiphComment; } //! An implementation of FLAC metadata @@ -83,8 +86,12 @@ namespace TagLib { virtual ~File(); /*! - * Returns the Tag for this file. This will be a union of XiphComment - * with ID3v1 and ID3v2 tags. + * Returns the Tag for this file. This will be a union of XiphComment, + * ID3v1 and ID3v2 tags. + * + * \see ID3v2Tag() + * \see ID3v1Tag() + * \see XiphComment() */ virtual TagLib::Tag *tag() const; @@ -101,6 +108,45 @@ namespace TagLib { */ virtual void save(); + /*! + * Returns a pointer to the ID3v2 tag of the file. + * + * If \a create is false (the default) this will return a null pointer + * if there is no valid ID3v2 tag. If \a create is true it will create + * an ID3v2 tag if one does not exist. + * + * \note The Tag is still owned by the FLAC::File and should not be + * deleted by the user. It will be deleted when the file (object) is + * destroyed. + */ + ID3v2::Tag *ID3v2Tag(bool create = false); + + /*! + * Returns a pointer to the ID3v1 tag of the file. + * + * If \a create is false (the default) this will return a null pointer + * if there is no valid ID3v1 tag. If \a create is true it will create + * an ID3v1 tag if one does not exist. + * + * \note The Tag is still owned by the FLAC::File and should not be + * deleted by the user. It will be deleted when the file (object) is + * destroyed. + */ + ID3v1::Tag *ID3v1Tag(bool create = false); + + /*! + * Returns a pointer to the XiphComment for the file. + * + * If \a create is false (the default) this will return a null pointer + * if there is no valid XiphComment. If \a create is true it will create + * a XiphComment if one does not exist. + * + * \note The Tag is still owned by the FLAC::File and should not be + * deleted by the user. It will be deleted when the file (object) is + * destroyed. + */ + Ogg::XiphComment *xiphComment(bool create = false); + /*! * Set the ID3v2::FrameFactory to something other than the default. This * can be used to specify the way that ID3v2 frames will be interpreted