Ok, think I've got this all sorted out a bit. Code is much simpler now,

though much of this could be moved into the base class as there's a lot
of copy-paste action going on.


git-svn-id: svn://anonsvn.kde.org/home/kde/trunk/kdesupport/taglib@768992 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
This commit is contained in:
Scott Wheeler
2008-01-31 05:46:13 +00:00
parent 6f6ec8d7de
commit 37e2d6293f
8 changed files with 154 additions and 499 deletions

View File

@ -49,22 +49,10 @@ namespace TagLib {
virtual ~TagUnion();
/*!
* Simply returns the value for the the tag at \a index.
*
* \note This does not call tag()
*
* \see tag()
*/
Tag *operator[](int index) const;
Tag *tag(int index) const;
/*!
* By default just a call to operator[], but may be overridden if, for
* instance, it is desirable to create frames on write.
*/
virtual Tag *tag(int index, AccessType type = Read) const;
void setTag(int index, Tag *tag);
void set(int index, Tag *tag);
virtual String title() const;
virtual String artist() const;
@ -83,6 +71,15 @@ namespace TagLib {
virtual void setTrack(uint i);
virtual bool isEmpty() const;
template <class T> T *access(int index, bool create)
{
if(!create || tag(index))
return static_cast<T *>(tag(index));
set(index, new T);
return static_cast<T *>(tag(index));
}
private:
TagUnion(const Tag &);
TagUnion &operator=(const Tag &);