]> granicus.if.org Git - taglib/commitdiff
Add reading/writing ID3v1 genre in number
authorTsuda Kageyu <tsuda.kageyu@gmail.com>
Thu, 4 Oct 2012 10:23:10 +0000 (19:23 +0900)
committerTsuda Kageyu <tsuda.kageyu@gmail.com>
Thu, 4 Oct 2012 10:23:10 +0000 (19:23 +0900)
taglib/mpeg/id3v1/id3v1tag.cpp
taglib/mpeg/id3v1/id3v1tag.h

index e9eb47bf1f897abee03a3f926908f1642d81a8d0..9fc8cfd7d9dedffcecc0d10bd07eef69d427c948 100644 (file)
@@ -182,16 +182,26 @@ void ID3v1::Tag::setGenre(const String &s)
   d->genre = ID3v1::genreIndex(s);
 }
 
-void ID3v1::Tag::setYear(uint i)
+void ID3v1::Tag::setYear(TagLib::uint i)
 {
   d->year = i > 0 ? String::number(i) : String::null;
 }
 
-void ID3v1::Tag::setTrack(uint i)
+void ID3v1::Tag::setTrack(TagLib::uint i)
 {
   d->track = i < 256 ? i : 0;
 }
 
+TagLib::uint ID3v1::Tag::genreNumber() const
+{
+  return d->genre;
+}
+
+void ID3v1::Tag::setGenreNumber(TagLib::uint i)
+{
+  d->genre = i < 256 ? i : 255;
+}
+
 void ID3v1::Tag::setStringHandler(const StringHandler *handler)
 {
   if (handler)
index 9332d4dce5a2d2676f28f6935d78583332ec89a1..7b26d023e0c583dd260280b9a638a21b2fa41e34 100644 (file)
@@ -140,16 +140,31 @@ namespace TagLib {
       virtual String album() const;
       virtual String comment() const;
       virtual String genre() const;
-      virtual uint year() const;
-      virtual uint track() const;
+      virtual TagLib::uint year() const;
+      virtual TagLib::uint track() const;
 
       virtual void setTitle(const String &s);
       virtual void setArtist(const String &s);
       virtual void setAlbum(const String &s);
       virtual void setComment(const String &s);
       virtual void setGenre(const String &s);
-      virtual void setYear(uint i);
-      virtual void setTrack(uint i);
+      virtual void setYear(TagLib::uint i);
+      virtual void setTrack(TagLib::uint i);
+
+      /*!
+       * Returns the genre in number.
+       *
+       * /note Normally 255 indicates that this tag contains no genre.
+       */
+      TagLib::uint genreNumber() const;
+
+      /*!
+       * Sets the genre in number to \a i.
+       *
+       * /note Valid value is from 0 up to 255. Normally 255 indicates that
+       * this tag contains no genre.
+       */
+      void setGenreNumber(TagLib::uint i);
 
       /*!
        * Sets the string handler that decides how the ID3v1 data will be