using namespace TagLib;
+namespace
+{
+ typedef Ogg::FieldListMap::Iterator FieldIterator;
+ typedef Ogg::FieldListMap::ConstIterator FieldConstIterator;
-typedef List<FLAC::Picture *> PictureList;
+ typedef List<FLAC::Picture *> PictureList;
+ typedef PictureList::Iterator PictureIterator;
+ typedef PictureList::Iterator PictureConstIterator;
+}
class Ogg::XiphComment::XiphCommentPrivate
{
public:
+ XiphCommentPrivate()
+ {
+ pictureList.setAutoDelete(true);
+ }
+
FieldListMap fieldListMap;
String vendorID;
String commentField;
// public members
////////////////////////////////////////////////////////////////////////////////
-Ogg::XiphComment::XiphComment() : TagLib::Tag()
+Ogg::XiphComment::XiphComment() :
+ TagLib::Tag(),
+ d(new XiphCommentPrivate())
{
- d = new XiphCommentPrivate;
}
-Ogg::XiphComment::XiphComment(const ByteVector &data) : TagLib::Tag()
+Ogg::XiphComment::XiphComment(const ByteVector &data) :
+ TagLib::Tag(),
+ d(new XiphCommentPrivate())
{
- d = new XiphCommentPrivate;
parse(data);
}
Ogg::XiphComment::~XiphComment()
{
- removePictures();
delete d;
}
bool Ogg::XiphComment::isEmpty() const
{
- FieldListMap::ConstIterator it = d->fieldListMap.begin();
- for(; it != d->fieldListMap.end(); ++it)
+ for(FieldConstIterator it = d->fieldListMap.begin(); it != d->fieldListMap.end(); ++it) {
if(!(*it).second.isEmpty())
return false;
+ }
return true;
}
{
uint count = 0;
- FieldListMap::ConstIterator it = d->fieldListMap.begin();
- for(; it != d->fieldListMap.end(); ++it)
+ for(FieldConstIterator it = d->fieldListMap.begin(); it != d->fieldListMap.end(); ++it)
count += (*it).second.size();
count += d->pictureList.size();
{
// check which keys are to be deleted
StringList toRemove;
- for(FieldListMap::ConstIterator it = d->fieldListMap.begin(); it != d->fieldListMap.end(); ++it)
+ for(FieldConstIterator it = d->fieldListMap.begin(); it != d->fieldListMap.end(); ++it)
if (!properties.contains(it->first))
toRemove.append(it->first);
void Ogg::XiphComment::removePicture(FLAC::Picture *picture, bool del)
{
- PictureList::Iterator it = d->pictureList.find(picture);
+ PictureIterator it = d->pictureList.find(picture);
if(it != d->pictureList.end())
d->pictureList.erase(it);
void Ogg::XiphComment::removePictures()
{
- PictureList newList;
- for(uint i = 0; i < d->pictureList.size(); i++) {
- delete d->pictureList[i];
- }
- d->pictureList = newList;
+ d->pictureList.clear();
}
void Ogg::XiphComment::addPicture(FLAC::Picture * picture)
d->pictureList.append(picture);
}
-
List<FLAC::Picture *> Ogg::XiphComment::pictureList()
{
return d->pictureList;
}
}
- for(PictureList::ConstIterator it = d->pictureList.begin(); it != d->pictureList.end(); ++it) {
+ for(PictureConstIterator it = d->pictureList.begin(); it != d->pictureList.end(); ++it) {
ByteVector picture = (*it)->render().toBase64();
data.append(ByteVector::fromUInt(picture.size() + 23, false));
data.append("METADATA_BLOCK_PICTURE=");