This commit is contained in:
Lukáš Lalinský
2012-03-17 10:41:02 +01:00
61 changed files with 2332 additions and 7 deletions

View File

@ -27,9 +27,11 @@
#include <tstring.h>
#include <tdebug.h>
#include <tpropertymap.h>
#include "vorbisfile.h"
using namespace TagLib;
class Vorbis::File::FilePrivate
@ -85,6 +87,16 @@ Ogg::XiphComment *Vorbis::File::tag() const
return d->comment;
}
PropertyMap Vorbis::File::properties() const
{
return d->comment->properties();
}
PropertyMap Vorbis::File::setProperties(const PropertyMap &properties)
{
return d->comment->setProperties(properties);
}
Vorbis::Properties *Vorbis::File::audioProperties() const
{
return d->properties;

View File

@ -90,6 +90,19 @@ namespace TagLib {
*/
virtual Ogg::XiphComment *tag() const;
/*!
* Implements the unified property interface -- export function.
* This forwards directly to XiphComment::properties().
*/
PropertyMap properties() const;
/*!
* Implements the unified tag dictionary interface -- import function.
* Like properties(), this is a forwarder to the file's XiphComment.
*/
PropertyMap setProperties(const PropertyMap &);
/*!
* Returns the Vorbis::Properties for this file. If no audio properties
* were read then this will return a null pointer.

View File

@ -27,6 +27,7 @@
#include <tdebug.h>
#include <xiphcomment.h>
#include <tpropertymap.h>
using namespace TagLib;
@ -188,6 +189,44 @@ const Ogg::FieldListMap &Ogg::XiphComment::fieldListMap() const
return d->fieldListMap;
}
PropertyMap Ogg::XiphComment::properties() const
{
return d->fieldListMap;
}
PropertyMap Ogg::XiphComment::setProperties(const PropertyMap &properties)
{
// check which keys are to be deleted
StringList toRemove;
for(FieldListMap::ConstIterator it = d->fieldListMap.begin(); it != d->fieldListMap.end(); ++it)
if (!properties.contains(it->first))
toRemove.append(it->first);
for(StringList::ConstIterator it = toRemove.begin(); it != toRemove.end(); ++it)
removeField(*it);
// 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(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(it->first);
else {
// replace all strings in the list for the tag
StringList::ConstIterator valueIterator = sl.begin();
addField(it->first, *valueIterator, true);
++valueIterator;
for(; valueIterator != sl.end(); ++valueIterator)
addField(it->first, *valueIterator, false);
}
}
}
return PropertyMap();
}
String Ogg::XiphComment::vendorID() const
{
return d->vendorID;

View File

@ -140,6 +140,21 @@ namespace TagLib {
*/
const FieldListMap &fieldListMap() const;
/*!
* 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 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).
*/
PropertyMap properties() const;
/*!
* Implements the unified property interface -- import function.
* The tags from the given map will be stored one-to-one in the file.
*/
PropertyMap setProperties(const PropertyMap&);
/*!
* Returns the vendor ID of the Ogg Vorbis encoder. libvorbis 1.0 as the
* most common case always returns "Xiph.Org libVorbis I 20020717".