Commits

shuerhaaken committed 4f21707

rename changed flag for dist str

Comments (0)

Files changed (17)

+commit a56fa78dc0f597093461030e35dc151e2e9b725e
+Author: Jörn Magens <shuerhaaken@googlemail.com>
+Date:   Thu Mar 21 13:42:26 2013 +0100
+
+    use integer returning function for disk number (API break)
+
 commit fe5166489577e72e057220af65e19229017e9cb1
 Author: Jörn Magens <shuerhaaken@googlemail.com>
 Date:   Thu Mar 21 12:32:27 2013 +0100
 Here are a few of them:
  - More unit tests
  - Do documentation
- - Add more queryable data to API or fully implement mappings 
-     (comments, user tags, ratings, cd number ...)
+ - Add individual changed flags for playcount and rating
 

bindings/vala/libtaginfo_c.vapi

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

libtaginfo/apeinfo.cc

         if(changedflag) {
             if(changedflag & CHANGED_COMPOSER_TAG)
                 taglib_apetag->addValue(APE_TAG_COMPOSER, composer);
-            if(changedflag & CHANGED_DISK_STR)
+            if(changedflag & CHANGED_DATA_DISK_NUM)
                 taglib_apetag->addValue(APE_TAG_DISKNO, format("%u", disk_number));
             
             if(changedflag & CHANGED_IS_COMPILATION_TAG) {

libtaginfo/asfinfo.cc

 bool ASFInfo::write(void) {
     if(asf_tag) {
         if(changedflag) {
-            if(changedflag & CHANGED_DATA_DISK_STR) {
+            if(changedflag & CHANGED_DATA_DISK_NUM) {
                 asf_tag->removeItem("WM/PartOfSet");
                 asf_tag->setAttribute("WM/PartOfSet", format("%u", disk_number));
             }

libtaginfo/flacinfo.cc

 bool FlacInfo::write(void) {
     if(xiphcomment) {
         if(changedflag) {
-            if(changedflag & CHANGED_DATA_DISK_STR)
+            if(changedflag & CHANGED_DATA_DISK_NUM)
                 xiphcomment->addField("DISCNUMBER", format("%u", disk_number));
             if(changedflag & CHANGED_COMPOSER_TAG)
                 xiphcomment->addField("COMPOSER", composer);

libtaginfo/info.cc

 
 void Info::set_disk_number(int number) {
     disk_number = number;
-    changedflag |= CHANGED_DISK_STR;
+    changedflag |= CHANGED_DATA_DISK_NUM;
 }
 int Info::get_disk_number() const {
     return disk_number;

libtaginfo/mp3info.cc

     if(taglib_tagId3v2) {
         if(changedflag) {
             TagLib::ID3v2::TextIdentificationFrame * frame;
-            if(changedflag & CHANGED_DATA_DISK_STR) {
+            if(changedflag & CHANGED_DATA_DISK_NUM) {
                 taglib_tagId3v2->removeFrames("TPOS");
                 frame = new TagLib::ID3v2::TextIdentificationFrame("TPOS");
                 frame->setText(format("%u", disk_number));

libtaginfo/mp4info.cc

 using namespace TagInfo;
 
 
+int disk_amount;
 
 Mp4Info::Mp4Info(const String &filename) : Info(filename) {
+    disk_amount = 1;
     if(!file_name.isEmpty() && !create_file_ref())
         printf("Error creating file ref! %s\n", filename.toCString(false));
     if(taglib_file) {
                 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_number = mp4_tag->itemListMap()["disk"].toIntPair().first;
+                disk_amount = mp4_tag->itemListMap()["disk"].toIntPair().second;
                 if(disk_number <= 0)
                     disk_number = 1;
+                if(disk_amount < disk_number)
+                    disk_amount = disk_number;
             }
             if(mp4_tag->itemListMap().contains("cpil")) {
                 is_compilation = mp4_tag->itemListMap()["cpil"].toBool();
                 mp4_tag->itemListMap()["aART"] = TagLib::StringList(album_artist);
             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(disk_number, disk_number); //ignore amount
+            if(changedflag & CHANGED_DATA_DISK_NUM) {
+                if(disk_amount < disk_number)
+                    disk_amount = disk_number;
+                mp4_tag->itemListMap()["disk"] = TagLib::MP4::Item(disk_number, disk_amount); //ignore amount
             }
             if(changedflag & CHANGED_IS_COMPILATION_TAG)
                 mp4_tag->itemListMap()["cpil"] = TagLib::MP4::Item(is_compilation);

libtaginfo/mpcinfo.cc

         if(changedflag) {
             if(changedflag & CHANGED_COMPOSER_TAG)
                 taglib_apetag->addValue("COMPOSER", composer);
-            if(changedflag & CHANGED_DISK_STR)
+            if(changedflag & CHANGED_DATA_DISK_NUM)
                 taglib_apetag->addValue("DISCNUMBER", format("%u", disk_number));
             
             if(changedflag & CHANGED_IS_COMPILATION_TAG) {

libtaginfo/ogginfo.cc

 bool OggInfo::write(void) {
     if(xiphcomment) {
         if(changedflag) {
-            if(changedflag & CHANGED_DATA_DISK_STR)
+            if(changedflag & CHANGED_DATA_DISK_NUM)
                 xiphcomment->addField("DISCNUMBER", format("%u", disk_number));
             
             if(changedflag & CHANGED_COMPOSER_TAG)

libtaginfo/speexinfo.cc

 bool SpeexInfo::write(void) {
     if(xiphcomment) {
         if(changedflag) {
-            if(changedflag & CHANGED_DATA_DISK_STR)
+            if(changedflag & CHANGED_DATA_DISK_NUM)
                 xiphcomment->addField("DISCNUMBER", format("%u", disk_number));
             
             if(changedflag & CHANGED_COMPOSER_TAG)

libtaginfo/taginfo.h

         CHANGED_TRACKNO_TAG        = (1 << 5),
         CHANGED_YEAR_TAG           = (1 << 6),
         CHANGED_DATA_ALBUMARTIST   = (1 << 7),
-        CHANGED_DATA_DISK_STR      = (1 << 8),
+        CHANGED_DATA_DISK_NUM      = (1 << 8),
         CHANGED_DATA_IMAGES        = (1 << 9),
         CHANGED_DATA_LYRICS        = (1 << 10),
         CHANGED_DATA_RATING        = (1 << 11),
         CHANGED_TRACK_LABELS       = (1 << 13),
         CHANGED_ARTIST_LABELS      = (1 << 14),
         CHANGED_ALBUM_LABELS       = (1 << 15),
-        CHANGED_IS_COMPILATION_TAG = (1 << 16),
-        CHANGED_DISK_STR           = (1 << 17)
+        CHANGED_IS_COMPILATION_TAG = (1 << 16)
     };
     
     

libtaginfo/taginfo_internal.h

     size_t fLen = find.size();
     size_t rLen = replace.size();
     
-    for (size_t pos = 0; (pos = source.find(find, pos)) != source.npos; pos += rLen) {
+    for(size_t pos = 0; (pos = source.find(find, pos)) != source.npos; pos += rLen) {
         source.replace(pos, fLen, replace);
     }
 }
 
 
-inline bool string_disk_to_disk_num(const string &diskstr, int &disknum, int &disktotal) {
-    unsigned long Number;
-    disknum = 0;
-    disktotal = 0;
-    string DiskNum = diskstr.substr(0, diskstr.find_first_of("/"));
-    if(!DiskNum.empty()) {
-        Number = strtoul(DiskNum.data(), NULL, 0);
-        
-        if(Number > 0) {
-            disknum = Number;
-            if(diskstr.find("/") != string::npos) {
-                DiskNum = diskstr.substr(diskstr.find_first_of("/") + 1);
-                Number = strtoul(DiskNum.data(), NULL, 0);
-                disktotal = Number;
-            }
-            return true;
-        }
-    }
-    return false;
-}
-
 inline int popularity_to_rating(const int rating) {
     if(rating < 0)
         return 0;

libtaginfo/trueaudioinfo.cc

     if(taglib_tagId3v2) {
         if(changedflag) {
             TagLib::ID3v2::TextIdentificationFrame * frame;
-            if(changedflag & CHANGED_DATA_DISK_STR) {
+            if(changedflag & CHANGED_DATA_DISK_NUM) {
                 taglib_tagId3v2->removeFrames("TPOS");
                 frame = new TagLib::ID3v2::TextIdentificationFrame("TPOS");
                 frame->setText(format("%u", disk_number));

libtaginfo/waveinfo.cc

     if(taglib_tagId3v2) {
         if(changedflag) {
             TagLib::ID3v2::TextIdentificationFrame * frame;
-            if(changedflag & CHANGED_DATA_DISK_STR) {
+            if(changedflag & CHANGED_DATA_DISK_NUM) {
                 taglib_tagId3v2->removeFrames("TPOS");
                 frame = new TagLib::ID3v2::TextIdentificationFrame("TPOS");
                 frame->setText(format("%u", disk_number));

libtaginfo/wavpackinfo.cc

         if(changedflag) {
             if(changedflag & CHANGED_COMPOSER_TAG)
                 taglib_apetag->addValue("COMPOSER", composer);
-            if(changedflag & CHANGED_DATA_DISK_STR)
+            if(changedflag & CHANGED_DATA_DISK_NUM)
                 taglib_apetag->addValue("DISCNUMBER", format("%u", disk_number));
             
             if(changedflag & CHANGED_IS_COMPILATION_TAG) {
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.