mirror of
https://github.com/taglib/taglib.git
synced 2025-07-23 07:24:30 -04:00
fixed lots of bugs found by 'make'
This commit is contained in:
@ -27,9 +27,11 @@
|
||||
|
||||
#include <tstring.h>
|
||||
#include <tdebug.h>
|
||||
#include <tpropertymap.h>
|
||||
|
||||
#include "vorbisfile.h"
|
||||
|
||||
|
||||
using namespace TagLib;
|
||||
|
||||
class Vorbis::File::FilePrivate
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include <tdebug.h>
|
||||
|
||||
#include <xiphcomment.h>
|
||||
#include <tpropertymap.h>
|
||||
|
||||
using namespace TagLib;
|
||||
|
||||
@ -188,45 +189,42 @@ const Ogg::FieldListMap &Ogg::XiphComment::fieldListMap() const
|
||||
return d->fieldListMap;
|
||||
}
|
||||
|
||||
TagDict Ogg::XiphComment::toDict() const
|
||||
PropertyMap Ogg::XiphComment::properties() const
|
||||
{
|
||||
return d->fieldListMap;
|
||||
}
|
||||
|
||||
void Ogg::XiphComment::fromDict(const TagDict &tagDict)
|
||||
PropertyMap Ogg::XiphComment::setProperties(const PropertyMap &properties)
|
||||
{
|
||||
// check which keys are to be deleted
|
||||
StringList toRemove;
|
||||
FieldListMap::ConstIterator it = d->fieldListMap.begin();
|
||||
for(; it != d->fieldListMap.end(); ++it) {
|
||||
if (!tagDict.contains(it->first))
|
||||
toRemove.append(it->first);
|
||||
}
|
||||
for(FieldListMap::ConstIterator it = d->fieldListMap.begin(); it != d->fieldListMap.end(); ++it)
|
||||
if (!properties.contains(it->first))
|
||||
toRemove.append(it->first);
|
||||
|
||||
StringList::ConstIterator removeIt = toRemove.begin();
|
||||
for (; removeIt != toRemove.end(); ++removeIt)
|
||||
removeField(*removeIt);
|
||||
for(StringList::ConstIterator it = toRemove.begin(); it != toRemove.end(); ++it)
|
||||
removeField(*it);
|
||||
|
||||
/* now go through keys in tagDict and check that the values match those in the xiph comment */
|
||||
TagDict::ConstIterator tagIt = tagDict.begin();
|
||||
for (; tagIt != tagDict.end(); ++tagIt)
|
||||
// now go through keys in \a properties and check that the values match those in the xiph comment */
|
||||
PropertyMap::ConstIterator it = properties.begin();
|
||||
for(; it != properties.end(); ++it)
|
||||
{
|
||||
if (!d->fieldListMap.contains(tagIt->first) || !(tagIt->second == d->fieldListMap[tagIt->first])) {
|
||||
const StringList &sl = tagIt->second;
|
||||
if(sl.size() == 0) {
|
||||
if(!d->fieldListMap.contains(it->first) || !(it->second == d->fieldListMap[it->first])) {
|
||||
const StringList &sl = it->second;
|
||||
if(sl.size() == 0)
|
||||
// zero size string list -> remove the tag with all values
|
||||
removeField(tagIt->first);
|
||||
}
|
||||
removeField(it->first);
|
||||
else {
|
||||
// replace all strings in the list for the tag
|
||||
StringList::ConstIterator valueIterator = sl.begin();
|
||||
addField(tagIt->first, *valueIterator, true);
|
||||
addField(it->first, *valueIterator, true);
|
||||
++valueIterator;
|
||||
for(; valueIterator != sl.end(); ++valueIterator)
|
||||
addField(tagIt->first, *valueIterator, false);
|
||||
addField(it->first, *valueIterator, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
return PropertyMap();
|
||||
}
|
||||
|
||||
String Ogg::XiphComment::vendorID() const
|
||||
|
@ -141,19 +141,19 @@ namespace TagLib {
|
||||
const FieldListMap &fieldListMap() const;
|
||||
|
||||
/*!
|
||||
* Implements the unified tag dictionary interface -- export function.
|
||||
* Implements the unified property interface -- export function.
|
||||
* The result is a one-to-one match of the Xiph comment, since it is
|
||||
* completely compatible with the dictionary interface (in fact, a Xiph
|
||||
* completely compatible with the property interface (in fact, a Xiph
|
||||
* comment is nothing more than a map from tag names to list of values,
|
||||
* as is the dict interface).
|
||||
*/
|
||||
TagDict toDict() const;
|
||||
PropertyMap properties() const;
|
||||
|
||||
/*!
|
||||
* Implements the unified tag dictionary interface -- import function.
|
||||
* The tags from the given dict will be stored one-to-one in the file.
|
||||
* Implements the unified property interface -- import function.
|
||||
* The tags from the given map will be stored one-to-one in the file.
|
||||
*/
|
||||
void fromDict(const TagDict &);
|
||||
PropertyMap setProperties(const PropertyMap&);
|
||||
|
||||
/*!
|
||||
* Returns the vendor ID of the Ogg Vorbis encoder. libvorbis 1.0 as the
|
||||
|
Reference in New Issue
Block a user