]> granicus.if.org Git - taglib/commitdiff
Update for pull request #89: Change how setProperties() updates tags.
authorMichael Helmling <supermihi@web.de>
Thu, 20 Dec 2012 16:28:50 +0000 (17:28 +0100)
committerMichael Helmling <supermihi@web.de>
Thu, 20 Dec 2012 16:28:50 +0000 (17:28 +0100)
For file types supporting more than one tag format, setProperties() now always creates the most modern one. Deprecated tags are stripped.

13 files changed:
taglib/ape/apefile.cpp
taglib/ape/apefile.h
taglib/flac/flacfile.cpp
taglib/flac/flacfile.h
taglib/mpc/mpcfile.cpp
taglib/mpc/mpcfile.h
taglib/mpeg/mpegfile.cpp
taglib/mpeg/mpegfile.h
taglib/toolkit/tfile.h
taglib/trueaudio/trueaudiofile.cpp
taglib/trueaudio/trueaudiofile.h
taglib/wavpack/wavpackfile.cpp
taglib/wavpack/wavpackfile.h

index fae4ab033cddb881c0d14431edd236dc2241268b..7cc1c54de67dfb928b40bbdd3d0342710b7d2cee 100644 (file)
@@ -131,12 +131,9 @@ void APE::File::removeUnsupportedProperties(const StringList &properties)
 
 PropertyMap APE::File::setProperties(const PropertyMap &properties)
 {
-  PropertyMap result;
   if(d->hasID3v1)
-    result = d->tag.access<ID3v1::Tag>(ApeID3v1Index, false)->setProperties(properties);
-  if(d->hasAPE || !d->hasID3v1)
-    result = d->tag.access<APE::Tag>(ApeAPEIndex, true)->setProperties(properties);
-  return result;
+    strip(ID3v1);
+  return d->tag.access<APE::Tag>(ApeAPEIndex, true)->setProperties(properties);
 }
 
 APE::Properties *APE::File::audioProperties() const
index 7be0f21da50d80b8f868349a63178bf4f2fd7483..df335ec6e58154d7f16eee70b15d75b71194142e 100644 (file)
@@ -128,8 +128,9 @@ namespace TagLib {
 
       /*!
        * Implements the unified property interface -- import function.
-       * As for the export, only one tag is taken into account. If the file
-       * has no tag at all, APE will be created.
+       * Creates an APEv2 tag if necessary. A pontentially existing ID3v1
+       * tag is considered deprecated and will be removed, invalidating all
+       * pointers to that tag.
        */
       PropertyMap setProperties(const PropertyMap &);
 
index 26d799747b6a344bc68800f20922a8ec712f9551..93f8bd7bb7a131f2009d447df17cd073eae31bb3 100644 (file)
@@ -168,14 +168,11 @@ void FLAC::File::removeUnsupportedProperties(const StringList &unsupported)
 
 PropertyMap FLAC::File::setProperties(const PropertyMap &properties)
 {
-  PropertyMap result;
   if(d->hasID3v1)
-      result = d->tag.access<ID3v1::Tag>(FlacID3v1Index, false)->setProperties(properties);
+      d->tag.access<ID3v1::Tag>(FlacID3v1Index, false)->setProperties(properties);
   if(d->hasID3v2)
-      result = d->tag.access<ID3v2::Tag>(FlacID3v2Index, false)->setProperties(properties);
-  if(d->hasXiphComment || !(d->hasID3v1 || d->hasID3v2))
-    result = d->tag.access<Ogg::XiphComment>(FlacXiphIndex, true)->setProperties(properties);
-  return result;
+      d->tag.access<ID3v2::Tag>(FlacID3v2Index, false)->setProperties(properties);
+  return d->tag.access<Ogg::XiphComment>(FlacXiphIndex, true)->setProperties(properties);
 }
 
 FLAC::Properties *FLAC::File::audioProperties() const
index 716d4478ccec0a05be5a8070a93b9aa6b36e14c2..76f2e2d3fca47a4545f8b3971e5848dd45e7e906 100644 (file)
@@ -133,8 +133,9 @@ namespace TagLib {
 
       /*!
        * Implements the unified property interface -- import function.
-       * As with the export, only one tag is taken into account. If the file
-       * has no tag at all, a XiphComment will be created.
+       * This always creates a Xiph comment, if none exists. The return value
+       * relates to the Xiph comment only.
+       * Potential ID3v1 and ID3v2 tags will also be updated.
        */
       PropertyMap setProperties(const PropertyMap &);
 
index 6d6b3f6bef8ca03d4718d4bf3a8d5383930207b7..c6cb3a410636d7d7c4aef55d2809b9ea02290fbb 100644 (file)
@@ -135,12 +135,9 @@ void MPC::File::removeUnsupportedProperties(const StringList &properties)
 
 PropertyMap MPC::File::setProperties(const PropertyMap &properties)
 {
-  PropertyMap result;
   if(d->hasID3v1)
-    result = d->tag.access<ID3v1::Tag>(MPCID3v1Index, false)->setProperties(properties);
-  if(d->hasAPE || !d->hasID3v1)
-    result = d->tag.access<APE::Tag>(MPCAPEIndex, true)->setProperties(properties);
-  return result;
+    strip(ID3v1);
+  return d->tag.access<APE::Tag>(MPCAPEIndex, true)->setProperties(properties);
 }
 
 MPC::Properties *MPC::File::audioProperties() const
index 167b768e1eab5d6b49af98bac6908e6476d53a13..b484be708631c287b7b61aff05a055dacb3c2f23 100644 (file)
@@ -124,8 +124,8 @@ namespace TagLib {
 
       /*!
        * Implements the unified property interface -- import function.
-       * As with the export, only one tag is taken into account. If the file
-       * has no tag at all, an APE tag will be created.
+       * Affects only the APEv2 tag which will be created if necessary.
+       * If an ID3v1 tag exists, it will be stripped from the file.
        */
       PropertyMap setProperties(const PropertyMap &);
 
index 907540076b1d4a15905a15ae65b88aaf24e9e8ff..fd7223c7cbff1dc1b882a5489de0d5cd8463e587 100644 (file)
@@ -159,14 +159,12 @@ void MPEG::File::removeUnsupportedProperties(const StringList &properties)
 
 PropertyMap MPEG::File::setProperties(const PropertyMap &properties)
 {
-  PropertyMap result;
-  if(d->hasID3v1)
-      result = d->tag.access<ID3v1::Tag>(ID3v1Index, false)->setProperties(properties);
   if(d->hasAPE)
-      result = d->tag.access<APE::Tag>(APEIndex, false)->setProperties(properties);
-  if(d->hasID3v2 || !(d->hasID3v1 || d->hasAPE))
-    result = d->tag.access<ID3v2::Tag>(ID3v2Index, true)->setProperties(properties);
-  return result;
+    strip(APE, true);
+  if(d->hasID3v1)
+    // update ID3v1 tag if it exists, but ignore the return value
+    d->tag.access<ID3v1::Tag>(ID3v1Index, false)->setProperties(properties);
+  return d->tag.access<ID3v2::Tag>(ID3v2Index, true)->setProperties(properties);
 }
 
 MPEG::Properties *MPEG::File::audioProperties() const
index f7b98364f34a05f1a243b96a094ef91240a6f828..08415d5503f3879ee6768c84890b011bdeaf6caa 100644 (file)
@@ -133,7 +133,7 @@ namespace TagLib {
       virtual Tag *tag() const;
 
       /*!
-       * Implements the unified property interface -- export function.
+       * Implements the reading part of the unified property interface.
        * If the file contains more than one tag, only the
        * first one (in the order ID3v2, APE, ID3v1) will be converted to the
        * PropertyMap.
@@ -143,9 +143,14 @@ namespace TagLib {
       void removeUnsupportedProperties(const StringList &properties);
 
       /*!
-       * Implements the unified tag dictionary interface -- import function.
-       * As with the export, only one tag is taken into account. If the file
-       * has no tag at all, ID3v2 will be created.
+       * Implements the writing part of the unified tag dictionary interface.
+       * In order to avoid problems with deprecated tag formats, this method
+       * always creates an ID3v2 tag if necessary, and removes potential APEv2
+       * tags (also invalidating all pointers to the APE tag) which are
+       * considered bad practice in MP3 files.
+       * If an ID3v1 tag  exists, it will be updated as well, within the
+       * limitations of that format.
+       * The returned PropertyMap refers to the ID3v2 tag only.
        */
       PropertyMap setProperties(const PropertyMap &);
 
index 7e6f2b9369cea060745a52de6f88f6e43ba821b1..4b231d06bdf260a39985e6842a89e4c7341e29e1 100644 (file)
@@ -80,8 +80,8 @@ namespace TagLib {
 
     /*!
      * Exports the tags of the file as dictionary mapping (human readable) tag
-     * names (Strings) to StringLists of tag values. Calls the according specialization
-     * in the File subclasses.
+     * names (uppercase Strings) to StringLists of tag values. Calls the according
+     * specialization in the File subclasses.
      * For each metadata object of the file that could not be parsed into the PropertyMap
      * format, the returend map's unsupportedData() list will contain one entry identifying
      * that object (e.g. the frame type for ID3v2 tags). Use removeUnsupportedProperties()
@@ -105,6 +105,10 @@ namespace TagLib {
      * If some value(s) could not be written imported to the specific metadata format,
      * the returned PropertyMap will contain those value(s). Otherwise it will be empty,
      * indicating that no problems occured.
+     * With file types that support several tag formats (for instance, MP3 files can have
+     * ID3v1, ID3v2, and APEv2 tags), this function will create the most appropriate one
+     * and may remove deprecated ones (mostly ID3v1). See the documentation of the 
+     * subclass implementations for detailed descriptions.
      * BIC: will become pure virtual in the future
      */
     PropertyMap setProperties(const PropertyMap &properties);
index 6af72aaa7d74921e34869cd61e10605ffc17e55d..85e5a21b2b079f7f968027e72b550888e2652595 100644 (file)
@@ -141,12 +141,9 @@ PropertyMap TrueAudio::File::properties() const
 
 PropertyMap TrueAudio::File::setProperties(const PropertyMap &properties)
 {
-  PropertyMap result;
   if(d->hasID3v1)
-    result = d->tag.access<ID3v1::Tag>(TrueAudioID3v1Index, false)->setProperties(properties);
-  if(d->hasID3v2 || !d->hasID3v1)
-    result =d->tag.access<ID3v2::Tag>(TrueAudioID3v2Index, true)->setProperties(properties);
-  return result;
+    d->tag.access<ID3v1::Tag>(TrueAudioID3v1Index, false)->setProperties(properties);
+  return d->tag.access<ID3v2::Tag>(TrueAudioID3v2Index, true)->setProperties(properties);
 }
 
 TrueAudio::Properties *TrueAudio::File::audioProperties() const
index e3e1fe62829522bdc3663a0e60c1b343708f8c18..1b8a93536820a52c79aa3d0a730568698a95fdc8 100644 (file)
@@ -139,8 +139,8 @@ namespace TagLib {
 
       /*!
        * Implements the unified property interface -- import function.
-       * As with the export, only one tag is taken into account. If the file
-       * has no tag at all, ID3v2 will be created.
+       * Creates in ID3v2 tag if necessary. If an ID3v1 tag exists, it will
+       * be updated as well, within the limitations of ID3v1.
        */
       PropertyMap setProperties(const PropertyMap &);
 
index 6cc86527bdfcdd9f33dc254d40d175bddc3f457b..67be997c4dd669a7d49a8e1a296678f9f48d9818 100644 (file)
@@ -119,12 +119,9 @@ PropertyMap WavPack::File::properties() const
 
 PropertyMap WavPack::File::setProperties(const PropertyMap &properties)
 {
-  PropertyMap result;
   if(d->hasID3v1)
-    result = d->tag.access<ID3v1::Tag>(WavID3v1Index, false)->setProperties(properties);
-  if(d->hasAPE || !d->hasID3v1)
-    result = d->tag.access<APE::Tag>(WavAPEIndex, true)->setProperties(properties);
-  return result;
+    strip(ID3v1);
+  return d->tag.access<APE::Tag>(WavAPEIndex, true)->setProperties(properties);
 }
 
 WavPack::Properties *WavPack::File::audioProperties() const
index 5bbbc65a190c3ac3ea5575661fc88560a4fd67e7..3e0c36c487e3cd56deaf1669e0443fbca11d90e4 100644 (file)
@@ -118,8 +118,8 @@ namespace TagLib {
 
       /*!
        * Implements the unified property interface -- import function.
-       * As for the export, only one tag is taken into account. If the file
-       * has no tag at all, APE will be created.
+       * Creates an APE tag if it does not exists and calls setProperties() on
+       * that. Any existing ID3v1 tag will be removed.
        */
       PropertyMap setProperties(const PropertyMap&);