Commits

shuerhaaken committed a56fa78

use integer returning function for disk number (API break)

Comments (0)

Files changed (17)

+commit fe5166489577e72e057220af65e19229017e9cb1
+Author: Jörn Magens <shuerhaaken@googlemail.com>
+Date:   Thu Mar 21 12:32:27 2013 +0100
+
+    remove unused code
+
 commit add746adb60bf7b9c63d6b1afe3e8152a595b809
 Author: Jörn Magens <shuerhaaken@googlemail.com>
 Date:   Thu Mar 21 12:10:01 2013 +0100

bindings/c/taginfo_c.cc

     return i->get_has_image();
 }
 
+// deprecated - do not use
 char * taginfo_info_get_disk_string(const TagInfo_Info *info) {
-    const Info *i = reinterpret_cast<const Info *>(info);
-    char *s = ::strdup(i->get_disk_string().toCString(true));
-    if(stringManagementEnabled)
-        strings.prepend(s);
-    return s;
+    return NULL;
 }
+// deprecated - do not use
 void taginfo_info_set_disk_string(TagInfo_Info *info, const char *disk_string) {
+}
+int taginfo_info_get_disk_number(const TagInfo_Info *info) {
+    const Info *i = reinterpret_cast<const Info *>(info);
+    return i->get_disk_number();
+}
+void taginfo_info_set_disk_number(TagInfo_Info *info, int number) {
     Info *i = reinterpret_cast<Info *>(info);
-    i->set_disk_string(String(disk_string, String::UTF8));
+    i->set_disk_number(number);
 }
 
 BOOL taginfo_info_get_is_compilation(const TagInfo_Info *info) {

bindings/c/taginfo_c.h

 
 BOOL taginfo_info_get_has_image(const TagInfo_Info *info);
 
+// deprecated - do not use
 char *taginfo_info_get_disk_string(const TagInfo_Info *info);
+// deprecated - do not use
 void  taginfo_info_set_disk_string(TagInfo_Info *info, const char *disk_string);
 
+int taginfo_info_get_disk_number(const TagInfo_Info *info);
+void taginfo_info_set_disk_number(TagInfo_Info *info, int number);
+
 BOOL taginfo_info_get_is_compilation(const TagInfo_Info *info);
 void taginfo_info_set_is_compilation(TagInfo_Info *info, BOOL is_compilation);
 

bindings/vala/libtaginfo_c.vapi

 			[CCode (cname = "taginfo_info_set_is_compilation")]
 			set;
 		}
-		public string disk_string {
-			[CCode (cname = "taginfo_info_get_disk_string")]
+		public string disk_number {
+			[CCode (cname = "taginfo_info_get_disk_number")]
 			owned get;
-			[CCode (cname = "taginfo_info_set_disk_string")]
+			[CCode (cname = "taginfo_info_set_disk_number")]
 			set;
 		}
 		public int length {

libtaginfo/apeinfo.cc

                 composer = taglib_apetag->itemListMap()[APE_TAG_COMPOSER].toStringList().front();
             }
             if(taglib_apetag->itemListMap().contains(APE_TAG_DISKNO)) {
-                disk_string = taglib_apetag->itemListMap()[APE_TAG_DISKNO].toStringList().front();
+                disk_number = 
+                  atol(taglib_apetag->itemListMap()[APE_TAG_DISKNO].toStringList().front().toCString(false));
+                if(disk_number <= 0)
+                    disk_number = 1;
             }
             if(taglib_apetag->itemListMap().contains(APE_TAG_COMPILATION)) {
                 is_compilation = 
             // Rating
             if(taglib_apetag->itemListMap().contains(APE_TAG_RATING)) {
                 long rat = 0;
-                rat = 
-                    atol(taglib_apetag->itemListMap()[APE_TAG_RATING].toStringList().front().toCString(true));
+                rat = atol(taglib_apetag->itemListMap()[APE_TAG_RATING].toStringList().front().toCString(true));
                 if(rat) {
                     if(rat > 5) {
                         rating = popularity_to_rating(rat);
             if(changedflag & CHANGED_COMPOSER_TAG)
                 taglib_apetag->addValue(APE_TAG_COMPOSER, composer);
             if(changedflag & CHANGED_DISK_STR)
-                taglib_apetag->addValue(APE_TAG_DISKNO, disk_string);
+                taglib_apetag->addValue(APE_TAG_DISKNO, format("%u", disk_number));
             
             if(changedflag & CHANGED_IS_COMPILATION_TAG) {
                 if(is_compilation) {
                 taglib_apetag->addValue(APE_TAG_ALBUMARTIST, album_artist);
             
             if(changedflag & CHANGED_DATA_RATING) {
-//                char* str;
                 taglib_apetag->addValue(APE_TAG_RATING, format("%u", rating_to_popularity(rating)));
-                /*if(asprintf (&str, "%u", rating_to_popularity(rating)) >= 0) {
-                    taglib_apetag->addValue(APE_TAG_RATING, str);
-                    free (str);
-                    str = NULL;
-                }*/
                 taglib_apetag->addValue("PLAY_COUNTER", format("%u", playcount)); // TODO
-                
-//                if(asprintf (&str, "%u", playcount) >= 0) {
-//                    taglib_apetag->addValue("PLAY_COUNTER", str);
-//                    free (str);
-//                }
             }
             if(changedflag & CHANGED_TRACK_LABELS)
                 check_ape_label_frame(taglib_apetag, "TRACK_LABELS",  track_labels_string);

libtaginfo/asfinfo.cc

             read_virtual_tags((TagLib::Tag *)asf_tag);
             
             if(asf_tag->attributeListMap().contains("WM/PartOfSet")) {
-                disk_string = asf_tag->attributeListMap()[ "WM/PartOfSet" ].front().toString();
+                disk_number = 
+                    atol(asf_tag->attributeListMap()[ "WM/PartOfSet" ].front().toString().toCString(false));
+                if(disk_number <= 0)
+                    disk_number = 1;
             }
             if(asf_tag->attributeListMap().contains("WM/Composer")) {
                 composer = asf_tag->attributeListMap()[ "WM/Composer" ].front().toString();
         if(changedflag) {
             if(changedflag & CHANGED_DATA_DISK_STR) {
                 asf_tag->removeItem("WM/PartOfSet");
-                asf_tag->setAttribute("WM/PartOfSet", disk_string);
+                asf_tag->setAttribute("WM/PartOfSet", format("%u", disk_number));
             }
             if(changedflag & CHANGED_COMPOSER_TAG) {
                 asf_tag->removeItem("WM/Composer");

libtaginfo/flacinfo.cc

                 composer = xiphcomment->fieldListMap()["COMPOSER"].front();
             }
             if(xiphcomment->fieldListMap().contains("DISCNUMBER")) {
-                disk_string = xiphcomment->fieldListMap()["DISCNUMBER"].front();
+                disk_number = 
+                    atol(xiphcomment->fieldListMap()["DISCNUMBER"].front().toCString(false));
+                if(disk_number <= 0)
+                    disk_number = 1;
             }
             if(xiphcomment->fieldListMap().contains("COMPILATION")) {
                 is_compilation = xiphcomment->fieldListMap()["COMPILATION"].front() == String("1");
     if(xiphcomment) {
         if(changedflag) {
             if(changedflag & CHANGED_DATA_DISK_STR)
-                xiphcomment->addField("DISCNUMBER", disk_string);
+                xiphcomment->addField("DISCNUMBER", format("%u", disk_number));
             if(changedflag & CHANGED_COMPOSER_TAG)
                 xiphcomment->addField("COMPOSER", composer);
             

libtaginfo/info.cc

     is_compilation = false;
     has_image = false;
     
+    disk_number = 1;
+    
     valid = true; //TODO
     
     changedflag = CHANGED_DATA_NONE;
     return genre;
 }
 
-void Info::set_disk_string(String new_disk_string) {
-    disk_string = new_disk_string;
+
+void Info::set_disk_number(int number) {
+    disk_number = number;
     changedflag |= CHANGED_DISK_STR;
 }
-String Info::get_disk_string() const {
-    return disk_string;
+int Info::get_disk_number() const {
+    return disk_number;
 }
 
+
 void Info::set_artist(String new_artist) {
     artist = new_artist;
     changedflag |= CHANGED_ARTIST_TAG;

libtaginfo/mp3info.cc

             if(!taglib_tag)
                 read_virtual_tags((TagLib::Tag *)taglib_tagId3v2);
             if(taglib_tagId3v2->frameListMap().contains("TPOS")) {
-                disk_string = taglib_tagId3v2->frameListMap()[ "TPOS" ].front()->toString();
+                disk_number = 
+                    atol(taglib_tagId3v2->frameListMap()[ "TPOS" ].front()->toString().toCString(false));
+                if(disk_number <= 0)
+                    disk_number = 1;
             }
             if(taglib_tagId3v2->frameListMap().contains("TCOM")) {
                 composer = taglib_tagId3v2->frameListMap()[ "TCOM" ].front()->toString();
             if(changedflag & CHANGED_DATA_DISK_STR) {
                 taglib_tagId3v2->removeFrames("TPOS");
                 frame = new TagLib::ID3v2::TextIdentificationFrame("TPOS");
-                frame->setText(disk_string);
+                frame->setText(format("%u", disk_number));
                 taglib_tagId3v2->addFrame(frame);
             }
             if(changedflag & CHANGED_COMPOSER_TAG) {

libtaginfo/mp4info.cc

                 composer = mp4_tag->itemListMap()["\xa9wrt"].toStringList().front();
             }
             if(mp4_tag->itemListMap().contains("disk")) {
-                disk_string = format("%i/%i", mp4_tag->itemListMap()["disk"].toIntPair().first,
-                                           mp4_tag->itemListMap()["disk"].toIntPair().second);
+//                disk_string = format("%i/%i", mp4_tag->itemListMap()["disk"].toIntPair().first,
+//                                           mp4_tag->itemListMap()["disk"].toIntPair().second);
+                disk_number = mp4_tag->itemListMap()["disk"].toIntPair().first;
+                if(disk_number <= 0)
+                    disk_number = 1;
             }
             if(mp4_tag->itemListMap().contains("cpil")) {
                 is_compilation = mp4_tag->itemListMap()["cpil"].toBool();
             if(changedflag & CHANGED_COMPOSER_TAG)
                 mp4_tag->itemListMap()["\xA9wrt"] = TagLib::StringList(composer);
             if(changedflag & CHANGED_DATA_DISK_STR) {
-                int first;
-                int second;
-                string_disk_to_disk_num(disk_string.toCString(true), first, second);
-                mp4_tag->itemListMap()["disk"] = TagLib::MP4::Item(first, second);
+//                int first;
+//                int second;
+//                string_disk_to_disk_num(disk_string.toCString(true), first, second);
+                mp4_tag->itemListMap()["disk"] = TagLib::MP4::Item(disk_number, disk_number); //ignore amount
             }
             if(changedflag & CHANGED_IS_COMPILATION_TAG)
                 mp4_tag->itemListMap()["cpil"] = TagLib::MP4::Item(is_compilation);

libtaginfo/mpcinfo.cc

                 composer = taglib_apetag->itemListMap()["COMPOSER"].toStringList().front();
             }
             if(taglib_apetag->itemListMap().contains("DISCNUMBER")) {
-                disk_string = taglib_apetag->itemListMap()["DISCNUMBER"].toStringList().front();
+                disk_number = 
+                    atol(taglib_apetag->itemListMap()["DISCNUMBER"].toStringList().front().toCString(false));
+                if(disk_number <= 0)
+                    disk_number = 1;
             }
             if(taglib_apetag->itemListMap().contains("COMPILATION")) {
                 is_compilation = 
             if(changedflag & CHANGED_COMPOSER_TAG)
                 taglib_apetag->addValue("COMPOSER", composer);
             if(changedflag & CHANGED_DISK_STR)
-                taglib_apetag->addValue("DISCNUMBER", disk_string);
+                taglib_apetag->addValue("DISCNUMBER", format("%u", disk_number));
             
             if(changedflag & CHANGED_IS_COMPILATION_TAG) {
                 if(is_compilation) {

libtaginfo/ogginfo.cc

                 composer = xiphcomment->fieldListMap()["COMPOSER"].front();
             }
             if(xiphcomment->fieldListMap().contains("DISCNUMBER")) {
-                disk_string = xiphcomment->fieldListMap()["DISCNUMBER"].front();
+                disk_number = atol(xiphcomment->fieldListMap()["DISCNUMBER"].front().toCString(false));
+                if(disk_number < 1)
+                    disk_number = 1;
             }
             if(xiphcomment->fieldListMap().contains("COMPILATION")) {
                 is_compilation = xiphcomment->fieldListMap()["COMPILATION"].front() == String("1");
     if(xiphcomment) {
         if(changedflag) {
             if(changedflag & CHANGED_DATA_DISK_STR)
-                xiphcomment->addField("DISCNUMBER", disk_string);
+                xiphcomment->addField("DISCNUMBER", format("%u", disk_number));
             
             if(changedflag & CHANGED_COMPOSER_TAG)
                 xiphcomment->addField("COMPOSER", composer);

libtaginfo/speexinfo.cc

                 composer = xiphcomment->fieldListMap()["COMPOSER"].front();
             }
             if(xiphcomment->fieldListMap().contains("DISCNUMBER")) {
-                disk_string = xiphcomment->fieldListMap()["DISCNUMBER"].front();
+                disk_number = atol(xiphcomment->fieldListMap()["DISCNUMBER"].front().toCString(false));
+                if(disk_number < 1)
+                    disk_number = 1;
             }
             if(xiphcomment->fieldListMap().contains("COMPILATION")) {
                 is_compilation = xiphcomment->fieldListMap()["COMPILATION"].front() == String("1");
     if(xiphcomment) {
         if(changedflag) {
             if(changedflag & CHANGED_DATA_DISK_STR)
-                xiphcomment->addField("DISCNUMBER", disk_string);
+                xiphcomment->addField("DISCNUMBER", format("%u", disk_number));
             
             if(changedflag & CHANGED_COMPOSER_TAG)
                 xiphcomment->addField("COMPOSER", composer);

libtaginfo/taginfo.h

             String comments;
             int    tracknumber;
             int    year;
-            String disk_string;
             bool   is_compilation;
             
+            int disk_number;
+            
+            
             //Audioproperties
             int length_seconds;
             int bitrate;
             int  get_rating() const;
             void set_rating(int new_rating);
             
-            String get_disk_string() const;
-            void   set_disk_string(String new_disk_string);
+            int  get_disk_number() const;
+            void set_disk_number(int number);
             
             bool get_has_image() const;
             

libtaginfo/trueaudioinfo.cc

             if(!taglib_tag)
                 read_virtual_tags((TagLib::Tag *)taglib_tagId3v2);
             if(taglib_tagId3v2->frameListMap().contains("TPOS")) {
-                disk_string = taglib_tagId3v2->frameListMap()[ "TPOS" ].front()->toString();
+                disk_number = 
+                    atol(taglib_tagId3v2->frameListMap()[ "TPOS" ].front()->toString().toCString(false));
+                if(disk_number < 1)
+                    disk_number = 1;
             }
             if(taglib_tagId3v2->frameListMap().contains("TCOM")) {
                 composer = taglib_tagId3v2->frameListMap()[ "TCOM" ].front()->toString();
             if(changedflag & CHANGED_DATA_DISK_STR) {
                 taglib_tagId3v2->removeFrames("TPOS");
                 frame = new TagLib::ID3v2::TextIdentificationFrame("TPOS");
-                frame->setText(disk_string);
+                frame->setText(format("%u", disk_number));
                 taglib_tagId3v2->addFrame(frame);
             }
             if(changedflag & CHANGED_COMPOSER_TAG) {

libtaginfo/waveinfo.cc

             if(!taglib_tag)
                 read_virtual_tags((TagLib::Tag *)taglib_tagId3v2);
             if(taglib_tagId3v2->frameListMap().contains("TPOS")) {
-                disk_string = taglib_tagId3v2->frameListMap()[ "TPOS" ].front()->toString();
+                disk_number = 
+                    atol(taglib_tagId3v2->frameListMap()[ "TPOS" ].front()->toString().toCString(false));
+                if(disk_number < 1)
+                    disk_number = 1;
             }
             if(taglib_tagId3v2->frameListMap().contains("TCOM")) {
                 composer = taglib_tagId3v2->frameListMap()[ "TCOM" ].front()->toString();
             if(changedflag & CHANGED_DATA_DISK_STR) {
                 taglib_tagId3v2->removeFrames("TPOS");
                 frame = new TagLib::ID3v2::TextIdentificationFrame("TPOS");
-                frame->setText(disk_string);
+                frame->setText(format("%u", disk_number));
                 taglib_tagId3v2->addFrame(frame);
             }
             if(changedflag & CHANGED_COMPOSER_TAG) {

libtaginfo/wavpackinfo.cc

                 composer = taglib_apetag->itemListMap()["COMPOSER"].toStringList().front();
             }
             if(taglib_apetag->itemListMap().contains("DISCNUMBER")) {
-                disk_string = taglib_apetag->itemListMap()["DISCNUMBER"].toStringList().front();
+                disk_number = 
+                    atol(taglib_apetag->itemListMap()["DISCNUMBER"].toStringList().front().toCString(false));
+                if(disk_number < 1)
+                    disk_number = 1;
             }
             if(taglib_apetag->itemListMap().contains("COMPILATION")) {
                 is_compilation = taglib_apetag->itemListMap()["COMPILATION"].toStringList().front() == String("1");
             if(changedflag & CHANGED_COMPOSER_TAG)
                 taglib_apetag->addValue("COMPOSER", composer);
             if(changedflag & CHANGED_DATA_DISK_STR)
-                taglib_apetag->addValue("DISCNUMBER", disk_string);
+                taglib_apetag->addValue("DISCNUMBER", format("%u", disk_number));
             
             if(changedflag & CHANGED_IS_COMPILATION_TAG) {
                 if(is_compilation) {