From 00c6e7ea79fb9b43afcb6011963f6d036ec87d7d Mon Sep 17 00:00:00 2001 From: Samuel Martin Date: Sun, 5 Oct 2014 14:18:52 +0200 Subject: [PATCH 01/33] cmake: use BUILD_SHARED_LIBS instead of ENABLE_STATIC to drive the shared object build In case ENABLE_STATIC is still set on the CMake command line, this change will makes CMake bail out becaus e this option is no longer supported. This patch makes taglib more compliant with the distro package framework that uses the standards CMake options. Signed-off-by: Samuel Martin --- CMakeLists.txt | 10 +++++----- INSTALL | 8 ++++---- examples/CMakeLists.txt | 4 ++-- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1c2bf39e..6265bb2f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,12 +8,12 @@ endif() list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules") -option(ENABLE_STATIC "Make static version of libtag" OFF) -if(ENABLE_STATIC) +if(DEFINED ENABLE_STATIC) + message(FATAL_ERROR "This option is no longer available, use BUILD_SHARED_LIBS instead") +endif() + +if(NOT BUILD_SHARED_LIBS) add_definitions(-DTAGLIB_STATIC) - set(BUILD_SHARED_LIBS OFF) -else() - set(BUILD_SHARED_LIBS ON) endif() OPTION(ENABLE_STATIC_RUNTIME "Visual Studio, link with runtime statically" OFF) diff --git a/INSTALL b/INSTALL index 205b4d31..0fb4862f 100644 --- a/INSTALL +++ b/INSTALL @@ -37,7 +37,7 @@ For a 10.6 Snow Leopard static library with both 32-bit and 64-bit code, use: cmake -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_OSX_DEPLOYMENT_TARGET=10.6 \ -DCMAKE_OSX_ARCHITECTURES="i386;x86_64" \ - -DENABLE_STATIC=ON \ + -DBUILD_SHARED_LIBS=OFF \ -DCMAKE_INSTALL_PREFIX="" After 'make', and 'make install', add libtag.a to your XCode project, and add @@ -139,9 +139,9 @@ The easiest way is at the Command Prompt. 4. Select: Project Only 5. Select: Build Only INSTALL -To build a static library enable the following two options with CMake. - -DENABLE_STATIC=ON -DENABLE_STATIC_RUNTIME=ON - +To build a static library, set the following two options with CMake. + -DBUILD_SHARED_LIBS=OFF -DENABLE_STATIC_RUNTIME=ON + Including ENABLE_STATIC_RUNTIME=ON indicates you want TagLib built using the static runtime library, rather than the DLL form of the runtime. diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 17d4bd6b..b25d4ff6 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -7,9 +7,9 @@ INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_SOURCE_DIR}/../taglib ${CMAKE_CURRENT_SOURCE_DIR}/../taglib/mpeg/id3v2 ${CMAKE_CURRENT_SOURCE_DIR}/../bindings/c/ ) -if(ENABLE_STATIC) +if(NOT BUILD_SHARED_LIBS) add_definitions(-DTAGLIB_STATIC) -endif(ENABLE_STATIC) +endif() ########### next target ############### From 7bbf5a2e79389026895870566196b5e13f224f72 Mon Sep 17 00:00:00 2001 From: Sander Jansen Date: Sat, 16 May 2015 14:06:49 -0500 Subject: [PATCH 02/33] add base64 encoder/decoder to bytevector --- taglib/toolkit/tbytevector.cpp | 92 ++++++++++++++++++++++++++++++++++ taglib/toolkit/tbytevector.h | 13 +++++ tests/test_bytevector.cpp | 40 +++++++++++++++ 3 files changed, 145 insertions(+) diff --git a/taglib/toolkit/tbytevector.cpp b/taglib/toolkit/tbytevector.cpp index 6262bec6..eb559390 100644 --- a/taglib/toolkit/tbytevector.cpp +++ b/taglib/toolkit/tbytevector.cpp @@ -950,6 +950,98 @@ ByteVector ByteVector::toHex() const return encoded; } + + + + +ByteVector & ByteVector::fromBase64() +{ + static const unsigned char base64[256]={ + 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80, + 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80, + 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x3e,0x80,0x80,0x80,0x3f, + 0x34,0x35,0x36,0x37,0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x80,0x80,0x80,0xff,0x80,0x80, + 0x80,0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e, + 0x0f,0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x80,0x80,0x80,0x80,0x80, + 0x80,0x1a,0x1b,0x1c,0x1d,0x1e,0x1f,0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28, + 0x29,0x2a,0x2b,0x2c,0x2d,0x2e,0x2f,0x30,0x31,0x32,0x33,0x80,0x80,0x80,0x80,0x80, + 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80, + 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80, + 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80, + 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80, + 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80, + 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80, + 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80, + 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80 + }; + + detach(); + uint len = size(); + const unsigned char * src = (unsigned char*) data(); + unsigned char * dst = (unsigned char*) data(); + while(4<=len) { + if(base64[src[0]]==0x80) break; + if(base64[src[1]]==0x80) break; + if(base64[src[2]]==0x80) break; + if(base64[src[3]]==0x80) break; + *dst++=((base64[src[0]]<<2)&0xfc)|((base64[src[1]]>>4)&0x03); + if(src[2]!='=') { + *dst++=((base64[src[1]]&0x0f)<<4)|((base64[src[2]]>>2)&0x0f); + if(src[3]!='=') { + *dst++=((base64[src[2]]&0x03)<<6)|(base64[src[3]]&0x3f); + } + else { + break; + } + } + else { + break; + } + src+=4; + len-=4; + } + resize(dst-(unsigned char*)data()); + return *this; +} + + + + +ByteVector ByteVector::toBase64() const +{ + static const char alphabet[]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; + if (size()) { + uint len=size(); + ByteVector output(4 * ((len-1)/3+1)); // note roundup + + const char * src = data(); + char * dst = output.data(); + while(3<=len) { + *dst++=alphabet[(src[0]>>2)&0x3f]; + *dst++=alphabet[((src[0]&0x03)<<4)|((src[1]>>4)&0x0f)]; + *dst++=alphabet[((src[1]&0x0f)<<2)|((src[2]>>6)&0x03)]; + *dst++=alphabet[src[2]&0x3f]; + src+=3; + len-=3; + } + if(len) { + *dst++=alphabet[(src[0]>>2)&0x3f]; + if(len>1) { + *dst++=alphabet[((src[0]&0x03)<<4)|((src[1]>>4)&0x0f)]; + *dst++=alphabet[((src[1]&0x0f)<<2)]; + } + else { + *dst++=alphabet[(src[0]&0x03)<<4]; + *dst++='='; + } + *dst++='='; + } + return output; + } + return ByteVector(); +} + + //////////////////////////////////////////////////////////////////////////////// // protected members //////////////////////////////////////////////////////////////////////////////// diff --git a/taglib/toolkit/tbytevector.h b/taglib/toolkit/tbytevector.h index 793b414c..0f96c77f 100644 --- a/taglib/toolkit/tbytevector.h +++ b/taglib/toolkit/tbytevector.h @@ -573,6 +573,19 @@ namespace TagLib { */ ByteVector toHex() const; + /*! + * Returns a base64 encoded copy of the byte vector + */ + ByteVector toBase64() const; + + /*! + * Decodes the base64 encoded byte vector in-memory. Returns a reference + * to this vector. Calls detach before decoding. + */ + ByteVector & fromBase64(); + + + protected: /* * If this ByteVector is being shared via implicit sharing, do a deep copy diff --git a/tests/test_bytevector.cpp b/tests/test_bytevector.cpp index 1c2ca904..19f51518 100644 --- a/tests/test_bytevector.cpp +++ b/tests/test_bytevector.cpp @@ -43,6 +43,7 @@ class TestByteVector : public CppUnit::TestFixture CPPUNIT_TEST(testReplace); CPPUNIT_TEST(testIterator); CPPUNIT_TEST(testResize); + CPPUNIT_TEST(testBase64); CPPUNIT_TEST_SUITE_END(); public: @@ -379,6 +380,45 @@ public: CPPUNIT_ASSERT_EQUAL(-1, c.find('C')); } + void testBase64() + { + ByteVector sempty; + ByteVector t0("a"); // test 1 byte + ByteVector t1("any carnal pleasure."); + ByteVector t2("any carnal pleasure"); + ByteVector t3("any carnal pleasur"); + ByteVector s0("a"); // test 1 byte + ByteVector s1("any carnal pleasure."); + ByteVector s2("any carnal pleasure"); + ByteVector s3("any carnal pleasur"); + ByteVector eempty; + ByteVector e0("YQ=="); + ByteVector e1("YW55IGNhcm5hbCBwbGVhc3VyZS4="); + ByteVector e2("YW55IGNhcm5hbCBwbGVhc3VyZQ=="); + ByteVector e3("YW55IGNhcm5hbCBwbGVhc3Vy"); + + // Encode + CPPUNIT_ASSERT_EQUAL(eempty, sempty.toBase64()); + CPPUNIT_ASSERT_EQUAL(e0, s0.toBase64()); + CPPUNIT_ASSERT_EQUAL(e1, s1.toBase64()); + CPPUNIT_ASSERT_EQUAL(e2, s2.toBase64()); + CPPUNIT_ASSERT_EQUAL(e3, s3.toBase64()); + + // Decode + CPPUNIT_ASSERT_EQUAL(sempty, eempty.toBase64()); + CPPUNIT_ASSERT_EQUAL(s0, e0.fromBase64()); + CPPUNIT_ASSERT_EQUAL(s1, e1.fromBase64()); + CPPUNIT_ASSERT_EQUAL(s2, e2.fromBase64()); + CPPUNIT_ASSERT_EQUAL(s3, e3.fromBase64()); + + CPPUNIT_ASSERT_EQUAL(t0, s0.toBase64().fromBase64()); + CPPUNIT_ASSERT_EQUAL(t1, s1.toBase64().fromBase64()); + CPPUNIT_ASSERT_EQUAL(t2, s2.toBase64().fromBase64()); + CPPUNIT_ASSERT_EQUAL(t3, s3.toBase64().fromBase64()); + + } + + }; CPPUNIT_TEST_SUITE_REGISTRATION(TestByteVector); From 0c14bd0ed075d140ef55fc62efc81b8c3ad841c8 Mon Sep 17 00:00:00 2001 From: Sander Jansen Date: Sat, 16 May 2015 14:10:24 -0500 Subject: [PATCH 03/33] Add FLAC::Picture support to Xiph Comment --- taglib/ogg/xiphcomment.cpp | 87 +++++++++++++++++++++++++++++++++----- taglib/ogg/xiphcomment.h | 26 ++++++++++++ tests/test_ogg.cpp | 28 ++++++++++++ 3 files changed, 130 insertions(+), 11 deletions(-) diff --git a/taglib/ogg/xiphcomment.cpp b/taglib/ogg/xiphcomment.cpp index 9462607f..c307e618 100644 --- a/taglib/ogg/xiphcomment.cpp +++ b/taglib/ogg/xiphcomment.cpp @@ -26,17 +26,22 @@ #include #include +#include #include #include using namespace TagLib; + +typedef List PictureList; + class Ogg::XiphComment::XiphCommentPrivate { public: FieldListMap fieldListMap; String vendorID; String commentField; + PictureList pictureList; }; //////////////////////////////////////////////////////////////////////////////// @@ -181,6 +186,8 @@ TagLib::uint Ogg::XiphComment::fieldCount() const for(; it != d->fieldListMap.end(); ++it) count += (*it).second.size(); + count += d->pictureList.size(); + return count; } @@ -275,6 +282,36 @@ bool Ogg::XiphComment::contains(const String &key) const return d->fieldListMap.contains(key) && !d->fieldListMap[key].isEmpty(); } +void Ogg::XiphComment::removePicture(FLAC::Picture *picture, bool del) +{ + List::Iterator it = d->pictureList.find(picture); + if(it != d->pictureList.end()) + d->pictureList.erase(it); + + if(del) + delete picture; +} + +void Ogg::XiphComment::removePictures() +{ + PictureList newList; + for(uint i = 0; i < d->pictureList.size(); i++) { + delete d->pictureList[i]; + } + d->pictureList = newList; +} + +void Ogg::XiphComment::addPicture(FLAC::Picture * picture) +{ + d->pictureList.append(picture); +} + + +List Ogg::XiphComment::pictureList() +{ + return d->pictureList; +} + ByteVector Ogg::XiphComment::render() const { return render(true); @@ -321,6 +358,13 @@ ByteVector Ogg::XiphComment::render(bool addFramingBit) const } } + for(PictureList::ConstIterator it = d->pictureList.begin(); it != d->pictureList.end(); ++it) { + ByteVector picture = (*it)->render().toBase64(); + data.append(ByteVector::fromUInt(picture.size()+23,false)); + data.append("METADATA_BLOCK_PICTURE="); + data.append(picture); + } + // Append the "framing bit". if(addFramingBit) @@ -363,20 +407,41 @@ void Ogg::XiphComment::parse(const ByteVector &data) const uint commentLength = data.toUInt(pos, false); pos += 4; - String comment = String(data.mid(pos, commentLength), String::UTF8); - pos += commentLength; - if(pos > data.size()) { + ByteVector entry = data.mid(pos, commentLength); + + // Don't go past data end + pos+=commentLength; + if (pos>data.size()) break; + + // Handle Pictures separately + if(entry.startsWith("METADATA_BLOCK_PICTURE=")) { + + // Decode base64 picture data + ByteVector picturedata = entry.mid(23, entry.size()-23).fromBase64(); + + if(picturedata.size()==0) { + debug("Empty picture data. Discarding content"); + continue; + } + + FLAC::Picture * picture = new FLAC::Picture(); + if(picture->parse(picturedata)) + d->pictureList.append(picture); + else + debug("Unable to parse METADATA_BLOCK_PICTURE. Discarding content."); } + else { - int commentSeparatorPosition = comment.find("="); - if(commentSeparatorPosition == -1) { - break; + // Check for field separator + int sep = entry.find('='); + if (sep == -1) + break; + + // Parse key and value + String key = String(entry.mid(0,sep), String::UTF8); + String value = String(entry.mid(sep+1, commentLength-sep), String::UTF8); + addField(key, value, false); } - - String key = comment.substr(0, commentSeparatorPosition); - String value = comment.substr(commentSeparatorPosition + 1); - - addField(key, value, false); } } diff --git a/taglib/ogg/xiphcomment.h b/taglib/ogg/xiphcomment.h index 54f3070b..8fcc6873 100644 --- a/taglib/ogg/xiphcomment.h +++ b/taglib/ogg/xiphcomment.h @@ -32,6 +32,7 @@ #include "tstring.h" #include "tstringlist.h" #include "tbytevector.h" +#include "flacpicture.h" #include "taglib_export.h" namespace TagLib { @@ -205,6 +206,31 @@ namespace TagLib { */ ByteVector render(bool addFramingBit) const; + + /*! + * Returns a list of pictures attached to the xiph comment. + */ + List pictureList(); + + /*! + * Removes an picture. If \a del is true the picture's memory + * will be freed; if it is false, it must be deleted by the user. + */ + void removePicture(FLAC::Picture *picture, bool del = true); + + /*! + * Remove all pictures. + */ + void removePictures(); + + /*! + * Add a new picture to the comment block. The comment block takes ownership of the + * picture and will handle freeing its memory. + * + * \note The file will be saved only after calling save(). + */ + void addPicture(FLAC::Picture *picture); + protected: /*! * Reads the tag from the file specified in the constructor and fills the diff --git a/tests/test_ogg.cpp b/tests/test_ogg.cpp index 210fca2f..05b23f64 100644 --- a/tests/test_ogg.cpp +++ b/tests/test_ogg.cpp @@ -21,6 +21,7 @@ class TestOGG : public CppUnit::TestFixture CPPUNIT_TEST(testDictInterface1); CPPUNIT_TEST(testDictInterface2); CPPUNIT_TEST(testAudioProperties); + CPPUNIT_TEST(testPicture); CPPUNIT_TEST_SUITE_END(); public: @@ -134,6 +135,33 @@ public: CPPUNIT_ASSERT_EQUAL(112000, f.audioProperties()->bitrateNominal()); CPPUNIT_ASSERT_EQUAL(0, f.audioProperties()->bitrateMinimum()); } + + void testPicture() + { + ScopedFileCopy copy("empty", ".ogg"); + string newname = copy.fileName(); + + Vorbis::File *f = new Vorbis::File(newname.c_str()); + FLAC::Picture *newpic = new FLAC::Picture(); + newpic->setType(FLAC::Picture::BackCover); + newpic->setWidth(5); + newpic->setHeight(6); + newpic->setColorDepth(16); + newpic->setNumColors(7); + newpic->setMimeType("image/jpeg"); + newpic->setDescription("new image"); + newpic->setData("JPEG data"); + f->tag()->addPicture(newpic); + f->save(); + delete f; + + f = new Vorbis::File(newname.c_str()); + List lst = f->tag()->pictureList(); + CPPUNIT_ASSERT_EQUAL(TagLib::uint(1), lst.size()); + delete f; + } + + }; CPPUNIT_TEST_SUITE_REGISTRATION(TestOGG); From d3351a0012d89bd78e032859597e4f4ef40efdd5 Mon Sep 17 00:00:00 2001 From: Sander Jansen Date: Sat, 16 May 2015 14:14:06 -0500 Subject: [PATCH 04/33] Delete pictures in XiphComment destructor --- taglib/ogg/xiphcomment.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/taglib/ogg/xiphcomment.cpp b/taglib/ogg/xiphcomment.cpp index c307e618..2783d922 100644 --- a/taglib/ogg/xiphcomment.cpp +++ b/taglib/ogg/xiphcomment.cpp @@ -61,6 +61,7 @@ Ogg::XiphComment::XiphComment(const ByteVector &data) : TagLib::Tag() Ogg::XiphComment::~XiphComment() { + removePictures(); delete d; } From 62bb3c95c80e6c1646a54cb3b96bc01bdebe4ff2 Mon Sep 17 00:00:00 2001 From: Sander Jansen Date: Sat, 16 May 2015 14:51:10 -0500 Subject: [PATCH 05/33] Make ByteVector::fromBase64 as static member function --- taglib/ogg/xiphcomment.cpp | 2 +- taglib/toolkit/tbytevector.cpp | 16 +++++++++------- taglib/toolkit/tbytevector.h | 7 ++----- tests/test_bytevector.cpp | 16 ++++++++-------- 4 files changed, 20 insertions(+), 21 deletions(-) diff --git a/taglib/ogg/xiphcomment.cpp b/taglib/ogg/xiphcomment.cpp index 2783d922..15f8cbaf 100644 --- a/taglib/ogg/xiphcomment.cpp +++ b/taglib/ogg/xiphcomment.cpp @@ -419,7 +419,7 @@ void Ogg::XiphComment::parse(const ByteVector &data) if(entry.startsWith("METADATA_BLOCK_PICTURE=")) { // Decode base64 picture data - ByteVector picturedata = entry.mid(23, entry.size()-23).fromBase64(); + ByteVector picturedata = ByteVector::fromBase64(entry.mid(23)); if(picturedata.size()==0) { debug("Empty picture data. Discarding content"); diff --git a/taglib/toolkit/tbytevector.cpp b/taglib/toolkit/tbytevector.cpp index eb559390..f18d2329 100644 --- a/taglib/toolkit/tbytevector.cpp +++ b/taglib/toolkit/tbytevector.cpp @@ -954,7 +954,7 @@ ByteVector ByteVector::toHex() const -ByteVector & ByteVector::fromBase64() +ByteVector ByteVector::fromBase64(const ByteVector & input) { static const unsigned char base64[256]={ 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80, @@ -975,10 +975,12 @@ ByteVector & ByteVector::fromBase64() 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80 }; - detach(); - uint len = size(); - const unsigned char * src = (unsigned char*) data(); - unsigned char * dst = (unsigned char*) data(); + uint len = input.size(); + + ByteVector output(len); + + const unsigned char * src = (unsigned char*) input.data(); + unsigned char * dst = (unsigned char*)output.data(); while(4<=len) { if(base64[src[0]]==0x80) break; if(base64[src[1]]==0x80) break; @@ -1000,8 +1002,8 @@ ByteVector & ByteVector::fromBase64() src+=4; len-=4; } - resize(dst-(unsigned char*)data()); - return *this; + output.resize(dst-(unsigned char*)output.data()); + return output; } diff --git a/taglib/toolkit/tbytevector.h b/taglib/toolkit/tbytevector.h index 0f96c77f..4b669b9e 100644 --- a/taglib/toolkit/tbytevector.h +++ b/taglib/toolkit/tbytevector.h @@ -579,12 +579,9 @@ namespace TagLib { ByteVector toBase64() const; /*! - * Decodes the base64 encoded byte vector in-memory. Returns a reference - * to this vector. Calls detach before decoding. + * Decodes the base64 encoded byte vector. */ - ByteVector & fromBase64(); - - + static ByteVector fromBase64(const ByteVector &); protected: /* diff --git a/tests/test_bytevector.cpp b/tests/test_bytevector.cpp index 19f51518..18097adf 100644 --- a/tests/test_bytevector.cpp +++ b/tests/test_bytevector.cpp @@ -406,15 +406,15 @@ public: // Decode CPPUNIT_ASSERT_EQUAL(sempty, eempty.toBase64()); - CPPUNIT_ASSERT_EQUAL(s0, e0.fromBase64()); - CPPUNIT_ASSERT_EQUAL(s1, e1.fromBase64()); - CPPUNIT_ASSERT_EQUAL(s2, e2.fromBase64()); - CPPUNIT_ASSERT_EQUAL(s3, e3.fromBase64()); + CPPUNIT_ASSERT_EQUAL(s0, ByteVector::fromBase64(e0)); + CPPUNIT_ASSERT_EQUAL(s1, ByteVector::fromBase64(e1)); + CPPUNIT_ASSERT_EQUAL(s2, ByteVector::fromBase64(e2)); + CPPUNIT_ASSERT_EQUAL(s3, ByteVector::fromBase64(e3)); - CPPUNIT_ASSERT_EQUAL(t0, s0.toBase64().fromBase64()); - CPPUNIT_ASSERT_EQUAL(t1, s1.toBase64().fromBase64()); - CPPUNIT_ASSERT_EQUAL(t2, s2.toBase64().fromBase64()); - CPPUNIT_ASSERT_EQUAL(t3, s3.toBase64().fromBase64()); + CPPUNIT_ASSERT_EQUAL(t0, ByteVector::fromBase64(s0.toBase64())); + CPPUNIT_ASSERT_EQUAL(t1, ByteVector::fromBase64(s1.toBase64())); + CPPUNIT_ASSERT_EQUAL(t2, ByteVector::fromBase64(s2.toBase64())); + CPPUNIT_ASSERT_EQUAL(t3, ByteVector::fromBase64(s3.toBase64())); } From 59a1b7a4916e3cf47945ba965961249db21fb9db Mon Sep 17 00:00:00 2001 From: Sander Jansen Date: Sat, 16 May 2015 14:53:17 -0500 Subject: [PATCH 06/33] add forgotten const cast --- taglib/toolkit/tbytevector.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/taglib/toolkit/tbytevector.cpp b/taglib/toolkit/tbytevector.cpp index f18d2329..a87922d5 100644 --- a/taglib/toolkit/tbytevector.cpp +++ b/taglib/toolkit/tbytevector.cpp @@ -979,7 +979,7 @@ ByteVector ByteVector::fromBase64(const ByteVector & input) ByteVector output(len); - const unsigned char * src = (unsigned char*) input.data(); + const unsigned char * src = (const unsigned char*) input.data(); unsigned char * dst = (unsigned char*)output.data(); while(4<=len) { if(base64[src[0]]==0x80) break; From c4a02a17991a857ad01d9ed61aad7da167faec4e Mon Sep 17 00:00:00 2001 From: Sander Jansen Date: Sat, 16 May 2015 14:57:19 -0500 Subject: [PATCH 07/33] remove redundant size specificier in mid usage --- taglib/ogg/xiphcomment.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/taglib/ogg/xiphcomment.cpp b/taglib/ogg/xiphcomment.cpp index 15f8cbaf..431c7980 100644 --- a/taglib/ogg/xiphcomment.cpp +++ b/taglib/ogg/xiphcomment.cpp @@ -441,7 +441,7 @@ void Ogg::XiphComment::parse(const ByteVector &data) // Parse key and value String key = String(entry.mid(0,sep), String::UTF8); - String value = String(entry.mid(sep+1, commentLength-sep), String::UTF8); + String value = String(entry.mid(sep+1), String::UTF8); addField(key, value, false); } } From c963d3ba04d0cd4ad227c2703d978c023d659833 Mon Sep 17 00:00:00 2001 From: Sander Jansen Date: Sat, 16 May 2015 15:05:05 -0500 Subject: [PATCH 08/33] correctly filter out invalid base64 characters --- taglib/toolkit/tbytevector.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/taglib/toolkit/tbytevector.cpp b/taglib/toolkit/tbytevector.cpp index a87922d5..377dc034 100644 --- a/taglib/toolkit/tbytevector.cpp +++ b/taglib/toolkit/tbytevector.cpp @@ -960,7 +960,7 @@ ByteVector ByteVector::fromBase64(const ByteVector & input) 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80, 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80, 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x3e,0x80,0x80,0x80,0x3f, - 0x34,0x35,0x36,0x37,0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x80,0x80,0x80,0xff,0x80,0x80, + 0x34,0x35,0x36,0x37,0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x80,0x80,0x80,0x80,0x80,0x80, 0x80,0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e, 0x0f,0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x80,0x80,0x80,0x80,0x80, 0x80,0x1a,0x1b,0x1c,0x1d,0x1e,0x1f,0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28, @@ -984,12 +984,12 @@ ByteVector ByteVector::fromBase64(const ByteVector & input) while(4<=len) { if(base64[src[0]]==0x80) break; if(base64[src[1]]==0x80) break; - if(base64[src[2]]==0x80) break; - if(base64[src[3]]==0x80) break; *dst++=((base64[src[0]]<<2)&0xfc)|((base64[src[1]]>>4)&0x03); if(src[2]!='=') { + if(base64[src[2]]==0x80) break; *dst++=((base64[src[1]]&0x0f)<<4)|((base64[src[2]]>>2)&0x0f); if(src[3]!='=') { + if(base64[src[3]]==0x80) break; *dst++=((base64[src[2]]&0x03)<<6)|(base64[src[3]]&0x3f); } else { From f4c1beb16147dee202824ff693d55da69eb110be Mon Sep 17 00:00:00 2001 From: Sander Jansen Date: Sat, 16 May 2015 21:25:06 -0500 Subject: [PATCH 09/33] Make fromBase64 more strict and update code to follow taglib coding style --- taglib/ogg/xiphcomment.cpp | 22 ++++---- taglib/toolkit/tbytevector.cpp | 99 +++++++++++++++++++++------------- 2 files changed, 74 insertions(+), 47 deletions(-) diff --git a/taglib/ogg/xiphcomment.cpp b/taglib/ogg/xiphcomment.cpp index 431c7980..6b87e3ea 100644 --- a/taglib/ogg/xiphcomment.cpp +++ b/taglib/ogg/xiphcomment.cpp @@ -33,7 +33,7 @@ using namespace TagLib; -typedef List PictureList; +typedef List PictureList; class Ogg::XiphComment::XiphCommentPrivate { @@ -285,7 +285,7 @@ bool Ogg::XiphComment::contains(const String &key) const void Ogg::XiphComment::removePicture(FLAC::Picture *picture, bool del) { - List::Iterator it = d->pictureList.find(picture); + PictureList::Iterator it = d->pictureList.find(picture); if(it != d->pictureList.end()) d->pictureList.erase(it); @@ -410,9 +410,10 @@ void Ogg::XiphComment::parse(const ByteVector &data) ByteVector entry = data.mid(pos, commentLength); + pos += commentLength; + // Don't go past data end - pos+=commentLength; - if (pos>data.size()) + if (pos > data.size()) break; // Handle Pictures separately @@ -421,12 +422,13 @@ void Ogg::XiphComment::parse(const ByteVector &data) // Decode base64 picture data ByteVector picturedata = ByteVector::fromBase64(entry.mid(23)); - if(picturedata.size()==0) { + if(picturedata.size() == 0) { debug("Empty picture data. Discarding content"); continue; - } + } FLAC::Picture * picture = new FLAC::Picture(); + if(picture->parse(picturedata)) d->pictureList.append(picture); else @@ -436,11 +438,13 @@ void Ogg::XiphComment::parse(const ByteVector &data) // Check for field separator int sep = entry.find('='); - if (sep == -1) - break; + if (sep < 1) { + debug("Discarding invalid comment field."); + continue; + } // Parse key and value - String key = String(entry.mid(0,sep), String::UTF8); + String key = String(entry.mid(0, sep), String::UTF8); String value = String(entry.mid(sep+1), String::UTF8); addField(key, value, false); } diff --git a/taglib/toolkit/tbytevector.cpp b/taglib/toolkit/tbytevector.cpp index 377dc034..14550ad1 100644 --- a/taglib/toolkit/tbytevector.cpp +++ b/taglib/toolkit/tbytevector.cpp @@ -950,13 +950,9 @@ ByteVector ByteVector::toHex() const return encoded; } - - - - ByteVector ByteVector::fromBase64(const ByteVector & input) { - static const unsigned char base64[256]={ + static const unsigned char base64[256] = { 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80, 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80, 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x3e,0x80,0x80,0x80,0x3f, @@ -980,61 +976,88 @@ ByteVector ByteVector::fromBase64(const ByteVector & input) ByteVector output(len); const unsigned char * src = (const unsigned char*) input.data(); - unsigned char * dst = (unsigned char*)output.data(); - while(4<=len) { - if(base64[src[0]]==0x80) break; - if(base64[src[1]]==0x80) break; - *dst++=((base64[src[0]]<<2)&0xfc)|((base64[src[1]]>>4)&0x03); - if(src[2]!='=') { - if(base64[src[2]]==0x80) break; - *dst++=((base64[src[1]]&0x0f)<<4)|((base64[src[2]]>>2)&0x0f); - if(src[3]!='=') { - if(base64[src[3]]==0x80) break; - *dst++=((base64[src[2]]&0x03)<<6)|(base64[src[3]]&0x3f); + unsigned char * dst = (unsigned char*) output.data(); + + while(4 <= len) { + + // Check invalid character + if(base64[src[0]] == 0x80) + break; + + // Check invalid character + if(base64[src[1]] == 0x80) + break; + + // Decode first byte + *dst++ = ((base64[src[0]] << 2) & 0xfc) | ((base64[src[1]] >> 4) & 0x03); + + if(src[2] != '=') { + + // Check invalid character + if(base64[src[2]] == 0x80) + break; + + // Decode second byte + *dst++ = ((base64[src[1]] & 0x0f) << 4) | ((base64[src[2]] >> 2) & 0x0f); + + if(src[3] != '=') { + + // Check invalid character + if(base64[src[3]] == 0x80) + break; + + // Decode third byte + *dst++ = ((base64[src[2]] & 0x03) << 6) | (base64[src[3]] & 0x3f); } else { + // assume end of data + len -= 4; break; } } else { + // assume end of data + len -= 4; break; } - src+=4; - len-=4; + src += 4; + len -= 4; } - output.resize(dst-(unsigned char*)output.data()); - return output; + + // Only return output if we processed all bytes + if(len == 0) { + output.resize(dst - (unsigned char*) output.data()); + return output; + } + return ByteVector(); } - - - ByteVector ByteVector::toBase64() const { - static const char alphabet[]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; + static const char alphabet[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; if (size()) { - uint len=size(); - ByteVector output(4 * ((len-1)/3+1)); // note roundup + uint len = size(); + ByteVector output(4 * ((len - 1) / 3 + 1)); // note roundup const char * src = data(); char * dst = output.data(); - while(3<=len) { - *dst++=alphabet[(src[0]>>2)&0x3f]; - *dst++=alphabet[((src[0]&0x03)<<4)|((src[1]>>4)&0x0f)]; - *dst++=alphabet[((src[1]&0x0f)<<2)|((src[2]>>6)&0x03)]; - *dst++=alphabet[src[2]&0x3f]; - src+=3; - len-=3; + while(3 <= len) { + *dst++ = alphabet[(src[0] >> 2) & 0x3f]; + *dst++ = alphabet[((src[0] & 0x03) << 4) | ((src[1] >> 4) & 0x0f)]; + *dst++ = alphabet[((src[1] & 0x0f) << 2) | ((src[2] >> 6) & 0x03)]; + *dst++ = alphabet[src[2] & 0x3f]; + src += 3; + len -= 3; } if(len) { - *dst++=alphabet[(src[0]>>2)&0x3f]; + *dst++ = alphabet[(src[0] >> 2) & 0x3f]; if(len>1) { - *dst++=alphabet[((src[0]&0x03)<<4)|((src[1]>>4)&0x0f)]; - *dst++=alphabet[((src[1]&0x0f)<<2)]; + *dst++ = alphabet[((src[0] & 0x03) << 4)|((src[1] >> 4) & 0x0f)]; + *dst++ = alphabet[((src[1] & 0x0f) << 2)]; } else { - *dst++=alphabet[(src[0]&0x03)<<4]; - *dst++='='; + *dst++ = alphabet[(src[0] & 0x03) << 4]; + *dst++ = '='; } *dst++='='; } From 90ad17b4c5da178d91c9a20e8c3724ea9e57de53 Mon Sep 17 00:00:00 2001 From: Sander Jansen Date: Sat, 16 May 2015 21:26:30 -0500 Subject: [PATCH 10/33] Additional unit tests for base64 encoder/decoder --- tests/test_bytevector.cpp | 68 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) diff --git a/tests/test_bytevector.cpp b/tests/test_bytevector.cpp index 18097adf..450402e3 100644 --- a/tests/test_bytevector.cpp +++ b/tests/test_bytevector.cpp @@ -25,6 +25,7 @@ #include #include #include +#include #include using namespace std; @@ -416,6 +417,73 @@ public: CPPUNIT_ASSERT_EQUAL(t2, ByteVector::fromBase64(s2.toBase64())); CPPUNIT_ASSERT_EQUAL(t3, ByteVector::fromBase64(s3.toBase64())); + ByteVector all((uint)256); + + // in order + { + for(int i = 0; i < 256; i++){ + all[i]=(unsigned char)i; + } + ByteVector b64 = all.toBase64(); + ByteVector original = ByteVector::fromBase64(b64); + CPPUNIT_ASSERT_EQUAL(all,original); + } + + // reverse + { + for(int i = 0; i < 256; i++){ + all[i]=(unsigned char)255-i; + } + ByteVector b64 = all.toBase64(); + ByteVector original = ByteVector::fromBase64(b64); + CPPUNIT_ASSERT_EQUAL(all,original); + } + + // all zeroes + { + for(int i = 0; i < 256; i++){ + all[i]=0; + } + ByteVector b64 = all.toBase64(); + ByteVector original = ByteVector::fromBase64(b64); + CPPUNIT_ASSERT_EQUAL(all,original); + } + + // all ones + { + for(int i = 0; i < 256; i++){ + all[i]=0xff; + } + ByteVector b64 = all.toBase64(); + ByteVector original = ByteVector::fromBase64(b64); + CPPUNIT_ASSERT_EQUAL(all,original); + } + + // Missing end bytes + { + // No missing bytes + ByteVector m0("YW55IGNhcm5hbCBwbGVhc3VyZQ=="); + CPPUNIT_ASSERT_EQUAL(s2,ByteVector::fromBase64(m0)); + + // 1 missing byte + ByteVector m1("YW55IGNhcm5hbCBwbGVhc3VyZQ="); + CPPUNIT_ASSERT_EQUAL(sempty,ByteVector::fromBase64(m1)); + + // 2 missing bytes + ByteVector m2("YW55IGNhcm5hbCBwbGVhc3VyZQ"); + CPPUNIT_ASSERT_EQUAL(sempty,ByteVector::fromBase64(m2)); + + // 3 missing bytes + ByteVector m3("YW55IGNhcm5hbCBwbGVhc3VyZ"); + CPPUNIT_ASSERT_EQUAL(sempty,ByteVector::fromBase64(m3)); + } + + // Grok invalid characters + { + ByteVector invalid("abd\x00\x01\x02\x03\x04"); + CPPUNIT_ASSERT_EQUAL(sempty,ByteVector::fromBase64(invalid)); + } + } From 47bd01ecda5852070de3821cd954658e8560d389 Mon Sep 17 00:00:00 2001 From: Sander Jansen Date: Sat, 16 May 2015 21:32:50 -0500 Subject: [PATCH 11/33] Minor style fixes --- taglib/ogg/xiphcomment.cpp | 4 ++-- tests/test_bytevector.cpp | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/taglib/ogg/xiphcomment.cpp b/taglib/ogg/xiphcomment.cpp index 6b87e3ea..cb607ce4 100644 --- a/taglib/ogg/xiphcomment.cpp +++ b/taglib/ogg/xiphcomment.cpp @@ -361,7 +361,7 @@ ByteVector Ogg::XiphComment::render(bool addFramingBit) const for(PictureList::ConstIterator it = d->pictureList.begin(); it != d->pictureList.end(); ++it) { ByteVector picture = (*it)->render().toBase64(); - data.append(ByteVector::fromUInt(picture.size()+23,false)); + data.append(ByteVector::fromUInt(picture.size() + 23, false)); data.append("METADATA_BLOCK_PICTURE="); data.append(picture); } @@ -445,7 +445,7 @@ void Ogg::XiphComment::parse(const ByteVector &data) // Parse key and value String key = String(entry.mid(0, sep), String::UTF8); - String value = String(entry.mid(sep+1), String::UTF8); + String value = String(entry.mid(sep + 1), String::UTF8); addField(key, value, false); } } diff --git a/tests/test_bytevector.cpp b/tests/test_bytevector.cpp index 450402e3..8d23b82b 100644 --- a/tests/test_bytevector.cpp +++ b/tests/test_bytevector.cpp @@ -25,7 +25,6 @@ #include #include #include -#include #include using namespace std; From f836cb4dea012826c00c371783db2b810438e750 Mon Sep 17 00:00:00 2001 From: Sander Jansen Date: Sat, 16 May 2015 21:38:01 -0500 Subject: [PATCH 12/33] Two more spaces --- taglib/toolkit/tbytevector.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/taglib/toolkit/tbytevector.cpp b/taglib/toolkit/tbytevector.cpp index 14550ad1..531503f7 100644 --- a/taglib/toolkit/tbytevector.cpp +++ b/taglib/toolkit/tbytevector.cpp @@ -1052,7 +1052,7 @@ ByteVector ByteVector::toBase64() const if(len) { *dst++ = alphabet[(src[0] >> 2) & 0x3f]; if(len>1) { - *dst++ = alphabet[((src[0] & 0x03) << 4)|((src[1] >> 4) & 0x0f)]; + *dst++ = alphabet[((src[0] & 0x03) << 4) | ((src[1] >> 4) & 0x0f)]; *dst++ = alphabet[((src[1] & 0x0f) << 2)]; } else { From 70e471f1d19a3be0caaf6000590eb48c71b439f5 Mon Sep 17 00:00:00 2001 From: Sander Jansen Date: Sat, 16 May 2015 22:09:27 -0500 Subject: [PATCH 13/33] Check if saved picture can be read back correctly --- tests/test_ogg.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/test_ogg.cpp b/tests/test_ogg.cpp index 05b23f64..3afeb196 100644 --- a/tests/test_ogg.cpp +++ b/tests/test_ogg.cpp @@ -158,6 +158,14 @@ public: f = new Vorbis::File(newname.c_str()); List lst = f->tag()->pictureList(); CPPUNIT_ASSERT_EQUAL(TagLib::uint(1), lst.size()); + CPPUNIT_ASSERT_EQUAL(int(5), lst[0]->width()); + CPPUNIT_ASSERT_EQUAL(int(6), lst[0]->height()); + CPPUNIT_ASSERT_EQUAL(int(16), lst[0]->colorDepth()); + CPPUNIT_ASSERT_EQUAL(int(7), lst[0]->numColors()); + CPPUNIT_ASSERT_EQUAL(String("image/jpeg"), lst[0]->mimeType()); + CPPUNIT_ASSERT_EQUAL(String("new image"), lst[0]->description()); + CPPUNIT_ASSERT_EQUAL(ByteVector("JPEG data"), lst[0]->data()); + delete f; } From 41a44f4ab2b1dda149e54c9b7431dd8624d22c51 Mon Sep 17 00:00:00 2001 From: Sander Jansen Date: Sat, 16 May 2015 22:34:08 -0500 Subject: [PATCH 14/33] Support reading deprecated COVERART xiphcomment --- taglib/ogg/xiphcomment.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/taglib/ogg/xiphcomment.cpp b/taglib/ogg/xiphcomment.cpp index cb607ce4..0424ed55 100644 --- a/taglib/ogg/xiphcomment.cpp +++ b/taglib/ogg/xiphcomment.cpp @@ -434,6 +434,23 @@ void Ogg::XiphComment::parse(const ByteVector &data) else debug("Unable to parse METADATA_BLOCK_PICTURE. Discarding content."); } + else if (entry.startsWith("COVERART=")) { + + // Decode base64 picture data + ByteVector picturedata = ByteVector::fromBase64(entry.mid(9)); + + if (picturedata.size() == 0) { + debug("Empty coverart data. Discaring content"); + continue; + } + + // Assume it's some type of image file + FLAC::Picture * picture = new FLAC::Picture(); + picture->setData(picturedata); + picture->setMimeType("image/"); + picture->setType(FLAC::Picture::Other); + d->pictureList.append(picture); + } else { // Check for field separator From 3e8eff16b8fc8de6a38fd6c159cb21990d1fc051 Mon Sep 17 00:00:00 2001 From: Sander Jansen Date: Sat, 16 May 2015 22:37:54 -0500 Subject: [PATCH 15/33] another style fix --- taglib/toolkit/tbytevector.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/taglib/toolkit/tbytevector.cpp b/taglib/toolkit/tbytevector.cpp index 531503f7..757e41c3 100644 --- a/taglib/toolkit/tbytevector.cpp +++ b/taglib/toolkit/tbytevector.cpp @@ -981,11 +981,11 @@ ByteVector ByteVector::fromBase64(const ByteVector & input) while(4 <= len) { // Check invalid character - if(base64[src[0]] == 0x80) + if(base64[src[0]] == 0x80) break; // Check invalid character - if(base64[src[1]] == 0x80) + if(base64[src[1]] == 0x80) break; // Decode first byte @@ -994,7 +994,7 @@ ByteVector ByteVector::fromBase64(const ByteVector & input) if(src[2] != '=') { // Check invalid character - if(base64[src[2]] == 0x80) + if(base64[src[2]] == 0x80) break; // Decode second byte @@ -1003,7 +1003,7 @@ ByteVector ByteVector::fromBase64(const ByteVector & input) if(src[3] != '=') { // Check invalid character - if(base64[src[3]] == 0x80) + if(base64[src[3]] == 0x80) break; // Decode third byte @@ -1059,7 +1059,7 @@ ByteVector ByteVector::toBase64() const *dst++ = alphabet[(src[0] & 0x03) << 4]; *dst++ = '='; } - *dst++='='; + *dst++ = '='; } return output; } From 2184aa476f19533d2829a40c7a7d22a76c8f8545 Mon Sep 17 00:00:00 2001 From: Sander Jansen Date: Mon, 18 May 2015 08:24:02 -0500 Subject: [PATCH 16/33] xiph: preserve any picture data we can't decode in the text comments --- taglib/ogg/xiphcomment.cpp | 101 +++++++++++++++++++++++-------------- 1 file changed, 62 insertions(+), 39 deletions(-) diff --git a/taglib/ogg/xiphcomment.cpp b/taglib/ogg/xiphcomment.cpp index 0424ed55..8ec108dd 100644 --- a/taglib/ogg/xiphcomment.cpp +++ b/taglib/ogg/xiphcomment.cpp @@ -419,51 +419,74 @@ void Ogg::XiphComment::parse(const ByteVector &data) // Handle Pictures separately if(entry.startsWith("METADATA_BLOCK_PICTURE=")) { - // Decode base64 picture data - ByteVector picturedata = ByteVector::fromBase64(entry.mid(23)); + // We need base64 encoded data including padding + if((entry.size() - 23) > 3 && ((entry.size() - 23) % 4) == 0) { - if(picturedata.size() == 0) { - debug("Empty picture data. Discarding content"); - continue; + // Decode base64 picture data + ByteVector picturedata = ByteVector::fromBase64(entry.mid(23)); + if (picturedata.size()) { + + // Decode Flac Picture + FLAC::Picture * picture = new FLAC::Picture(); + if(picture->parse(picturedata)) { + + d->pictureList.append(picture); + + // continue to next field + continue; + } + else { + delete picture; + debug("Failed to decode FlacPicture block"); + } + } + else { + debug("Failed to decode base64 encoded data"); + } } - - FLAC::Picture * picture = new FLAC::Picture(); - - if(picture->parse(picturedata)) - d->pictureList.append(picture); - else - debug("Unable to parse METADATA_BLOCK_PICTURE. Discarding content."); - } - else if (entry.startsWith("COVERART=")) { - - // Decode base64 picture data - ByteVector picturedata = ByteVector::fromBase64(entry.mid(9)); - - if (picturedata.size() == 0) { - debug("Empty coverart data. Discaring content"); - continue; + else { + debug("Invalid base64 encoded data"); } - - // Assume it's some type of image file - FLAC::Picture * picture = new FLAC::Picture(); - picture->setData(picturedata); - picture->setMimeType("image/"); - picture->setType(FLAC::Picture::Other); - d->pictureList.append(picture); } - else { - // Check for field separator - int sep = entry.find('='); - if (sep < 1) { - debug("Discarding invalid comment field."); - continue; + // Handle old picture standard + if (entry.startsWith("COVERART=")) { + + if((entry.size() - 9) > 3 && ((entry.size() - 9) % 4) == 0) { + + // Decode base64 picture data + ByteVector picturedata = ByteVector::fromBase64(entry.mid(9)); + if (picturedata.size()) { + + // Assume it's some type of image file + FLAC::Picture * picture = new FLAC::Picture(); + picture->setData(picturedata); + picture->setMimeType("image/"); + picture->setType(FLAC::Picture::Other); + d->pictureList.append(picture); + + // continue to next field + continue; + } + else { + debug("Failed to decode base64 encoded data"); + } + } + else { + debug("Invalid base64 encoded data"); } - - // Parse key and value - String key = String(entry.mid(0, sep), String::UTF8); - String value = String(entry.mid(sep + 1), String::UTF8); - addField(key, value, false); } + + // Check for field separator + int sep = entry.find('='); + if (sep < 1) { + debug("Discarding invalid comment field."); + continue; + } + + // Parse key and value + String key = String(entry.mid(0, sep), String::UTF8); + String value = String(entry.mid(sep + 1), String::UTF8); + addField(key, value, false); } } From 463e8f313a030056dad0cc6705579690f1239977 Mon Sep 17 00:00:00 2001 From: Festus Hagen Date: Sat, 16 May 2015 16:06:14 -0400 Subject: [PATCH 17/33] Append TIME to TDRC, adjusted test_id3v2.cpp as appropriate. --- taglib/mpeg/id3v2/id3v2framefactory.cpp | 24 +++++++++++++++++------- tests/test_id3v2.cpp | 2 +- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/taglib/mpeg/id3v2/id3v2framefactory.cpp b/taglib/mpeg/id3v2/id3v2framefactory.cpp index 1282d228..a462e21b 100644 --- a/taglib/mpeg/id3v2/id3v2framefactory.cpp +++ b/taglib/mpeg/id3v2/id3v2framefactory.cpp @@ -336,18 +336,27 @@ void FrameFactory::rebuildAggregateFrames(ID3v2::Tag *tag) const tag->frameList("TDRC").size() == 1 && tag->frameList("TDAT").size() == 1) { - TextIdentificationFrame *trdc = + TextIdentificationFrame *tdrc = static_cast(tag->frameList("TDRC").front()); - UnknownFrame *tdat = - static_cast(tag->frameList("TDAT").front()); + UnknownFrame *tdat = static_cast(tag->frameList("TDAT").front()); - if(trdc->fieldList().size() == 1 && - trdc->fieldList().front().size() == 4 && + if(tdrc->fieldList().size() == 1 && + tdrc->fieldList().front().size() == 4 && tdat->data().size() >= 5) { String date(tdat->data().mid(1), String::Type(tdat->data()[0])); - if(date.length() == 4) - trdc->setText(trdc->toString() + '-' + date.substr(2, 2) + '-' + date.substr(0, 2)); + if(date.length() == 4) { + tdrc->setText(tdrc->toString() + '-' + date.substr(2, 2) + '-' + date.substr(0, 2)); + if(tag->frameList("TIME").size() == 1) { + UnknownFrame *timeframe = static_cast(tag->frameList("TIME").front()); + if(timeframe->data().size() >= 5) { + String time(timeframe->data().mid(1), String::Type(timeframe->data()[0])); + if(time.length() == 4) { + tdrc->setText(tdrc->toString() + 'T' + time.substr(0, 2) + ':' + time.substr(2, 2)); + } + } + } + } } } } @@ -533,3 +542,4 @@ bool FrameFactory::updateFrame(Frame::Header *header) const return true; } + diff --git a/tests/test_id3v2.cpp b/tests/test_id3v2.cpp index c6592bbe..cf2e854b 100644 --- a/tests/test_id3v2.cpp +++ b/tests/test_id3v2.cpp @@ -690,7 +690,7 @@ public: tf = static_cast(bar.ID3v2Tag()->frameList("TDRC").front()); CPPUNIT_ASSERT(tf); CPPUNIT_ASSERT_EQUAL(TagLib::uint(1), tf->fieldList().size()); - CPPUNIT_ASSERT_EQUAL(String("2012-04-17"), tf->fieldList().front()); + CPPUNIT_ASSERT_EQUAL(String("2012-04-17T12:01"), tf->fieldList().front()); tf = dynamic_cast(bar.ID3v2Tag()->frameList("TIPL").front()); CPPUNIT_ASSERT(tf); CPPUNIT_ASSERT_EQUAL(TagLib::uint(8), tf->fieldList().size()); From 060a50ab117826ae994ce44031f79d4bf13b6586 Mon Sep 17 00:00:00 2001 From: Tsuda Kageyu Date: Wed, 2 Dec 2015 11:30:29 +0900 Subject: [PATCH 18/33] Use a standard type rather than TagLib::wchar. This won't break the ABI compatibility. --- taglib/mpeg/id3v1/id3v1genres.cpp | 2 +- taglib/toolkit/taglib.h | 2 +- taglib/toolkit/tstring.cpp | 4 ++-- taglib/toolkit/tstring.h | 8 ++++---- tests/test_ogg.cpp | 2 +- tests/test_oggflac.cpp | 2 +- tests/test_opus.cpp | 2 +- tests/test_speex.cpp | 2 +- 8 files changed, 12 insertions(+), 12 deletions(-) diff --git a/taglib/mpeg/id3v1/id3v1genres.cpp b/taglib/mpeg/id3v1/id3v1genres.cpp index def91910..1c707c30 100644 --- a/taglib/mpeg/id3v1/id3v1genres.cpp +++ b/taglib/mpeg/id3v1/id3v1genres.cpp @@ -29,7 +29,7 @@ using namespace TagLib; namespace { - const wchar *genres[] = { + const wchar_t *genres[] = { L"Blues", L"Classic Rock", L"Country", diff --git a/taglib/toolkit/taglib.h b/taglib/toolkit/taglib.h index ef7650ce..e9116e6d 100644 --- a/taglib/toolkit/taglib.h +++ b/taglib/toolkit/taglib.h @@ -73,7 +73,7 @@ namespace TagLib { * Unfortunately std::wstring isn't defined on some systems, (i.e. GCC < 3) * so I'm providing something here that should be constant. */ - typedef std::basic_string wstring; + typedef std::basic_string wstring; } /*! diff --git a/taglib/toolkit/tstring.cpp b/taglib/toolkit/tstring.cpp index 18b44d1a..9d68a23f 100644 --- a/taglib/toolkit/tstring.cpp +++ b/taglib/toolkit/tstring.cpp @@ -635,13 +635,13 @@ String String::number(int n) // static return Utils::formatString("%d", n); } -TagLib::wchar &String::operator[](int i) +wchar_t &String::operator[](int i) { detach(); return d->data[i]; } -const TagLib::wchar &String::operator[](int i) const +const wchar_t &String::operator[](int i) const { return d->data[i]; } diff --git a/taglib/toolkit/tstring.h b/taglib/toolkit/tstring.h index d00d4947..839b2f23 100644 --- a/taglib/toolkit/tstring.h +++ b/taglib/toolkit/tstring.h @@ -86,8 +86,8 @@ namespace TagLib { public: #ifndef DO_NOT_DOCUMENT - typedef std::basic_string::iterator Iterator; - typedef std::basic_string::const_iterator ConstIterator; + typedef TagLib::wstring::iterator Iterator; + typedef TagLib::wstring::const_iterator ConstIterator; #endif /** @@ -395,12 +395,12 @@ namespace TagLib { /*! * Returns a reference to the character at position \a i. */ - wchar &operator[](int i); + wchar_t &operator[](int i); /*! * Returns a const reference to the character at position \a i. */ - const wchar &operator[](int i) const; + const wchar_t &operator[](int i) const; /*! * Compares each character of the String with each character of \a s and diff --git a/tests/test_ogg.cpp b/tests/test_ogg.cpp index 6a671d48..45620d61 100644 --- a/tests/test_ogg.cpp +++ b/tests/test_ogg.cpp @@ -49,7 +49,7 @@ public: String longText(std::string(128 * 1024, ' ').c_str()); for (size_t i = 0; i < longText.length(); ++i) - longText[i] = static_cast(L'A' + (i % 26)); + longText[i] = static_cast(L'A' + (i % 26)); { Vorbis::File f(newname.c_str()); diff --git a/tests/test_oggflac.cpp b/tests/test_oggflac.cpp index 737a7261..58781ea0 100644 --- a/tests/test_oggflac.cpp +++ b/tests/test_oggflac.cpp @@ -54,7 +54,7 @@ public: String longText(std::string(128 * 1024, ' ').c_str()); for(size_t i = 0; i < longText.length(); ++i) - longText[i] = static_cast(L'A' + (i % 26)); + longText[i] = static_cast(L'A' + (i % 26)); { Ogg::FLAC::File f(newname.c_str()); diff --git a/tests/test_opus.cpp b/tests/test_opus.cpp index 3113e55f..1d08d017 100644 --- a/tests/test_opus.cpp +++ b/tests/test_opus.cpp @@ -70,7 +70,7 @@ public: String longText(std::string(128 * 1024, ' ').c_str()); for(size_t i = 0; i < longText.length(); ++i) - longText[i] = static_cast(L'A' + (i % 26)); + longText[i] = static_cast(L'A' + (i % 26)); { Ogg::Opus::File f(newname.c_str()); diff --git a/tests/test_speex.cpp b/tests/test_speex.cpp index 258795ab..2bbdbc90 100644 --- a/tests/test_speex.cpp +++ b/tests/test_speex.cpp @@ -35,7 +35,7 @@ public: String longText(std::string(128 * 1024, ' ').c_str()); for (size_t i = 0; i < longText.length(); ++i) - longText[i] = static_cast(L'A' + (i % 26)); + longText[i] = static_cast(L'A' + (i % 26)); { Ogg::Speex::File f(newname.c_str()); From d97292c59320826e275299a7fcafc5b16c821a6d Mon Sep 17 00:00:00 2001 From: Tsuda Kageyu Date: Wed, 2 Dec 2015 11:36:54 +0900 Subject: [PATCH 19/33] Amend some comments refer to the 'offset_t' type. It no longer exists. --- taglib/mpeg/id3v2/id3v2tag.cpp | 2 +- taglib/xm/xmfile.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/taglib/mpeg/id3v2/id3v2tag.cpp b/taglib/mpeg/id3v2/id3v2tag.cpp index ac1bd66c..224a607f 100644 --- a/taglib/mpeg/id3v2/id3v2tag.cpp +++ b/taglib/mpeg/id3v2/id3v2tag.cpp @@ -609,7 +609,7 @@ ByteVector ID3v2::Tag::render(int version) const } // Compute the amount of padding, and append that to tagData. - // TODO: Should be calculated in offset_t in taglib2. + // TODO: Should be calculated in long long in taglib2. long originalSize = d->header.tagSize(); long paddingSize = originalSize - (tagData.size() - Header::size()); diff --git a/taglib/xm/xmfile.cpp b/taglib/xm/xmfile.cpp index a0bb5353..5919abac 100644 --- a/taglib/xm/xmfile.cpp +++ b/taglib/xm/xmfile.cpp @@ -421,7 +421,7 @@ bool XM::File::save() if(!readU16L(patternCount) || !readU16L(instrumentCount)) return false; - long pos = 60 + headerSize; // should be offset_t in taglib2. + long pos = 60 + headerSize; // should be long long in taglib2. // need to read patterns again in order to seek to the instruments: for(ushort i = 0; i < patternCount; ++ i) { From 83ffc87598fecebea903730f1522ed2238dcdcaa Mon Sep 17 00:00:00 2001 From: Tsuda Kageyu Date: Wed, 2 Dec 2015 12:00:43 +0900 Subject: [PATCH 20/33] Surround some internal stuff by anonymous namespaces. --- taglib/ape/apetag.cpp | 28 +++++++----- taglib/mpc/mpcproperties.cpp | 68 ++++++++++++++-------------- taglib/wavpack/wavpackproperties.cpp | 4 +- 3 files changed, 53 insertions(+), 47 deletions(-) diff --git a/taglib/ape/apetag.cpp b/taglib/ape/apetag.cpp index 71a98c18..4e282faa 100644 --- a/taglib/ape/apetag.cpp +++ b/taglib/ape/apetag.cpp @@ -167,14 +167,18 @@ void APE::Tag::setTrack(uint i) addValue("TRACK", String::number(i), true); } -// conversions of tag keys between what we use in PropertyMap and what's usual -// for APE tags -static const TagLib::uint keyConversionsSize = 5; //usual, APE -static const char *keyConversions[][2] = {{"TRACKNUMBER", "TRACK" }, - {"DATE", "YEAR" }, - {"ALBUMARTIST", "ALBUM ARTIST"}, - {"DISCNUMBER", "DISC" }, - {"REMIXER", "MIXARTIST" }}; +namespace +{ + // conversions of tag keys between what we use in PropertyMap and what's usual + // for APE tags + // usual, APE + const char *keyConversions[][2] = {{"TRACKNUMBER", "TRACK" }, + {"DATE", "YEAR" }, + {"ALBUMARTIST", "ALBUM ARTIST"}, + {"DISCNUMBER", "DISC" }, + {"REMIXER", "MIXARTIST" }}; + const size_t keyConversionsSize = sizeof(keyConversions) / sizeof(keyConversions[0]); +} PropertyMap APE::Tag::properties() const { @@ -184,14 +188,16 @@ PropertyMap APE::Tag::properties() const String tagName = it->first.upper(); // if the item is Binary or Locator, or if the key is an invalid string, // add to unsupportedData - if(it->second.type() != Item::Text || tagName.isEmpty()) + if(it->second.type() != Item::Text || tagName.isEmpty()) { properties.unsupportedData().append(it->first); + } else { // Some tags need to be handled specially - for(uint i = 0; i < keyConversionsSize; ++i) + for(size_t i = 0; i < keyConversionsSize; ++i) { if(tagName == keyConversions[i][1]) tagName = keyConversions[i][0]; - properties[tagName].append(it->second.toStringList()); + } + properties[tagName].append(it->second.toStringList()); } } return properties; diff --git a/taglib/mpc/mpcproperties.cpp b/taglib/mpc/mpcproperties.cpp index 2eb2f2a6..9437f22e 100644 --- a/taglib/mpc/mpcproperties.cpp +++ b/taglib/mpc/mpcproperties.cpp @@ -163,42 +163,42 @@ int MPC::Properties::albumPeak() const // private members //////////////////////////////////////////////////////////////////////////////// -unsigned long readSize(File *file, TagLib::uint &sizeLength, bool &eof) -{ - sizeLength = 0; - eof = false; - - unsigned char tmp; - unsigned long size = 0; - - do { - const ByteVector b = file->readBlock(1); - if(b.isEmpty()) { - eof = true; - break; - } - - tmp = b[0]; - size = (size << 7) | (tmp & 0x7F); - sizeLength++; - } while((tmp & 0x80)); - return size; -} - -unsigned long readSize(const ByteVector &data, TagLib::uint &pos) -{ - unsigned char tmp; - unsigned long size = 0; - - do { - tmp = data[pos++]; - size = (size << 7) | (tmp & 0x7F); - } while((tmp & 0x80) && (pos < data.size())); - return size; -} - namespace { + unsigned long readSize(File *file, TagLib::uint &sizeLength, bool &eof) + { + sizeLength = 0; + eof = false; + + unsigned char tmp; + unsigned long size = 0; + + do { + const ByteVector b = file->readBlock(1); + if(b.isEmpty()) { + eof = true; + break; + } + + tmp = b[0]; + size = (size << 7) | (tmp & 0x7F); + sizeLength++; + } while((tmp & 0x80)); + return size; + } + + unsigned long readSize(const ByteVector &data, TagLib::uint &pos) + { + unsigned char tmp; + unsigned long size = 0; + + do { + tmp = data[pos++]; + size = (size << 7) | (tmp & 0x7F); + } while((tmp & 0x80) && (pos < data.size())); + return size; + } + // This array looks weird, but the same as original MusePack code found at: // https://www.musepack.net/index.php?pg=src const unsigned short sftable [8] = { 44100, 48000, 37800, 32000, 0, 0, 0, 0 }; diff --git a/taglib/wavpack/wavpackproperties.cpp b/taglib/wavpack/wavpackproperties.cpp index 4e4ccd58..12d47c44 100644 --- a/taglib/wavpack/wavpackproperties.cpp +++ b/taglib/wavpack/wavpackproperties.cpp @@ -155,8 +155,8 @@ namespace #define SRATE_LSB 23 #define SRATE_MASK (0xfL << SRATE_LSB) -#define MIN_STREAM_VERS 0x402 -#define MAX_STREAM_VERS 0x410 +#define MIN_STREAM_VERS 0x402 +#define MAX_STREAM_VERS 0x410 #define FINAL_BLOCK 0x1000 From bc8b60ea46e2572c11b8a85cd9b9149b1efa2962 Mon Sep 17 00:00:00 2001 From: Tsuda Kageyu Date: Wed, 2 Dec 2015 14:08:20 +0900 Subject: [PATCH 21/33] Remove an unreachable statement. --- bindings/c/tag_c.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/bindings/c/tag_c.cpp b/bindings/c/tag_c.cpp index b0fd8c0b..33c61229 100644 --- a/bindings/c/tag_c.cpp +++ b/bindings/c/tag_c.cpp @@ -121,8 +121,6 @@ TagLib_File *taglib_file_new_type(const char *filename, TagLib_File_Type type) default: return 0; } - - return 0; } void taglib_file_free(TagLib_File *file) From e475e31e0d8f26635537992632800771a35461d4 Mon Sep 17 00:00:00 2001 From: Tsuda Kageyu Date: Wed, 2 Dec 2015 14:28:41 +0900 Subject: [PATCH 22/33] Update NEWS. --- NEWS | 1 + 1 file changed, 1 insertion(+) diff --git a/NEWS b/NEWS index 86680008..81580c7d 100644 --- a/NEWS +++ b/NEWS @@ -12,6 +12,7 @@ * Fixed updating the comment field of Vorbis comments. * Added BUILD_BINDINGS build option. * Added ENABLE_CCACHE build option. + * Replaced ENABLE_STATIC build option with BUILD_SHARED_LIBS. * Marked ByteVector::null and ByteVector::isNull() deprecated. * Marked String::null and ByteVector::isNull() deprecated. * Marked XiphComment::removeField() deprecated. From 7b854c5434033513fa647a3c0197b35daf523e7c Mon Sep 17 00:00:00 2001 From: Tsuda Kageyu Date: Wed, 2 Dec 2015 15:01:10 +0900 Subject: [PATCH 23/33] Update NEWS. --- NEWS | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/NEWS b/NEWS index 81580c7d..bec7d290 100644 --- a/NEWS +++ b/NEWS @@ -2,16 +2,17 @@ * New API for creating FileRef from IOStream. * Added support for ID3v2 PCST and WFED frames. + * Added support for pictures in XiphComment. * Added String::clear(). * Added alternative functions to XiphComment::removeField(). + * Added BUILD_BINDINGS build option. + * Added ENABLE_CCACHE build option. * Better handling of duplicate ID3v2 tags in all kinds of files. * Better handling of duplicate tag chunks in WAV files. * Better handling of duplicate tag chunks in AIFF files. * Fixed crash when calling File::properties() after strip(). * Fixed possible file corruptions when saving ASF files. * Fixed updating the comment field of Vorbis comments. - * Added BUILD_BINDINGS build option. - * Added ENABLE_CCACHE build option. * Replaced ENABLE_STATIC build option with BUILD_SHARED_LIBS. * Marked ByteVector::null and ByteVector::isNull() deprecated. * Marked String::null and ByteVector::isNull() deprecated. From 2cb89b85c991e2972715c7e51c5d8576a76e3a5f Mon Sep 17 00:00:00 2001 From: Tsuda Kageyu Date: Wed, 2 Dec 2015 17:33:11 +0900 Subject: [PATCH 24/33] Make use of List iterators and setAutoDelete() in XiphComment. --- taglib/ogg/xiphcomment.cpp | 45 ++++++++++++++++++++++---------------- 1 file changed, 26 insertions(+), 19 deletions(-) diff --git a/taglib/ogg/xiphcomment.cpp b/taglib/ogg/xiphcomment.cpp index d825333e..6267ee8c 100644 --- a/taglib/ogg/xiphcomment.cpp +++ b/taglib/ogg/xiphcomment.cpp @@ -32,12 +32,24 @@ using namespace TagLib; +namespace +{ + typedef Ogg::FieldListMap::Iterator FieldIterator; + typedef Ogg::FieldListMap::ConstIterator FieldConstIterator; -typedef List PictureList; + typedef List PictureList; + typedef PictureList::Iterator PictureIterator; + typedef PictureList::Iterator PictureConstIterator; +} class Ogg::XiphComment::XiphCommentPrivate { public: + XiphCommentPrivate() + { + pictureList.setAutoDelete(true); + } + FieldListMap fieldListMap; String vendorID; String commentField; @@ -48,20 +60,21 @@ public: // public members //////////////////////////////////////////////////////////////////////////////// -Ogg::XiphComment::XiphComment() : TagLib::Tag() +Ogg::XiphComment::XiphComment() : + TagLib::Tag(), + d(new XiphCommentPrivate()) { - d = new XiphCommentPrivate; } -Ogg::XiphComment::XiphComment(const ByteVector &data) : TagLib::Tag() +Ogg::XiphComment::XiphComment(const ByteVector &data) : + TagLib::Tag(), + d(new XiphCommentPrivate()) { - d = new XiphCommentPrivate; parse(data); } Ogg::XiphComment::~XiphComment() { - removePictures(); delete d; } @@ -178,10 +191,10 @@ void Ogg::XiphComment::setTrack(uint i) bool Ogg::XiphComment::isEmpty() const { - FieldListMap::ConstIterator it = d->fieldListMap.begin(); - for(; it != d->fieldListMap.end(); ++it) + for(FieldConstIterator it = d->fieldListMap.begin(); it != d->fieldListMap.end(); ++it) { if(!(*it).second.isEmpty()) return false; + } return true; } @@ -190,8 +203,7 @@ TagLib::uint Ogg::XiphComment::fieldCount() const { uint count = 0; - FieldListMap::ConstIterator it = d->fieldListMap.begin(); - for(; it != d->fieldListMap.end(); ++it) + for(FieldConstIterator it = d->fieldListMap.begin(); it != d->fieldListMap.end(); ++it) count += (*it).second.size(); count += d->pictureList.size(); @@ -213,7 +225,7 @@ 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) + for(FieldConstIterator it = d->fieldListMap.begin(); it != d->fieldListMap.end(); ++it) if (!properties.contains(it->first)) toRemove.append(it->first); @@ -306,7 +318,7 @@ bool Ogg::XiphComment::contains(const String &key) const void Ogg::XiphComment::removePicture(FLAC::Picture *picture, bool del) { - PictureList::Iterator it = d->pictureList.find(picture); + PictureIterator it = d->pictureList.find(picture); if(it != d->pictureList.end()) d->pictureList.erase(it); @@ -316,11 +328,7 @@ void Ogg::XiphComment::removePicture(FLAC::Picture *picture, bool del) void Ogg::XiphComment::removePictures() { - PictureList newList; - for(uint i = 0; i < d->pictureList.size(); i++) { - delete d->pictureList[i]; - } - d->pictureList = newList; + d->pictureList.clear(); } void Ogg::XiphComment::addPicture(FLAC::Picture * picture) @@ -328,7 +336,6 @@ void Ogg::XiphComment::addPicture(FLAC::Picture * picture) d->pictureList.append(picture); } - List Ogg::XiphComment::pictureList() { return d->pictureList; @@ -380,7 +387,7 @@ ByteVector Ogg::XiphComment::render(bool addFramingBit) const } } - for(PictureList::ConstIterator it = d->pictureList.begin(); it != d->pictureList.end(); ++it) { + for(PictureConstIterator it = d->pictureList.begin(); it != d->pictureList.end(); ++it) { ByteVector picture = (*it)->render().toBase64(); data.append(ByteVector::fromUInt(picture.size() + 23, false)); data.append("METADATA_BLOCK_PICTURE="); From 8bdddaabce75106cb359a9a0c7831c2d236e096e Mon Sep 17 00:00:00 2001 From: Tsuda Kageyu Date: Wed, 2 Dec 2015 18:11:52 +0900 Subject: [PATCH 25/33] Use a standard type rather than TagLib::uchar. This won't break the ABI compatibility. --- taglib/it/itproperties.cpp | 36 +++++++++---------- taglib/it/itproperties.h | 24 ++++++------- taglib/mod/modfilebase.cpp | 4 +-- taglib/mod/modfilebase.h | 4 +-- taglib/mod/modfileprivate.h | 4 +-- taglib/mod/modproperties.cpp | 6 ++-- taglib/mod/modproperties.h | 4 +-- taglib/mp4/mp4item.cpp | 6 ++-- taglib/mp4/mp4item.h | 4 +-- taglib/mp4/mp4tag.cpp | 2 +- taglib/mpeg/id3v1/id3v1tag.cpp | 8 ++--- .../id3v2/frames/eventtimingcodesframe.cpp | 2 +- taglib/mpeg/id3v2/id3v2header.cpp | 2 +- taglib/mpeg/id3v2/id3v2synchdata.cpp | 2 +- taglib/mpeg/mpegfile.cpp | 4 +-- taglib/mpeg/mpegheader.cpp | 8 ++--- taglib/ogg/oggpageheader.cpp | 14 ++++---- taglib/ogg/opus/opusproperties.cpp | 4 +-- taglib/ogg/vorbis/vorbisproperties.cpp | 2 +- taglib/riff/aiff/aiffproperties.cpp | 3 +- taglib/riff/riffutils.h | 2 +- taglib/s3m/s3mfile.cpp | 2 +- taglib/s3m/s3mproperties.cpp | 24 ++++++------- taglib/s3m/s3mproperties.h | 16 ++++----- taglib/toolkit/tbytevector.cpp | 6 ++-- taglib/toolkit/tstring.cpp | 10 +++--- taglib/xm/xmfile.cpp | 22 ++++++------ tests/test_bytevector.cpp | 12 +++---- tests/test_id3v2.cpp | 2 +- tests/test_it.cpp | 12 +++---- tests/test_mod.cpp | 2 +- tests/test_s3m.cpp | 8 ++--- 32 files changed, 131 insertions(+), 130 deletions(-) diff --git a/taglib/it/itproperties.cpp b/taglib/it/itproperties.cpp index 0359533d..8b1fc43c 100644 --- a/taglib/it/itproperties.cpp +++ b/taglib/it/itproperties.cpp @@ -55,12 +55,12 @@ public: ushort compatibleVersion; ushort flags; ushort special; - uchar globalVolume; - uchar mixVolume; - uchar tempo; - uchar bpmSpeed; - uchar panningSeparation; - uchar pitchWheelDepth; + unsigned char globalVolume; + unsigned char mixVolume; + unsigned char tempo; + unsigned char bpmSpeed; + unsigned char panningSeparation; + unsigned char pitchWheelDepth; }; IT::Properties::Properties(AudioProperties::ReadStyle propertiesStyle) : @@ -149,32 +149,32 @@ TagLib::ushort IT::Properties::special() const return d->special; } -uchar IT::Properties::globalVolume() const +unsigned char IT::Properties::globalVolume() const { return d->globalVolume; } -uchar IT::Properties::mixVolume() const +unsigned char IT::Properties::mixVolume() const { return d->mixVolume; } -uchar IT::Properties::tempo() const +unsigned char IT::Properties::tempo() const { return d->tempo; } -uchar IT::Properties::bpmSpeed() const +unsigned char IT::Properties::bpmSpeed() const { return d->bpmSpeed; } -uchar IT::Properties::panningSeparation() const +unsigned char IT::Properties::panningSeparation() const { return d->panningSeparation; } -uchar IT::Properties::pitchWheelDepth() const +unsigned char IT::Properties::pitchWheelDepth() const { return d->pitchWheelDepth; } @@ -224,32 +224,32 @@ void IT::Properties::setVersion(ushort version) d->version = version; } -void IT::Properties::setGlobalVolume(uchar globalVolume) +void IT::Properties::setGlobalVolume(unsigned char globalVolume) { d->globalVolume = globalVolume; } -void IT::Properties::setMixVolume(uchar mixVolume) +void IT::Properties::setMixVolume(unsigned char mixVolume) { d->mixVolume = mixVolume; } -void IT::Properties::setTempo(uchar tempo) +void IT::Properties::setTempo(unsigned char tempo) { d->tempo = tempo; } -void IT::Properties::setBpmSpeed(uchar bpmSpeed) +void IT::Properties::setBpmSpeed(unsigned char bpmSpeed) { d->bpmSpeed = bpmSpeed; } -void IT::Properties::setPanningSeparation(uchar panningSeparation) +void IT::Properties::setPanningSeparation(unsigned char panningSeparation) { d->panningSeparation = panningSeparation; } -void IT::Properties::setPitchWheelDepth(uchar pitchWheelDepth) +void IT::Properties::setPitchWheelDepth(unsigned char pitchWheelDepth) { d->pitchWheelDepth = pitchWheelDepth; } diff --git a/taglib/it/itproperties.h b/taglib/it/itproperties.h index 060ad358..e2da6e66 100644 --- a/taglib/it/itproperties.h +++ b/taglib/it/itproperties.h @@ -67,12 +67,12 @@ namespace TagLib { ushort compatibleVersion() const; ushort flags() const; ushort special() const; - uchar globalVolume() const; - uchar mixVolume() const; - uchar tempo() const; - uchar bpmSpeed() const; - uchar panningSeparation() const; - uchar pitchWheelDepth() const; + unsigned char globalVolume() const; + unsigned char mixVolume() const; + unsigned char tempo() const; + unsigned char bpmSpeed() const; + unsigned char panningSeparation() const; + unsigned char pitchWheelDepth() const; void setChannels(int channels); void setLengthInPatterns(ushort lengthInPatterns); @@ -83,12 +83,12 @@ namespace TagLib { void setCompatibleVersion(ushort compatibleVersion); void setFlags (ushort flags); void setSpecial (ushort special); - void setGlobalVolume(uchar globalVolume); - void setMixVolume (uchar mixVolume); - void setTempo (uchar tempo); - void setBpmSpeed (uchar bpmSpeed); - void setPanningSeparation(uchar panningSeparation); - void setPitchWheelDepth (uchar pitchWheelDepth); + void setGlobalVolume(unsigned char globalVolume); + void setMixVolume (unsigned char mixVolume); + void setTempo (unsigned char tempo); + void setBpmSpeed (unsigned char bpmSpeed); + void setPanningSeparation(unsigned char panningSeparation); + void setPitchWheelDepth (unsigned char pitchWheelDepth); private: Properties(const Properties&); diff --git a/taglib/mod/modfilebase.cpp b/taglib/mod/modfilebase.cpp index e074dac8..a73e9367 100644 --- a/taglib/mod/modfilebase.cpp +++ b/taglib/mod/modfilebase.cpp @@ -55,7 +55,7 @@ bool Mod::FileBase::readString(String &s, ulong size) return true; } -void Mod::FileBase::writeByte(uchar byte) +void Mod::FileBase::writeByte(unsigned char byte) { ByteVector data(1, byte); writeBlock(data); @@ -81,7 +81,7 @@ void Mod::FileBase::writeU32B(ulong number) writeBlock(ByteVector::fromUInt(number, true)); } -bool Mod::FileBase::readByte(uchar &byte) +bool Mod::FileBase::readByte(unsigned char &byte) { ByteVector data(readBlock(1)); if(data.size() < 1) return false; diff --git a/taglib/mod/modfilebase.h b/taglib/mod/modfilebase.h index 383bde11..8b483d38 100644 --- a/taglib/mod/modfilebase.h +++ b/taglib/mod/modfilebase.h @@ -41,14 +41,14 @@ namespace TagLib { FileBase(IOStream *stream); void writeString(const String &s, ulong size, char padding = 0); - void writeByte(uchar byte); + void writeByte(unsigned char byte); void writeU16L(ushort number); void writeU32L(ulong number); void writeU16B(ushort number); void writeU32B(ulong number); bool readString(String &s, ulong size); - bool readByte(uchar &byte); + bool readByte(unsigned char &byte); bool readU16L(ushort &number); bool readU32L(ulong &number); bool readU16B(ushort &number); diff --git a/taglib/mod/modfileprivate.h b/taglib/mod/modfileprivate.h index 19a30019..7aa52db1 100644 --- a/taglib/mod/modfileprivate.h +++ b/taglib/mod/modfileprivate.h @@ -37,7 +37,7 @@ setter(number); \ } -#define READ_BYTE(setter) READ(setter,uchar,readByte) +#define READ_BYTE(setter) READ(setter,unsigned char,readByte) #define READ_U16L(setter) READ(setter,ushort,readU16L) #define READ_U32L(setter) READ(setter,ulong,readU32L) #define READ_U16B(setter) READ(setter,ushort,readU16B) @@ -54,7 +54,7 @@ type name = 0; \ READ_ASSERT(read(name)); -#define READ_BYTE_AS(name) READ_AS(uchar,name,readByte) +#define READ_BYTE_AS(name) READ_AS(unsigned char,name,readByte) #define READ_U16L_AS(name) READ_AS(ushort,name,readU16L) #define READ_U32L_AS(name) READ_AS(ulong,name,readU32L) #define READ_U16B_AS(name) READ_AS(ushort,name,readU16B) diff --git a/taglib/mod/modproperties.cpp b/taglib/mod/modproperties.cpp index db5a98e2..86fa3845 100644 --- a/taglib/mod/modproperties.cpp +++ b/taglib/mod/modproperties.cpp @@ -36,7 +36,7 @@ public: int channels; uint instrumentCount; - uchar lengthInPatterns; + unsigned char lengthInPatterns; }; Mod::Properties::Properties(AudioProperties::ReadStyle propertiesStyle) : @@ -85,7 +85,7 @@ TagLib::uint Mod::Properties::instrumentCount() const return d->instrumentCount; } -uchar Mod::Properties::lengthInPatterns() const +unsigned char Mod::Properties::lengthInPatterns() const { return d->lengthInPatterns; } @@ -100,7 +100,7 @@ void Mod::Properties::setInstrumentCount(uint instrumentCount) d->instrumentCount = instrumentCount; } -void Mod::Properties::setLengthInPatterns(uchar lengthInPatterns) +void Mod::Properties::setLengthInPatterns(unsigned char lengthInPatterns) { d->lengthInPatterns = lengthInPatterns; } diff --git a/taglib/mod/modproperties.h b/taglib/mod/modproperties.h index ac4bf7f3..cf0f9e7b 100644 --- a/taglib/mod/modproperties.h +++ b/taglib/mod/modproperties.h @@ -43,12 +43,12 @@ namespace TagLib { int channels() const; uint instrumentCount() const; - uchar lengthInPatterns() const; + unsigned char lengthInPatterns() const; void setChannels(int channels); void setInstrumentCount(uint sampleCount); - void setLengthInPatterns(uchar lengthInPatterns); + void setLengthInPatterns(unsigned char lengthInPatterns); private: friend class File; diff --git a/taglib/mp4/mp4item.cpp b/taglib/mp4/mp4item.cpp index d36e5200..f7edbb55 100644 --- a/taglib/mp4/mp4item.cpp +++ b/taglib/mp4/mp4item.cpp @@ -44,7 +44,7 @@ public: bool m_bool; int m_int; IntPair m_intPair; - uchar m_byte; + unsigned char m_byte; uint m_uint; long long m_longlong; }; @@ -98,7 +98,7 @@ MP4::Item::Item(int value) : d->m_int = value; } -MP4::Item::Item(uchar value) : +MP4::Item::Item(unsigned char value) : d(new ItemPrivate()) { d->m_byte = value; @@ -163,7 +163,7 @@ MP4::Item::toInt() const return d->m_int; } -uchar +unsigned char MP4::Item::toByte() const { return d->m_byte; diff --git a/taglib/mp4/mp4item.h b/taglib/mp4/mp4item.h index 38b6c25e..63fc93bd 100644 --- a/taglib/mp4/mp4item.h +++ b/taglib/mp4/mp4item.h @@ -57,7 +57,7 @@ namespace TagLib { ~Item(); Item(int value); - Item(uchar value); + Item(unsigned char value); Item(uint value); Item(long long value); Item(bool value); @@ -70,7 +70,7 @@ namespace TagLib { AtomDataType atomDataType() const; int toInt() const; - uchar toByte() const; + unsigned char toByte() const; uint toUInt() const; long long toLongLong() const; bool toBool() const; diff --git a/taglib/mp4/mp4tag.cpp b/taglib/mp4/mp4tag.cpp index 84219196..6ad75a87 100644 --- a/taglib/mp4/mp4tag.cpp +++ b/taglib/mp4/mp4tag.cpp @@ -189,7 +189,7 @@ MP4::Tag::parseByte(const MP4::Atom *atom) { ByteVectorList data = parseData(atom); if(!data.isEmpty()) { - addItem(atom->name, (uchar)data[0].at(0)); + addItem(atom->name, static_cast(data[0].at(0))); } } diff --git a/taglib/mpeg/id3v1/id3v1tag.cpp b/taglib/mpeg/id3v1/id3v1tag.cpp index dd32326f..1ca297e2 100644 --- a/taglib/mpeg/id3v1/id3v1tag.cpp +++ b/taglib/mpeg/id3v1/id3v1tag.cpp @@ -50,8 +50,8 @@ public: String album; String year; String comment; - uchar track; - uchar genre; + unsigned char track; + unsigned char genre; }; //////////////////////////////////////////////////////////////////////////////// @@ -251,12 +251,12 @@ void ID3v1::Tag::parse(const ByteVector &data) // ID3v1.1 detected d->comment = stringHandler->parse(data.mid(offset, 28)); - d->track = uchar(data[offset + 29]); + d->track = static_cast(data[offset + 29]); } else d->comment = data.mid(offset, 30); offset += 30; - d->genre = uchar(data[offset]); + d->genre = static_cast(data[offset]); } diff --git a/taglib/mpeg/id3v2/frames/eventtimingcodesframe.cpp b/taglib/mpeg/id3v2/frames/eventtimingcodesframe.cpp index 70214bad..6a3f7d26 100644 --- a/taglib/mpeg/id3v2/frames/eventtimingcodesframe.cpp +++ b/taglib/mpeg/id3v2/frames/eventtimingcodesframe.cpp @@ -109,7 +109,7 @@ void EventTimingCodesFrame::parseFields(const ByteVector &data) int pos = 1; d->synchedEvents.clear(); while(pos + 4 < end) { - EventType type = EventType(uchar(data[pos++])); + EventType type = static_cast(static_cast(data[pos++])); uint time = data.toUInt(pos, true); pos += 4; d->synchedEvents.append(SynchedEvent(time, type)); diff --git a/taglib/mpeg/id3v2/id3v2header.cpp b/taglib/mpeg/id3v2/id3v2header.cpp index 6e567193..69d700ee 100644 --- a/taglib/mpeg/id3v2/id3v2header.cpp +++ b/taglib/mpeg/id3v2/id3v2header.cpp @@ -212,7 +212,7 @@ void Header::parse(const ByteVector &data) } for(ByteVector::ConstIterator it = sizeData.begin(); it != sizeData.end(); it++) { - if(uchar(*it) >= 128) { + if(static_cast(*it) >= 128) { d->tagSize = 0; debug("TagLib::ID3v2::Header::parse() - One of the size bytes in the id3v2 header was greater than the allowed 128."); return; diff --git a/taglib/mpeg/id3v2/id3v2synchdata.cpp b/taglib/mpeg/id3v2/id3v2synchdata.cpp index 4acfd914..03767371 100644 --- a/taglib/mpeg/id3v2/id3v2synchdata.cpp +++ b/taglib/mpeg/id3v2/id3v2synchdata.cpp @@ -67,7 +67,7 @@ ByteVector SynchData::fromUInt(uint value) ByteVector v(4, 0); for(int i = 0; i < 4; i++) - v[i] = uchar(value >> ((3 - i) * 7) & 0x7f); + v[i] = static_cast(value >> ((3 - i) * 7) & 0x7f); return v; } diff --git a/taglib/mpeg/mpegfile.cpp b/taglib/mpeg/mpegfile.cpp index 523f804c..adf7a850 100644 --- a/taglib/mpeg/mpegfile.cpp +++ b/taglib/mpeg/mpegfile.cpp @@ -45,12 +45,12 @@ namespace * starts with \e 111 is a bit more tricky, hence these functions. */ - inline bool firstSyncByte(uchar byte) + inline bool firstSyncByte(unsigned char byte) { return (byte == 0xFF); } - inline bool secondSynchByte(uchar byte) + inline bool secondSynchByte(unsigned char byte) { return ((byte & 0xE0) == 0xE0); } diff --git a/taglib/mpeg/mpegheader.cpp b/taglib/mpeg/mpegheader.cpp index 0c9a0f1c..01cc6c57 100644 --- a/taglib/mpeg/mpegheader.cpp +++ b/taglib/mpeg/mpegheader.cpp @@ -164,7 +164,7 @@ MPEG::Header &MPEG::Header::operator=(const Header &h) void MPEG::Header::parse(const ByteVector &data) { - if(data.size() < 4 || uchar(data[0]) != 0xff) { + if(data.size() < 4 || static_cast(data[0]) != 0xff) { debug("MPEG::Header::parse() -- First byte did not match MPEG synch."); return; } @@ -219,7 +219,7 @@ void MPEG::Header::parse(const ByteVector &data) // The bitrate index is encoded as the first 4 bits of the 3rd byte, // i.e. 1111xxxx - int i = uchar(data[2]) >> 4; + int i = static_cast(data[2]) >> 4; d->bitrate = bitrates[versionIndex][layerIndex][i]; @@ -233,7 +233,7 @@ void MPEG::Header::parse(const ByteVector &data) // The sample rate index is encoded as two bits in the 3nd byte, i.e. xxxx11xx - i = uchar(data[2]) >> 2 & 0x03; + i = static_cast(data[2]) >> 2 & 0x03; d->sampleRate = sampleRates[d->version][i]; @@ -245,7 +245,7 @@ void MPEG::Header::parse(const ByteVector &data) // The channel mode is encoded as a 2 bit value at the end of the 3nd byte, // i.e. xxxxxx11 - d->channelMode = ChannelMode((uchar(data[3]) & 0xC0) >> 6); + d->channelMode = static_cast((static_cast(data[3]) & 0xC0) >> 6); // TODO: Add mode extension for completeness diff --git a/taglib/ogg/oggpageheader.cpp b/taglib/ogg/oggpageheader.cpp index b9333135..54c6c259 100644 --- a/taglib/ogg/oggpageheader.cpp +++ b/taglib/ogg/oggpageheader.cpp @@ -222,7 +222,7 @@ ByteVector Ogg::PageHeader::render() const ByteVector pageSegments = lacingValues(); - data.append(char(uchar(pageSegments.size()))); + data.append(static_cast(pageSegments.size())); data.append(pageSegments); return data; @@ -263,7 +263,7 @@ void Ogg::PageHeader::read() // length portion of the page header. After reading the number of page // segments we'll then read in the corresponding data for this count. - int pageSegmentCount = uchar(data[26]); + int pageSegmentCount = static_cast(data[26]); ByteVector pageSegments = d->file->readBlock(pageSegmentCount); @@ -279,10 +279,10 @@ void Ogg::PageHeader::read() int packetSize = 0; for(int i = 0; i < pageSegmentCount; i++) { - d->dataSize += uchar(pageSegments[i]); - packetSize += uchar(pageSegments[i]); + d->dataSize += static_cast(pageSegments[i]); + packetSize += static_cast(pageSegments[i]); - if(uchar(pageSegments[i]) < 255) { + if(static_cast(pageSegments[i]) < 255) { d->packetSizes.append(packetSize); packetSize = 0; } @@ -313,10 +313,10 @@ ByteVector Ogg::PageHeader::lacingValues() const div_t n = div(*it, 255); for(int i = 0; i < n.quot; i++) - data.append(char(uchar(255))); + data.append(static_cast(255)); if(it != --sizes.end() || d->lastPacketCompleted) - data.append(char(uchar(n.rem))); + data.append(static_cast(n.rem)); } return data; diff --git a/taglib/ogg/opus/opusproperties.cpp b/taglib/ogg/opus/opusproperties.cpp index c8aff624..365658f8 100644 --- a/taglib/ogg/opus/opusproperties.cpp +++ b/taglib/ogg/opus/opusproperties.cpp @@ -130,11 +130,11 @@ void Opus::Properties::read(File *file) uint pos = 8; // *Version* (8 bits, unsigned) - d->opusVersion = uchar(data.at(pos)); + d->opusVersion = static_cast(data.at(pos)); pos += 1; // *Output Channel Count* 'C' (8 bits, unsigned) - d->channels = uchar(data.at(pos)); + d->channels = static_cast(data.at(pos)); pos += 1; // *Pre-skip* (16 bits, unsigned, little endian) diff --git a/taglib/ogg/vorbis/vorbisproperties.cpp b/taglib/ogg/vorbis/vorbisproperties.cpp index d9dfc0a8..cef0b395 100644 --- a/taglib/ogg/vorbis/vorbisproperties.cpp +++ b/taglib/ogg/vorbis/vorbisproperties.cpp @@ -156,7 +156,7 @@ void Vorbis::Properties::read(File *file) d->vorbisVersion = data.toUInt(pos, false); pos += 4; - d->channels = uchar(data[pos]); + d->channels = static_cast(data[pos]); pos += 1; d->sampleRate = data.toUInt(pos, false); diff --git a/taglib/riff/aiff/aiffproperties.cpp b/taglib/riff/aiff/aiffproperties.cpp index f074fae3..020ac6cf 100644 --- a/taglib/riff/aiff/aiffproperties.cpp +++ b/taglib/riff/aiff/aiffproperties.cpp @@ -186,6 +186,7 @@ void RIFF::AIFF::Properties::read(File *file) if(data.size() >= 23) { d->compressionType = data.mid(18, 4); - d->compressionName = String(data.mid(23, static_cast(data[22])), String::Latin1); + d->compressionName + = String(data.mid(23, static_cast(data[22])), String::Latin1); } } diff --git a/taglib/riff/riffutils.h b/taglib/riff/riffutils.h index c9270dff..42977efe 100644 --- a/taglib/riff/riffutils.h +++ b/taglib/riff/riffutils.h @@ -40,7 +40,7 @@ namespace TagLib return false; for(ByteVector::ConstIterator it = name.begin(); it != name.end(); ++it) { - const uchar c = static_cast(*it); + const int c = static_cast(*it); if(c < 32 || 127 < c) return false; } diff --git a/taglib/s3m/s3mfile.cpp b/taglib/s3m/s3mfile.cpp index f15d740b..c83e09d7 100644 --- a/taglib/s3m/s3mfile.cpp +++ b/taglib/s3m/s3mfile.cpp @@ -110,7 +110,7 @@ bool S3M::File::save() int channels = 0; for(int i = 0; i < 32; ++ i) { - uchar setting = 0; + unsigned char setting = 0; if(!readByte(setting)) return false; // or if(setting >= 128)? diff --git a/taglib/s3m/s3mproperties.cpp b/taglib/s3m/s3mproperties.cpp index 6f93eec3..de2d1ebe 100644 --- a/taglib/s3m/s3mproperties.cpp +++ b/taglib/s3m/s3mproperties.cpp @@ -51,10 +51,10 @@ public: ushort flags; ushort trackerVersion; ushort fileFormatVersion; - uchar globalVolume; - uchar masterVolume; - uchar tempo; - uchar bpmSpeed; + unsigned char globalVolume; + unsigned char masterVolume; + unsigned char tempo; + unsigned char bpmSpeed; }; S3M::Properties::Properties(AudioProperties::ReadStyle propertiesStyle) : @@ -133,22 +133,22 @@ TagLib::ushort S3M::Properties::fileFormatVersion() const return d->fileFormatVersion; } -uchar S3M::Properties::globalVolume() const +unsigned char S3M::Properties::globalVolume() const { return d->globalVolume; } -uchar S3M::Properties::masterVolume() const +unsigned char S3M::Properties::masterVolume() const { return d->masterVolume; } -uchar S3M::Properties::tempo() const +unsigned char S3M::Properties::tempo() const { return d->tempo; } -uchar S3M::Properties::bpmSpeed() const +unsigned char S3M::Properties::bpmSpeed() const { return d->bpmSpeed; } @@ -193,22 +193,22 @@ void S3M::Properties::setFileFormatVersion(ushort fileFormatVersion) d->fileFormatVersion = fileFormatVersion; } -void S3M::Properties::setGlobalVolume(uchar globalVolume) +void S3M::Properties::setGlobalVolume(unsigned char globalVolume) { d->globalVolume = globalVolume; } -void S3M::Properties::setMasterVolume(uchar masterVolume) +void S3M::Properties::setMasterVolume(unsigned char masterVolume) { d->masterVolume = masterVolume; } -void S3M::Properties::setTempo(uchar tempo) +void S3M::Properties::setTempo(unsigned char tempo) { d->tempo = tempo; } -void S3M::Properties::setBpmSpeed(uchar bpmSpeed) +void S3M::Properties::setBpmSpeed(unsigned char bpmSpeed) { d->bpmSpeed = bpmSpeed; } diff --git a/taglib/s3m/s3mproperties.h b/taglib/s3m/s3mproperties.h index 4499627f..f77d2204 100644 --- a/taglib/s3m/s3mproperties.h +++ b/taglib/s3m/s3mproperties.h @@ -58,10 +58,10 @@ namespace TagLib { ushort flags() const; ushort trackerVersion() const; ushort fileFormatVersion() const; - uchar globalVolume() const; - uchar masterVolume() const; - uchar tempo() const; - uchar bpmSpeed() const; + unsigned char globalVolume() const; + unsigned char masterVolume() const; + unsigned char tempo() const; + unsigned char bpmSpeed() const; void setChannels(int channels); @@ -72,10 +72,10 @@ namespace TagLib { void setFlags (ushort flags); void setTrackerVersion (ushort trackerVersion); void setFileFormatVersion(ushort fileFormatVersion); - void setGlobalVolume (uchar globalVolume); - void setMasterVolume (uchar masterVolume); - void setTempo (uchar tempo); - void setBpmSpeed (uchar bpmSpeed); + void setGlobalVolume (unsigned char globalVolume); + void setMasterVolume (unsigned char masterVolume); + void setTempo (unsigned char tempo); + void setBpmSpeed (unsigned char bpmSpeed); private: Properties(const Properties&); diff --git a/taglib/toolkit/tbytevector.cpp b/taglib/toolkit/tbytevector.cpp index fbdc8b7c..71bcb43a 100644 --- a/taglib/toolkit/tbytevector.cpp +++ b/taglib/toolkit/tbytevector.cpp @@ -177,7 +177,7 @@ T toNumber(const ByteVector &v, size_t offset, size_t length, bool mostSignifica T sum = 0; for(size_t i = 0; i < length; i++) { const size_t shift = (mostSignificantByteFirst ? length - 1 - i : i) * 8; - sum |= static_cast(static_cast(v[offset + i])) << shift; + sum |= static_cast(static_cast(v[offset + i])) << shift; } return sum; @@ -259,7 +259,7 @@ long double toFloat80(const ByteVector &v, size_t offset) return 0.0; } - uchar bytes[10]; + unsigned char bytes[10]; ::memcpy(bytes, v.data() + offset, 10); if(ENDIAN == Utils::LittleEndian) { @@ -695,7 +695,7 @@ TagLib::uint ByteVector::checksum() const { uint sum = 0; for(ByteVector::ConstIterator it = begin(); it != end(); ++it) - sum = (sum << 8) ^ crcTable[((sum >> 24) & 0xff) ^ uchar(*it)]; + sum = (sum << 8) ^ crcTable[((sum >> 24) & 0xff) ^ static_cast(*it)]; return sum; } diff --git a/taglib/toolkit/tstring.cpp b/taglib/toolkit/tstring.cpp index 9d68a23f..f9884da7 100644 --- a/taglib/toolkit/tstring.cpp +++ b/taglib/toolkit/tstring.cpp @@ -133,7 +133,7 @@ namespace data.resize(length); for(size_t i = 0; i < length; ++i) - data[i] = static_cast(s[i]); + data[i] = static_cast(s[i]); } // Converts a UTF-8 string into UTF-16(without BOM/CPU byte order) @@ -337,7 +337,7 @@ String::String(wchar_t c, Type t) : } String::String(char c, Type t) : - d(new StringPrivate(1, static_cast(c))) + d(new StringPrivate(1, static_cast(c))) { if(t != Latin1 && t != UTF8) { debug("String::String() -- char should not contain UTF16."); @@ -661,7 +661,7 @@ bool String::operator==(const char *s) const const wchar_t *p = toCWString(); while(*p != L'\0' || *s != '\0') { - if(*p++ != static_cast(*s++)) + if(*p++ != static_cast(*s++)) return false; } return true; @@ -703,7 +703,7 @@ String &String::operator+=(const char *s) detach(); for(int i = 0; s[i] != 0; i++) - d->data += uchar(s[i]); + d->data += static_cast(s[i]); return *this; } @@ -719,7 +719,7 @@ String &String::operator+=(char c) { detach(); - d->data += uchar(c); + d->data += static_cast(c); return *this; } diff --git a/taglib/xm/xmfile.cpp b/taglib/xm/xmfile.cpp index 5919abac..fc337ba4 100644 --- a/taglib/xm/xmfile.cpp +++ b/taglib/xm/xmfile.cpp @@ -147,10 +147,10 @@ private: uint m_size; }; -class ByteReader : public ValueReader +class ByteReader : public ValueReader { public: - ByteReader(uchar &byte) : ValueReader(byte) {} + ByteReader(unsigned char &byte) : ValueReader(byte) {} uint read(TagLib::File &file, uint limit) { @@ -258,7 +258,7 @@ public: /*! * Read a byte into \a byte. */ - StructReader &byte(uchar &byte) + StructReader &byte(unsigned char &byte) { m_readers.append(new ByteReader(byte)); return *this; @@ -553,7 +553,7 @@ void XM::File::read(bool) READ_U32L_AS(patternHeaderLength); READ_ASSERT(patternHeaderLength >= 4); - uchar packingType = 0; + unsigned char packingType = 0; ushort rowCount = 0; ushort dataSize = 0; StructReader pattern; @@ -575,7 +575,7 @@ void XM::File::read(bool) READ_ASSERT(instrumentHeaderSize >= 4); String instrumentName; - uchar instrumentType = 0; + unsigned char instrumentType = 0; ushort sampleCount = 0; StructReader instrument; @@ -598,12 +598,12 @@ void XM::File::read(bool) ulong sampleLength = 0; ulong loopStart = 0; ulong loopLength = 0; - uchar volume = 0; - uchar finetune = 0; - uchar sampleType = 0; - uchar panning = 0; - uchar noteNumber = 0; - uchar compression = 0; + unsigned char volume = 0; + unsigned char finetune = 0; + unsigned char sampleType = 0; + unsigned char panning = 0; + unsigned char noteNumber = 0; + unsigned char compression = 0; String sampleName; StructReader sample; sample.u32L(sampleLength) diff --git a/tests/test_bytevector.cpp b/tests/test_bytevector.cpp index 2848c6ce..5d82fedb 100644 --- a/tests/test_bytevector.cpp +++ b/tests/test_bytevector.cpp @@ -211,12 +211,12 @@ public: CPPUNIT_ASSERT_EQUAL((unsigned short)0xFF01, ByteVector("\xFF\x01", 2).toUShort()); CPPUNIT_ASSERT_EQUAL((unsigned short)0x01FF, ByteVector("\xFF\x01", 2).toUShort(false)); - const uchar PI32LE[] = { 0x00, 0xdb, 0x0f, 0x49, 0x40 }; - const uchar PI32BE[] = { 0x00, 0x40, 0x49, 0x0f, 0xdb }; - const uchar PI64LE[] = { 0x00, 0x18, 0x2d, 0x44, 0x54, 0xfb, 0x21, 0x09, 0x40 }; - const uchar PI64BE[] = { 0x00, 0x40, 0x09, 0x21, 0xfb, 0x54, 0x44, 0x2d, 0x18 }; - const uchar PI80LE[] = { 0x00, 0x00, 0xc0, 0x68, 0x21, 0xa2, 0xda, 0x0f, 0xc9, 0x00, 0x40 }; - const uchar PI80BE[] = { 0x00, 0x40, 0x00, 0xc9, 0x0f, 0xda, 0xa2, 0x21, 0x68, 0xc0, 0x00 }; + const unsigned char PI32LE[] = { 0x00, 0xdb, 0x0f, 0x49, 0x40 }; + const unsigned char PI32BE[] = { 0x00, 0x40, 0x49, 0x0f, 0xdb }; + const unsigned char PI64LE[] = { 0x00, 0x18, 0x2d, 0x44, 0x54, 0xfb, 0x21, 0x09, 0x40 }; + const unsigned char PI64BE[] = { 0x00, 0x40, 0x09, 0x21, 0xfb, 0x54, 0x44, 0x2d, 0x18 }; + const unsigned char PI80LE[] = { 0x00, 0x00, 0xc0, 0x68, 0x21, 0xa2, 0xda, 0x0f, 0xc9, 0x00, 0x40 }; + const unsigned char PI80BE[] = { 0x00, 0x40, 0x00, 0xc9, 0x0f, 0xda, 0xa2, 0x21, 0x68, 0xc0, 0x00 }; ByteVector pi32le(reinterpret_cast(PI32LE), 5); CPPUNIT_ASSERT_EQUAL(31415, static_cast(pi32le.toFloat32LE(1) * 10000)); diff --git a/tests/test_id3v2.cpp b/tests/test_id3v2.cpp index c6592bbe..b6257e8c 100644 --- a/tests/test_id3v2.cpp +++ b/tests/test_id3v2.cpp @@ -338,7 +338,7 @@ public: CPPUNIT_ASSERT_EQUAL(String("ident"), f.identification()); CPPUNIT_ASSERT_EQUAL(15.0f / 512.0f, f.volumeAdjustment(ID3v2::RelativeVolumeFrame::FrontRight)); - CPPUNIT_ASSERT_EQUAL((uchar)8, + CPPUNIT_ASSERT_EQUAL((unsigned char)8, f.peakVolume(ID3v2::RelativeVolumeFrame::FrontRight).bitsRepresentingPeak); CPPUNIT_ASSERT_EQUAL(ByteVector("\x45"), f.peakVolume(ID3v2::RelativeVolumeFrame::FrontRight).peakVolume); diff --git a/tests/test_it.cpp b/tests/test_it.cpp index 3270eb25..7bb9084b 100644 --- a/tests/test_it.cpp +++ b/tests/test_it.cpp @@ -116,12 +116,12 @@ private: CPPUNIT_ASSERT_EQUAL((TagLib::ushort)535, p->version()); CPPUNIT_ASSERT_EQUAL((TagLib::ushort)532, p->compatibleVersion()); CPPUNIT_ASSERT_EQUAL((TagLib::ushort) 9, p->flags()); - CPPUNIT_ASSERT_EQUAL((TagLib::uchar)128, p->globalVolume()); - CPPUNIT_ASSERT_EQUAL((TagLib::uchar) 48, p->mixVolume()); - CPPUNIT_ASSERT_EQUAL((TagLib::uchar)125, p->tempo()); - CPPUNIT_ASSERT_EQUAL((TagLib::uchar) 6, p->bpmSpeed()); - CPPUNIT_ASSERT_EQUAL((TagLib::uchar)128, p->panningSeparation()); - CPPUNIT_ASSERT_EQUAL((TagLib::uchar) 0, p->pitchWheelDepth()); + CPPUNIT_ASSERT_EQUAL((unsigned char)128, p->globalVolume()); + CPPUNIT_ASSERT_EQUAL((unsigned char) 48, p->mixVolume()); + CPPUNIT_ASSERT_EQUAL((unsigned char)125, p->tempo()); + CPPUNIT_ASSERT_EQUAL((unsigned char) 6, p->bpmSpeed()); + CPPUNIT_ASSERT_EQUAL((unsigned char)128, p->panningSeparation()); + CPPUNIT_ASSERT_EQUAL((unsigned char) 0, p->pitchWheelDepth()); CPPUNIT_ASSERT_EQUAL(title, t->title()); CPPUNIT_ASSERT_EQUAL(String(), t->artist()); CPPUNIT_ASSERT_EQUAL(String(), t->album()); diff --git a/tests/test_mod.cpp b/tests/test_mod.cpp index c62a870b..b150c7fb 100644 --- a/tests/test_mod.cpp +++ b/tests/test_mod.cpp @@ -111,7 +111,7 @@ private: CPPUNIT_ASSERT_EQUAL(0, p->sampleRate()); CPPUNIT_ASSERT_EQUAL(8, p->channels()); CPPUNIT_ASSERT_EQUAL(31U, p->instrumentCount()); - CPPUNIT_ASSERT_EQUAL((uchar)1, p->lengthInPatterns()); + CPPUNIT_ASSERT_EQUAL((unsigned char)1, p->lengthInPatterns()); CPPUNIT_ASSERT_EQUAL(title, t->title()); CPPUNIT_ASSERT_EQUAL(String(), t->artist()); CPPUNIT_ASSERT_EQUAL(String(), t->album()); diff --git a/tests/test_s3m.cpp b/tests/test_s3m.cpp index 997c5653..41579d3c 100644 --- a/tests/test_s3m.cpp +++ b/tests/test_s3m.cpp @@ -105,10 +105,10 @@ private: CPPUNIT_ASSERT_EQUAL((TagLib::ushort) 0, p->flags()); CPPUNIT_ASSERT_EQUAL((TagLib::ushort)4896, p->trackerVersion()); CPPUNIT_ASSERT_EQUAL((TagLib::ushort) 2, p->fileFormatVersion()); - CPPUNIT_ASSERT_EQUAL((TagLib::uchar) 64, p->globalVolume()); - CPPUNIT_ASSERT_EQUAL((TagLib::uchar) 48, p->masterVolume()); - CPPUNIT_ASSERT_EQUAL((TagLib::uchar)125, p->tempo()); - CPPUNIT_ASSERT_EQUAL((TagLib::uchar) 6, p->bpmSpeed()); + CPPUNIT_ASSERT_EQUAL((unsigned char) 64, p->globalVolume()); + CPPUNIT_ASSERT_EQUAL((unsigned char) 48, p->masterVolume()); + CPPUNIT_ASSERT_EQUAL((unsigned char)125, p->tempo()); + CPPUNIT_ASSERT_EQUAL((unsigned char) 6, p->bpmSpeed()); CPPUNIT_ASSERT_EQUAL(title, t->title()); CPPUNIT_ASSERT_EQUAL(String(), t->artist()); CPPUNIT_ASSERT_EQUAL(String(), t->album()); From dcc0fe553c7b0922d35af3f7c6f6095a9540e989 Mon Sep 17 00:00:00 2001 From: Tsuda Kageyu Date: Wed, 2 Dec 2015 18:59:45 +0900 Subject: [PATCH 26/33] Use a standard type rather than TagLib::ushort. This won't break the ABI compatibility. --- taglib/asf/asfutils.h | 2 +- taglib/it/itfile.cpp | 22 ++++---- taglib/it/itproperties.cpp | 50 ++++++++--------- taglib/it/itproperties.h | 34 ++++++------ taglib/mod/modfilebase.cpp | 8 +-- taglib/mod/modfilebase.h | 8 +-- taglib/mod/modfileprivate.h | 8 +-- taglib/mpc/mpcproperties.cpp | 2 +- .../id3v2/frames/synchronizedlyricsframe.cpp | 4 +- taglib/ogg/opus/opusproperties.cpp | 2 +- taglib/s3m/s3mfile.cpp | 14 ++--- taglib/s3m/s3mproperties.cpp | 40 +++++++------- taglib/s3m/s3mproperties.h | 26 ++++----- taglib/toolkit/tbytevector.cpp | 2 +- taglib/toolkit/tstring.cpp | 6 +- taglib/toolkit/tutils.h | 2 +- taglib/xm/xmfile.cpp | 55 +++++++++---------- taglib/xm/xmproperties.cpp | 50 ++++++++--------- taglib/xm/xmproperties.h | 32 +++++------ tests/test_it.cpp | 14 ++--- tests/test_s3m.cpp | 12 ++-- tests/test_xm.cpp | 32 +++++------ 22 files changed, 212 insertions(+), 213 deletions(-) diff --git a/taglib/asf/asfutils.h b/taglib/asf/asfutils.h index 21dbd034..9a949413 100644 --- a/taglib/asf/asfutils.h +++ b/taglib/asf/asfutils.h @@ -35,7 +35,7 @@ namespace TagLib namespace ASF { - inline ushort readWORD(File *file, bool *ok = 0) + inline unsigned short readWORD(File *file, bool *ok = 0) { const ByteVector v = file->readBlock(2); if(v.size() != 2) { diff --git a/taglib/it/itfile.cpp b/taglib/it/itfile.cpp index 51ad8ac1..7508cfcb 100644 --- a/taglib/it/itfile.cpp +++ b/taglib/it/itfile.cpp @@ -96,9 +96,9 @@ bool IT::File::save() seek(2, Current); - ushort length = 0; - ushort instrumentCount = 0; - ushort sampleCount = 0; + unsigned short length = 0; + unsigned short instrumentCount = 0; + unsigned short sampleCount = 0; if(!readU16L(length) || !readU16L(instrumentCount) || !readU16L(sampleCount)) return false; @@ -107,7 +107,7 @@ bool IT::File::save() // write comment as instrument and sample names: StringList lines = d->tag.comment().split("\n"); - for(ushort i = 0; i < instrumentCount; ++ i) { + for(unsigned short i = 0; i < instrumentCount; ++ i) { seek(192L + length + ((long)i << 2)); ulong instrumentOffset = 0; if(!readU32L(instrumentOffset)) @@ -122,7 +122,7 @@ bool IT::File::save() writeByte(0); } - for(ushort i = 0; i < sampleCount; ++ i) { + for(unsigned short i = 0; i < sampleCount; ++ i) { seek(192L + length + ((long)instrumentCount << 2) + ((long)i << 2)); ulong sampleOffset = 0; if(!readU32L(sampleOffset)) @@ -149,8 +149,8 @@ bool IT::File::save() message.resize(7999); message.append((char)0); - ushort special = 0; - ushort messageLength = 0; + unsigned short special = 0; + unsigned short messageLength = 0; ulong messageOffset = 0; seek(46); @@ -259,8 +259,8 @@ void IT::File::read(bool) d->properties.setChannels(channels); // real length might be shorter because of skips and terminator - ushort realLength = 0; - for(ushort i = 0; i < length; ++ i) { + unsigned short realLength = 0; + for(unsigned short i = 0; i < length; ++ i) { READ_BYTE_AS(order); if(order == 255) break; if(order != 254) ++ realLength; @@ -274,7 +274,7 @@ void IT::File::read(bool) // Currently I just discard anything after a nil, but // e.g. VLC seems to interprete a nil as a space. I // don't know what is the proper behaviour. - for(ushort i = 0; i < instrumentCount; ++ i) { + for(unsigned short i = 0; i < instrumentCount; ++ i) { seek(192L + length + ((long)i << 2)); READ_U32L_AS(instrumentOffset); seek(instrumentOffset); @@ -290,7 +290,7 @@ void IT::File::read(bool) comment.append(instrumentName); } - for(ushort i = 0; i < sampleCount; ++ i) { + for(unsigned short i = 0; i < sampleCount; ++ i) { seek(192L + length + ((long)instrumentCount << 2) + ((long)i << 2)); READ_U32L_AS(sampleOffset); diff --git a/taglib/it/itproperties.cpp b/taglib/it/itproperties.cpp index 8b1fc43c..426a6f2d 100644 --- a/taglib/it/itproperties.cpp +++ b/taglib/it/itproperties.cpp @@ -46,15 +46,15 @@ public: { } - int channels; - ushort lengthInPatterns; - ushort instrumentCount; - ushort sampleCount; - ushort patternCount; - ushort version; - ushort compatibleVersion; - ushort flags; - ushort special; + int channels; + unsigned short lengthInPatterns; + unsigned short instrumentCount; + unsigned short sampleCount; + unsigned short patternCount; + unsigned short version; + unsigned short compatibleVersion; + unsigned short flags; + unsigned short special; unsigned char globalVolume; unsigned char mixVolume; unsigned char tempo; @@ -104,7 +104,7 @@ int IT::Properties::channels() const return d->channels; } -TagLib::ushort IT::Properties::lengthInPatterns() const +unsigned short IT::Properties::lengthInPatterns() const { return d->lengthInPatterns; } @@ -114,37 +114,37 @@ bool IT::Properties::stereo() const return d->flags & Stereo; } -TagLib::ushort IT::Properties::instrumentCount() const +unsigned short IT::Properties::instrumentCount() const { return d->instrumentCount; } -TagLib::ushort IT::Properties::sampleCount() const +unsigned short IT::Properties::sampleCount() const { return d->sampleCount; } -TagLib::ushort IT::Properties::patternCount() const +unsigned short IT::Properties::patternCount() const { return d->patternCount; } -TagLib::ushort IT::Properties::version() const +unsigned short IT::Properties::version() const { return d->version; } -TagLib::ushort IT::Properties::compatibleVersion() const +unsigned short IT::Properties::compatibleVersion() const { return d->compatibleVersion; } -TagLib::ushort IT::Properties::flags() const +unsigned short IT::Properties::flags() const { return d->flags; } -TagLib::ushort IT::Properties::special() const +unsigned short IT::Properties::special() const { return d->special; } @@ -184,42 +184,42 @@ void IT::Properties::setChannels(int channels) d->channels = channels; } -void IT::Properties::setLengthInPatterns(ushort lengthInPatterns) +void IT::Properties::setLengthInPatterns(unsigned short lengthInPatterns) { d->lengthInPatterns = lengthInPatterns; } -void IT::Properties::setInstrumentCount(ushort instrumentCount) +void IT::Properties::setInstrumentCount(unsigned short instrumentCount) { d->instrumentCount = instrumentCount; } -void IT::Properties::setSampleCount(ushort sampleCount) +void IT::Properties::setSampleCount(unsigned short sampleCount) { d->sampleCount = sampleCount; } -void IT::Properties::setPatternCount(ushort patternCount) +void IT::Properties::setPatternCount(unsigned short patternCount) { d->patternCount = patternCount; } -void IT::Properties::setFlags(ushort flags) +void IT::Properties::setFlags(unsigned short flags) { d->flags = flags; } -void IT::Properties::setSpecial(ushort special) +void IT::Properties::setSpecial(unsigned short special) { d->special = special; } -void IT::Properties::setCompatibleVersion(ushort compatibleVersion) +void IT::Properties::setCompatibleVersion(unsigned short compatibleVersion) { d->compatibleVersion = compatibleVersion; } -void IT::Properties::setVersion(ushort version) +void IT::Properties::setVersion(unsigned short version) { d->version = version; } diff --git a/taglib/it/itproperties.h b/taglib/it/itproperties.h index e2da6e66..d65a8c28 100644 --- a/taglib/it/itproperties.h +++ b/taglib/it/itproperties.h @@ -58,15 +58,15 @@ namespace TagLib { int sampleRate() const; int channels() const; - ushort lengthInPatterns() const; - bool stereo() const; - ushort instrumentCount() const; - ushort sampleCount() const; - ushort patternCount() const; - ushort version() const; - ushort compatibleVersion() const; - ushort flags() const; - ushort special() const; + unsigned short lengthInPatterns() const; + bool stereo() const; + unsigned short instrumentCount() const; + unsigned short sampleCount() const; + unsigned short patternCount() const; + unsigned short version() const; + unsigned short compatibleVersion() const; + unsigned short flags() const; + unsigned short special() const; unsigned char globalVolume() const; unsigned char mixVolume() const; unsigned char tempo() const; @@ -75,14 +75,14 @@ namespace TagLib { unsigned char pitchWheelDepth() const; void setChannels(int channels); - void setLengthInPatterns(ushort lengthInPatterns); - void setInstrumentCount(ushort instrumentCount); - void setSampleCount (ushort sampleCount); - void setPatternCount(ushort patternCount); - void setVersion (ushort version); - void setCompatibleVersion(ushort compatibleVersion); - void setFlags (ushort flags); - void setSpecial (ushort special); + void setLengthInPatterns(unsigned short lengthInPatterns); + void setInstrumentCount(unsigned short instrumentCount); + void setSampleCount (unsigned short sampleCount); + void setPatternCount(unsigned short patternCount); + void setVersion (unsigned short version); + void setCompatibleVersion(unsigned short compatibleVersion); + void setFlags (unsigned short flags); + void setSpecial (unsigned short special); void setGlobalVolume(unsigned char globalVolume); void setMixVolume (unsigned char mixVolume); void setTempo (unsigned char tempo); diff --git a/taglib/mod/modfilebase.cpp b/taglib/mod/modfilebase.cpp index a73e9367..2ed16ae7 100644 --- a/taglib/mod/modfilebase.cpp +++ b/taglib/mod/modfilebase.cpp @@ -61,7 +61,7 @@ void Mod::FileBase::writeByte(unsigned char byte) writeBlock(data); } -void Mod::FileBase::writeU16L(ushort number) +void Mod::FileBase::writeU16L(unsigned short number) { writeBlock(ByteVector::fromShort(number, false)); } @@ -71,7 +71,7 @@ void Mod::FileBase::writeU32L(ulong number) writeBlock(ByteVector::fromUInt(number, false)); } -void Mod::FileBase::writeU16B(ushort number) +void Mod::FileBase::writeU16B(unsigned short number) { writeBlock(ByteVector::fromShort(number, true)); } @@ -89,7 +89,7 @@ bool Mod::FileBase::readByte(unsigned char &byte) return true; } -bool Mod::FileBase::readU16L(ushort &number) +bool Mod::FileBase::readU16L(unsigned short &number) { ByteVector data(readBlock(2)); if(data.size() < 2) return false; @@ -104,7 +104,7 @@ bool Mod::FileBase::readU32L(ulong &number) { return true; } -bool Mod::FileBase::readU16B(ushort &number) +bool Mod::FileBase::readU16B(unsigned short &number) { ByteVector data(readBlock(2)); if(data.size() < 2) return false; diff --git a/taglib/mod/modfilebase.h b/taglib/mod/modfilebase.h index 8b483d38..82f3122b 100644 --- a/taglib/mod/modfilebase.h +++ b/taglib/mod/modfilebase.h @@ -42,16 +42,16 @@ namespace TagLib { void writeString(const String &s, ulong size, char padding = 0); void writeByte(unsigned char byte); - void writeU16L(ushort number); + void writeU16L(unsigned short number); void writeU32L(ulong number); - void writeU16B(ushort number); + void writeU16B(unsigned short number); void writeU32B(ulong number); bool readString(String &s, ulong size); bool readByte(unsigned char &byte); - bool readU16L(ushort &number); + bool readU16L(unsigned short &number); bool readU32L(ulong &number); - bool readU16B(ushort &number); + bool readU16B(unsigned short &number); bool readU32B(ulong &number); }; diff --git a/taglib/mod/modfileprivate.h b/taglib/mod/modfileprivate.h index 7aa52db1..a4fc8d33 100644 --- a/taglib/mod/modfileprivate.h +++ b/taglib/mod/modfileprivate.h @@ -38,9 +38,9 @@ } #define READ_BYTE(setter) READ(setter,unsigned char,readByte) -#define READ_U16L(setter) READ(setter,ushort,readU16L) +#define READ_U16L(setter) READ(setter,unsigned short,readU16L) #define READ_U32L(setter) READ(setter,ulong,readU32L) -#define READ_U16B(setter) READ(setter,ushort,readU16B) +#define READ_U16B(setter) READ(setter,unsigned short,readU16B) #define READ_U32B(setter) READ(setter,ulong,readU32B) #define READ_STRING(setter,size) \ @@ -55,9 +55,9 @@ READ_ASSERT(read(name)); #define READ_BYTE_AS(name) READ_AS(unsigned char,name,readByte) -#define READ_U16L_AS(name) READ_AS(ushort,name,readU16L) +#define READ_U16L_AS(name) READ_AS(unsigned short,name,readU16L) #define READ_U32L_AS(name) READ_AS(ulong,name,readU32L) -#define READ_U16B_AS(name) READ_AS(ushort,name,readU16B) +#define READ_U16B_AS(name) READ_AS(unsigned short,name,readU16B) #define READ_U32B_AS(name) READ_AS(ulong,name,readU32B) #define READ_STRING_AS(name,size) \ diff --git a/taglib/mpc/mpcproperties.cpp b/taglib/mpc/mpcproperties.cpp index 9437f22e..9c1274eb 100644 --- a/taglib/mpc/mpcproperties.cpp +++ b/taglib/mpc/mpcproperties.cpp @@ -253,7 +253,7 @@ void MPC::Properties::readSV8(File *file, long streamLength) break; } - const ushort flags = data.toUShort(pos, true); + const unsigned short flags = data.toUShort(pos, true); pos += 2; d->sampleRate = sftable[(flags >> 13) & 0x07]; diff --git a/taglib/mpeg/id3v2/frames/synchronizedlyricsframe.cpp b/taglib/mpeg/id3v2/frames/synchronizedlyricsframe.cpp index 2ab46481..1d42e1c8 100644 --- a/taglib/mpeg/id3v2/frames/synchronizedlyricsframe.cpp +++ b/taglib/mpeg/id3v2/frames/synchronizedlyricsframe.cpp @@ -171,7 +171,7 @@ void SynchronizedLyricsFrame::parseFields(const ByteVector &data) */ String::Type encWithEndianness = d->textEncoding; if(d->textEncoding == String::UTF16) { - ushort bom = data.toUShort(6, true); + unsigned short bom = data.toUShort(6, true); if(bom == 0xfffe) { encWithEndianness = String::UTF16LE; } else if(bom == 0xfeff) { @@ -184,7 +184,7 @@ void SynchronizedLyricsFrame::parseFields(const ByteVector &data) String::Type enc = d->textEncoding; // If a UTF16 string has no BOM, use the encoding found above. if(enc == String::UTF16 && pos + 1 < end) { - ushort bom = data.toUShort(pos, true); + unsigned short bom = data.toUShort(pos, true); if(bom != 0xfffe && bom != 0xfeff) { enc = encWithEndianness; } diff --git a/taglib/ogg/opus/opusproperties.cpp b/taglib/ogg/opus/opusproperties.cpp index 365658f8..43858da6 100644 --- a/taglib/ogg/opus/opusproperties.cpp +++ b/taglib/ogg/opus/opusproperties.cpp @@ -138,7 +138,7 @@ void Opus::Properties::read(File *file) pos += 1; // *Pre-skip* (16 bits, unsigned, little endian) - const ushort preSkip = data.toUShort(pos, false); + const unsigned short preSkip = data.toUShort(pos, false); pos += 2; // *Input Sample Rate* (32 bits, unsigned, little endian) diff --git a/taglib/s3m/s3mfile.cpp b/taglib/s3m/s3mfile.cpp index c83e09d7..923a80ad 100644 --- a/taglib/s3m/s3mfile.cpp +++ b/taglib/s3m/s3mfile.cpp @@ -100,8 +100,8 @@ bool S3M::File::save() seek(32); - ushort length = 0; - ushort sampleCount = 0; + unsigned short length = 0; + unsigned short sampleCount = 0; if(!readU16L(length) || !readU16L(sampleCount)) return false; @@ -123,10 +123,10 @@ bool S3M::File::save() StringList lines = d->tag.comment().split("\n"); // write comment as sample names: - for(ushort i = 0; i < sampleCount; ++ i) { + for(unsigned short i = 0; i < sampleCount; ++ i) { seek(96L + length + ((long)i << 1)); - ushort instrumentOffset = 0; + unsigned short instrumentOffset = 0; if(!readU16L(instrumentOffset)) return false; seek(((long)instrumentOffset << 4) + 48); @@ -193,8 +193,8 @@ void S3M::File::read(bool) d->properties.setChannels(channels); seek(96); - ushort realLength = 0; - for(ushort i = 0; i < length; ++ i) { + unsigned short realLength = 0; + for(unsigned short i = 0; i < length; ++ i) { READ_BYTE_AS(order); if(order == 255) break; if(order != 254) ++ realLength; @@ -208,7 +208,7 @@ void S3M::File::read(bool) // However, there I never found instruments (SCRI) but // instead samples (SCRS). StringList comment; - for(ushort i = 0; i < sampleCount; ++ i) { + for(unsigned short i = 0; i < sampleCount; ++ i) { seek(96L + length + ((long)i << 1)); READ_U16L_AS(sampleHeaderOffset); diff --git a/taglib/s3m/s3mproperties.cpp b/taglib/s3m/s3mproperties.cpp index de2d1ebe..9633a0fe 100644 --- a/taglib/s3m/s3mproperties.cpp +++ b/taglib/s3m/s3mproperties.cpp @@ -43,14 +43,14 @@ public: { } - ushort lengthInPatterns; - int channels; - bool stereo; - ushort sampleCount; - ushort patternCount; - ushort flags; - ushort trackerVersion; - ushort fileFormatVersion; + unsigned short lengthInPatterns; + int channels; + bool stereo; + unsigned short sampleCount; + unsigned short patternCount; + unsigned short flags; + unsigned short trackerVersion; + unsigned short fileFormatVersion; unsigned char globalVolume; unsigned char masterVolume; unsigned char tempo; @@ -98,7 +98,7 @@ int S3M::Properties::channels() const return d->channels; } -TagLib::ushort S3M::Properties::lengthInPatterns() const +unsigned short S3M::Properties::lengthInPatterns() const { return d->lengthInPatterns; } @@ -108,27 +108,27 @@ bool S3M::Properties::stereo() const return d->stereo; } -TagLib::ushort S3M::Properties::sampleCount() const +unsigned short S3M::Properties::sampleCount() const { return d->sampleCount; } -TagLib::ushort S3M::Properties::patternCount() const +unsigned short S3M::Properties::patternCount() const { return d->patternCount; } -TagLib::ushort S3M::Properties::flags() const +unsigned short S3M::Properties::flags() const { return d->flags; } -TagLib::ushort S3M::Properties::trackerVersion() const +unsigned short S3M::Properties::trackerVersion() const { return d->trackerVersion; } -TagLib::ushort S3M::Properties::fileFormatVersion() const +unsigned short S3M::Properties::fileFormatVersion() const { return d->fileFormatVersion; } @@ -153,7 +153,7 @@ unsigned char S3M::Properties::bpmSpeed() const return d->bpmSpeed; } -void S3M::Properties::setLengthInPatterns(ushort lengthInPatterns) +void S3M::Properties::setLengthInPatterns(unsigned short lengthInPatterns) { d->lengthInPatterns = lengthInPatterns; } @@ -168,27 +168,27 @@ void S3M::Properties::setStereo(bool stereo) d->stereo = stereo; } -void S3M::Properties::setSampleCount(ushort sampleCount) +void S3M::Properties::setSampleCount(unsigned short sampleCount) { d->sampleCount = sampleCount; } -void S3M::Properties::setPatternCount(ushort patternCount) +void S3M::Properties::setPatternCount(unsigned short patternCount) { d->patternCount = patternCount; } -void S3M::Properties::setFlags(ushort flags) +void S3M::Properties::setFlags(unsigned short flags) { d->flags = flags; } -void S3M::Properties::setTrackerVersion(ushort trackerVersion) +void S3M::Properties::setTrackerVersion(unsigned short trackerVersion) { d->trackerVersion = trackerVersion; } -void S3M::Properties::setFileFormatVersion(ushort fileFormatVersion) +void S3M::Properties::setFileFormatVersion(unsigned short fileFormatVersion) { d->fileFormatVersion = fileFormatVersion; } diff --git a/taglib/s3m/s3mproperties.h b/taglib/s3m/s3mproperties.h index f77d2204..4b14e97f 100644 --- a/taglib/s3m/s3mproperties.h +++ b/taglib/s3m/s3mproperties.h @@ -51,13 +51,13 @@ namespace TagLib { int sampleRate() const; int channels() const; - ushort lengthInPatterns() const; - bool stereo() const; - ushort sampleCount() const; - ushort patternCount() const; - ushort flags() const; - ushort trackerVersion() const; - ushort fileFormatVersion() const; + unsigned short lengthInPatterns() const; + bool stereo() const; + unsigned short sampleCount() const; + unsigned short patternCount() const; + unsigned short flags() const; + unsigned short trackerVersion() const; + unsigned short fileFormatVersion() const; unsigned char globalVolume() const; unsigned char masterVolume() const; unsigned char tempo() const; @@ -65,13 +65,13 @@ namespace TagLib { void setChannels(int channels); - void setLengthInPatterns (ushort lengthInPatterns); + void setLengthInPatterns (unsigned short lengthInPatterns); void setStereo (bool stereo); - void setSampleCount (ushort sampleCount); - void setPatternCount (ushort patternCount); - void setFlags (ushort flags); - void setTrackerVersion (ushort trackerVersion); - void setFileFormatVersion(ushort fileFormatVersion); + void setSampleCount (unsigned short sampleCount); + void setPatternCount (unsigned short patternCount); + void setFlags (unsigned short flags); + void setTrackerVersion (unsigned short trackerVersion); + void setFileFormatVersion(unsigned short fileFormatVersion); void setGlobalVolume (unsigned char globalVolume); void setMasterVolume (unsigned char masterVolume); void setTempo (unsigned char tempo); diff --git a/taglib/toolkit/tbytevector.cpp b/taglib/toolkit/tbytevector.cpp index 71bcb43a..6aff6423 100644 --- a/taglib/toolkit/tbytevector.cpp +++ b/taglib/toolkit/tbytevector.cpp @@ -364,7 +364,7 @@ ByteVector ByteVector::fromUInt(uint value, bool mostSignificantByteFirst) ByteVector ByteVector::fromShort(short value, bool mostSignificantByteFirst) { - return fromNumber(value, mostSignificantByteFirst); + return fromNumber(value, mostSignificantByteFirst); } ByteVector ByteVector::fromLongLong(long long value, bool mostSignificantByteFirst) diff --git a/taglib/toolkit/tstring.cpp b/taglib/toolkit/tstring.cpp index f9884da7..6ad80528 100644 --- a/taglib/toolkit/tstring.cpp +++ b/taglib/toolkit/tstring.cpp @@ -174,7 +174,7 @@ namespace if(length > 0) { if(swap) { for(size_t i = 0; i < length; ++i) - data[i] = Utils::byteSwap(static_cast(s[i])); + data[i] = Utils::byteSwap(static_cast(s[i])); } else { ::wmemcpy(&data[0], s, length); @@ -194,7 +194,7 @@ namespace } // Uses memcpy instead of reinterpret_cast to avoid an alignment exception. - TagLib::ushort bom; + unsigned short bom; ::memcpy(&bom, s, 2); if(bom == 0xfeff) @@ -215,7 +215,7 @@ namespace data.resize(length / 2); for(size_t i = 0; i < length / 2; ++i) { - TagLib::ushort c; + unsigned short c; ::memcpy(&c, s, 2); if(swap) c = Utils::byteSwap(c); diff --git a/taglib/toolkit/tutils.h b/taglib/toolkit/tutils.h index 9855ed91..4e2c13ce 100644 --- a/taglib/toolkit/tutils.h +++ b/taglib/toolkit/tutils.h @@ -59,7 +59,7 @@ namespace TagLib /*! * Reverses the order of bytes in an 16-bit integer. */ - inline ushort byteSwap(ushort x) + inline unsigned short byteSwap(unsigned short x) { #if defined(HAVE_BOOST_BYTESWAP) diff --git a/taglib/xm/xmfile.cpp b/taglib/xm/xmfile.cpp index fc337ba4..7fa032c7 100644 --- a/taglib/xm/xmfile.cpp +++ b/taglib/xm/xmfile.cpp @@ -31,7 +31,6 @@ using namespace TagLib; using namespace XM; using TagLib::uint; -using TagLib::ushort; using TagLib::ulong; /*! @@ -180,11 +179,11 @@ protected: bool bigEndian; }; -class U16Reader : public NumberReader +class U16Reader : public NumberReader { public: - U16Reader(ushort &value, bool bigEndian) - : NumberReader(value, bigEndian) {} + U16Reader(unsigned short &value, bool bigEndian) + : NumberReader(value, bigEndian) {} uint read(TagLib::File &file, uint limit) { @@ -268,7 +267,7 @@ public: * Read a unsigned 16 Bit integer into \a number. The byte order * is controlled by \a bigEndian. */ - StructReader &u16(ushort &number, bool bigEndian) + StructReader &u16(unsigned short &number, bool bigEndian) { m_readers.append(new U16Reader(number, bigEndian)); return *this; @@ -277,7 +276,7 @@ public: /*! * Read a unsigned 16 Bit little endian integer into \a number. */ - StructReader &u16L(ushort &number) + StructReader &u16L(unsigned short &number) { return u16(number, false); } @@ -285,7 +284,7 @@ public: /*! * Read a unsigned 16 Bit big endian integer into \a number. */ - StructReader &u16B(ushort &number) + StructReader &u16B(unsigned short &number) { return u16(number, true); } @@ -416,22 +415,22 @@ bool XM::File::save() return false; seek(70); - ushort patternCount = 0; - ushort instrumentCount = 0; + unsigned short patternCount = 0; + unsigned short instrumentCount = 0; if(!readU16L(patternCount) || !readU16L(instrumentCount)) return false; long pos = 60 + headerSize; // should be long long in taglib2. // need to read patterns again in order to seek to the instruments: - for(ushort i = 0; i < patternCount; ++ i) { + for(unsigned short i = 0; i < patternCount; ++ i) { seek(pos); ulong patternHeaderLength = 0; if(!readU32L(patternHeaderLength) || patternHeaderLength < 4) return false; seek(pos + 7); - ushort dataSize = 0; + unsigned short dataSize = 0; if (!readU16L(dataSize)) return false; @@ -440,7 +439,7 @@ bool XM::File::save() const StringList lines = d->tag.comment().split("\n"); uint sampleNameIndex = instrumentCount; - for(ushort i = 0; i < instrumentCount; ++ i) { + for(unsigned short i = 0; i < instrumentCount; ++ i) { seek(pos); ulong instrumentHeaderSize = 0; if(!readU32L(instrumentHeaderSize) || instrumentHeaderSize < 4) @@ -453,7 +452,7 @@ bool XM::File::save() else writeString(lines[i], len); - ushort sampleCount = 0; + unsigned short sampleCount = 0; if(instrumentHeaderSize >= 29U) { seek(pos + 27); if(!readU16L(sampleCount)) @@ -469,7 +468,7 @@ bool XM::File::save() pos += instrumentHeaderSize; - for(ushort j = 0; j < sampleCount; ++ j) { + for(unsigned short j = 0; j < sampleCount; ++ j) { if(sampleHeaderSize > 4U) { seek(pos); ulong sampleLength = 0; @@ -513,14 +512,14 @@ void XM::File::read(bool) READ_U32L_AS(headerSize); READ_ASSERT(headerSize >= 4); - ushort length = 0; - ushort restartPosition = 0; - ushort channels = 0; - ushort patternCount = 0; - ushort instrumentCount = 0; - ushort flags = 0; - ushort tempo = 0; - ushort bpmSpeed = 0; + unsigned short length = 0; + unsigned short restartPosition = 0; + unsigned short channels = 0; + unsigned short patternCount = 0; + unsigned short instrumentCount = 0; + unsigned short flags = 0; + unsigned short tempo = 0; + unsigned short bpmSpeed = 0; StructReader header; header.u16L(length) @@ -549,13 +548,13 @@ void XM::File::read(bool) seek(60 + headerSize); // read patterns: - for(ushort i = 0; i < patternCount; ++ i) { + for(unsigned short i = 0; i < patternCount; ++ i) { READ_U32L_AS(patternHeaderLength); READ_ASSERT(patternHeaderLength >= 4); unsigned char packingType = 0; - ushort rowCount = 0; - ushort dataSize = 0; + unsigned short rowCount = 0; + unsigned short dataSize = 0; StructReader pattern; pattern.byte(packingType).u16L(rowCount).u16L(dataSize); @@ -570,13 +569,13 @@ void XM::File::read(bool) uint sumSampleCount = 0; // read instruments: - for(ushort i = 0; i < instrumentCount; ++ i) { + for(unsigned short i = 0; i < instrumentCount; ++ i) { READ_U32L_AS(instrumentHeaderSize); READ_ASSERT(instrumentHeaderSize >= 4); String instrumentName; unsigned char instrumentType = 0; - ushort sampleCount = 0; + unsigned short sampleCount = 0; StructReader instrument; instrument.string(instrumentName, 22).byte(instrumentType).u16L(sampleCount); @@ -594,7 +593,7 @@ void XM::File::read(bool) // skip unhandeled header proportion: seek(instrumentHeaderSize - count - 4, Current); - for(ushort j = 0; j < sampleCount; ++ j) { + for(unsigned short j = 0; j < sampleCount; ++ j) { ulong sampleLength = 0; ulong loopStart = 0; ulong loopLength = 0; diff --git a/taglib/xm/xmproperties.cpp b/taglib/xm/xmproperties.cpp index 3d4a3c38..9a7fa6b2 100644 --- a/taglib/xm/xmproperties.cpp +++ b/taglib/xm/xmproperties.cpp @@ -41,16 +41,16 @@ public: { } - ushort lengthInPatterns; - int channels; - ushort version; - ushort restartPosition; - ushort patternCount; - ushort instrumentCount; + unsigned short lengthInPatterns; + int channels; + unsigned short version; + unsigned short restartPosition; + unsigned short patternCount; + unsigned short instrumentCount; uint sampleCount; - ushort flags; - ushort tempo; - ushort bpmSpeed; + unsigned short flags; + unsigned short tempo; + unsigned short bpmSpeed; }; XM::Properties::Properties(AudioProperties::ReadStyle propertiesStyle) : @@ -94,27 +94,27 @@ int XM::Properties::channels() const return d->channels; } -TagLib::ushort XM::Properties::lengthInPatterns() const +unsigned short XM::Properties::lengthInPatterns() const { return d->lengthInPatterns; } -TagLib::ushort XM::Properties::version() const +unsigned short XM::Properties::version() const { return d->version; } -TagLib::ushort XM::Properties::restartPosition() const +unsigned short XM::Properties::restartPosition() const { return d->restartPosition; } -TagLib::ushort XM::Properties::patternCount() const +unsigned short XM::Properties::patternCount() const { return d->patternCount; } -TagLib::ushort XM::Properties::instrumentCount() const +unsigned short XM::Properties::instrumentCount() const { return d->instrumentCount; } @@ -124,22 +124,22 @@ TagLib::uint XM::Properties::sampleCount() const return d->sampleCount; } -TagLib::ushort XM::Properties::flags() const +unsigned short XM::Properties::flags() const { return d->flags; } -TagLib::ushort XM::Properties::tempo() const +unsigned short XM::Properties::tempo() const { return d->tempo; } -TagLib::ushort XM::Properties::bpmSpeed() const +unsigned short XM::Properties::bpmSpeed() const { return d->bpmSpeed; } -void XM::Properties::setLengthInPatterns(ushort lengthInPatterns) +void XM::Properties::setLengthInPatterns(unsigned short lengthInPatterns) { d->lengthInPatterns = lengthInPatterns; } @@ -149,22 +149,22 @@ void XM::Properties::setChannels(int channels) d->channels = channels; } -void XM::Properties::setVersion(ushort version) +void XM::Properties::setVersion(unsigned short version) { d->version = version; } -void XM::Properties::setRestartPosition(ushort restartPosition) +void XM::Properties::setRestartPosition(unsigned short restartPosition) { d->restartPosition = restartPosition; } -void XM::Properties::setPatternCount(ushort patternCount) +void XM::Properties::setPatternCount(unsigned short patternCount) { d->patternCount = patternCount; } -void XM::Properties::setInstrumentCount(ushort instrumentCount) +void XM::Properties::setInstrumentCount(unsigned short instrumentCount) { d->instrumentCount = instrumentCount; } @@ -174,17 +174,17 @@ void XM::Properties::setSampleCount(uint sampleCount) d->sampleCount = sampleCount; } -void XM::Properties::setFlags(ushort flags) +void XM::Properties::setFlags(unsigned short flags) { d->flags = flags; } -void XM::Properties::setTempo(ushort tempo) +void XM::Properties::setTempo(unsigned short tempo) { d->tempo = tempo; } -void XM::Properties::setBpmSpeed(ushort bpmSpeed) +void XM::Properties::setBpmSpeed(unsigned short bpmSpeed) { d->bpmSpeed = bpmSpeed; } diff --git a/taglib/xm/xmproperties.h b/taglib/xm/xmproperties.h index f929982b..4fdf8b4b 100644 --- a/taglib/xm/xmproperties.h +++ b/taglib/xm/xmproperties.h @@ -46,27 +46,27 @@ namespace TagLib { int sampleRate() const; int channels() const; - ushort lengthInPatterns() const; - ushort version() const; - ushort restartPosition() const; - ushort patternCount() const; - ushort instrumentCount() const; + unsigned short lengthInPatterns() const; + unsigned short version() const; + unsigned short restartPosition() const; + unsigned short patternCount() const; + unsigned short instrumentCount() const; uint sampleCount() const; - ushort flags() const; - ushort tempo() const; - ushort bpmSpeed() const; + unsigned short flags() const; + unsigned short tempo() const; + unsigned short bpmSpeed() const; void setChannels(int channels); - void setLengthInPatterns(ushort lengthInPatterns); - void setVersion(ushort version); - void setRestartPosition(ushort restartPosition); - void setPatternCount(ushort patternCount); - void setInstrumentCount(ushort instrumentCount); + void setLengthInPatterns(unsigned short lengthInPatterns); + void setVersion(unsigned short version); + void setRestartPosition(unsigned short restartPosition); + void setPatternCount(unsigned short patternCount); + void setInstrumentCount(unsigned short instrumentCount); void setSampleCount(uint sampleCount); - void setFlags(ushort flags); - void setTempo(ushort tempo); - void setBpmSpeed(ushort bpmSpeed); + void setFlags(unsigned short flags); + void setTempo(unsigned short tempo); + void setBpmSpeed(unsigned short bpmSpeed); private: Properties(const Properties&); diff --git a/tests/test_it.cpp b/tests/test_it.cpp index 7bb9084b..24cfb1a6 100644 --- a/tests/test_it.cpp +++ b/tests/test_it.cpp @@ -108,14 +108,14 @@ private: CPPUNIT_ASSERT_EQUAL( 0, p->bitrate()); CPPUNIT_ASSERT_EQUAL( 0, p->sampleRate()); CPPUNIT_ASSERT_EQUAL(64, p->channels()); - CPPUNIT_ASSERT_EQUAL((TagLib::ushort) 0, p->lengthInPatterns()); + CPPUNIT_ASSERT_EQUAL((unsigned short) 0, p->lengthInPatterns()); CPPUNIT_ASSERT_EQUAL(true, p->stereo()); - CPPUNIT_ASSERT_EQUAL((TagLib::ushort) 0, p->instrumentCount()); - CPPUNIT_ASSERT_EQUAL((TagLib::ushort) 5, p->sampleCount()); - CPPUNIT_ASSERT_EQUAL((TagLib::ushort) 1, p->patternCount()); - CPPUNIT_ASSERT_EQUAL((TagLib::ushort)535, p->version()); - CPPUNIT_ASSERT_EQUAL((TagLib::ushort)532, p->compatibleVersion()); - CPPUNIT_ASSERT_EQUAL((TagLib::ushort) 9, p->flags()); + CPPUNIT_ASSERT_EQUAL((unsigned short) 0, p->instrumentCount()); + CPPUNIT_ASSERT_EQUAL((unsigned short) 5, p->sampleCount()); + CPPUNIT_ASSERT_EQUAL((unsigned short) 1, p->patternCount()); + CPPUNIT_ASSERT_EQUAL((unsigned short)535, p->version()); + CPPUNIT_ASSERT_EQUAL((unsigned short)532, p->compatibleVersion()); + CPPUNIT_ASSERT_EQUAL((unsigned short) 9, p->flags()); CPPUNIT_ASSERT_EQUAL((unsigned char)128, p->globalVolume()); CPPUNIT_ASSERT_EQUAL((unsigned char) 48, p->mixVolume()); CPPUNIT_ASSERT_EQUAL((unsigned char)125, p->tempo()); diff --git a/tests/test_s3m.cpp b/tests/test_s3m.cpp index 41579d3c..8133e215 100644 --- a/tests/test_s3m.cpp +++ b/tests/test_s3m.cpp @@ -98,13 +98,13 @@ private: CPPUNIT_ASSERT_EQUAL( 0, p->bitrate()); CPPUNIT_ASSERT_EQUAL( 0, p->sampleRate()); CPPUNIT_ASSERT_EQUAL(16, p->channels()); - CPPUNIT_ASSERT_EQUAL((TagLib::ushort) 0, p->lengthInPatterns()); + CPPUNIT_ASSERT_EQUAL((unsigned short) 0, p->lengthInPatterns()); CPPUNIT_ASSERT_EQUAL(false, p->stereo()); - CPPUNIT_ASSERT_EQUAL((TagLib::ushort) 5, p->sampleCount()); - CPPUNIT_ASSERT_EQUAL((TagLib::ushort) 1, p->patternCount()); - CPPUNIT_ASSERT_EQUAL((TagLib::ushort) 0, p->flags()); - CPPUNIT_ASSERT_EQUAL((TagLib::ushort)4896, p->trackerVersion()); - CPPUNIT_ASSERT_EQUAL((TagLib::ushort) 2, p->fileFormatVersion()); + CPPUNIT_ASSERT_EQUAL((unsigned short) 5, p->sampleCount()); + CPPUNIT_ASSERT_EQUAL((unsigned short) 1, p->patternCount()); + CPPUNIT_ASSERT_EQUAL((unsigned short) 0, p->flags()); + CPPUNIT_ASSERT_EQUAL((unsigned short)4896, p->trackerVersion()); + CPPUNIT_ASSERT_EQUAL((unsigned short) 2, p->fileFormatVersion()); CPPUNIT_ASSERT_EQUAL((unsigned char) 64, p->globalVolume()); CPPUNIT_ASSERT_EQUAL((unsigned char) 48, p->masterVolume()); CPPUNIT_ASSERT_EQUAL((unsigned char)125, p->tempo()); diff --git a/tests/test_xm.cpp b/tests/test_xm.cpp index 48e6ec2c..e4527c74 100644 --- a/tests/test_xm.cpp +++ b/tests/test_xm.cpp @@ -130,14 +130,14 @@ public: CPPUNIT_ASSERT_EQUAL(0, p->bitrate()); CPPUNIT_ASSERT_EQUAL(0, p->sampleRate()); CPPUNIT_ASSERT_EQUAL(8, p->channels()); - CPPUNIT_ASSERT_EQUAL((TagLib::ushort) 1, p->lengthInPatterns()); - CPPUNIT_ASSERT_EQUAL((TagLib::ushort) 0, p->version()); - CPPUNIT_ASSERT_EQUAL((TagLib::ushort) 0 , p->restartPosition()); - CPPUNIT_ASSERT_EQUAL((TagLib::ushort) 1, p->patternCount()); - CPPUNIT_ASSERT_EQUAL((TagLib::ushort) 0, p->instrumentCount()); - CPPUNIT_ASSERT_EQUAL((TagLib::ushort) 1, p->flags()); - CPPUNIT_ASSERT_EQUAL((TagLib::ushort) 6, p->tempo()); - CPPUNIT_ASSERT_EQUAL((TagLib::ushort)125, p->bpmSpeed()); + CPPUNIT_ASSERT_EQUAL((unsigned short) 1, p->lengthInPatterns()); + CPPUNIT_ASSERT_EQUAL((unsigned short) 0, p->version()); + CPPUNIT_ASSERT_EQUAL((unsigned short) 0 , p->restartPosition()); + CPPUNIT_ASSERT_EQUAL((unsigned short) 1, p->patternCount()); + CPPUNIT_ASSERT_EQUAL((unsigned short) 0, p->instrumentCount()); + CPPUNIT_ASSERT_EQUAL((unsigned short) 1, p->flags()); + CPPUNIT_ASSERT_EQUAL((unsigned short) 6, p->tempo()); + CPPUNIT_ASSERT_EQUAL((unsigned short)125, p->bpmSpeed()); CPPUNIT_ASSERT_EQUAL(titleBefore, t->title()); CPPUNIT_ASSERT_EQUAL(String(), t->artist()); CPPUNIT_ASSERT_EQUAL(String(), t->album()); @@ -176,14 +176,14 @@ private: CPPUNIT_ASSERT_EQUAL(0, p->bitrate()); CPPUNIT_ASSERT_EQUAL(0, p->sampleRate()); CPPUNIT_ASSERT_EQUAL(8, p->channels()); - CPPUNIT_ASSERT_EQUAL((TagLib::ushort) 1, p->lengthInPatterns()); - CPPUNIT_ASSERT_EQUAL((TagLib::ushort)260, p->version()); - CPPUNIT_ASSERT_EQUAL((TagLib::ushort) 0, p->restartPosition()); - CPPUNIT_ASSERT_EQUAL((TagLib::ushort) 1, p->patternCount()); - CPPUNIT_ASSERT_EQUAL((TagLib::ushort)128, p->instrumentCount()); - CPPUNIT_ASSERT_EQUAL((TagLib::ushort) 1, p->flags()); - CPPUNIT_ASSERT_EQUAL((TagLib::ushort) 6, p->tempo()); - CPPUNIT_ASSERT_EQUAL((TagLib::ushort)125, p->bpmSpeed()); + CPPUNIT_ASSERT_EQUAL((unsigned short) 1, p->lengthInPatterns()); + CPPUNIT_ASSERT_EQUAL((unsigned short)260, p->version()); + CPPUNIT_ASSERT_EQUAL((unsigned short) 0, p->restartPosition()); + CPPUNIT_ASSERT_EQUAL((unsigned short) 1, p->patternCount()); + CPPUNIT_ASSERT_EQUAL((unsigned short)128, p->instrumentCount()); + CPPUNIT_ASSERT_EQUAL((unsigned short) 1, p->flags()); + CPPUNIT_ASSERT_EQUAL((unsigned short) 6, p->tempo()); + CPPUNIT_ASSERT_EQUAL((unsigned short)125, p->bpmSpeed()); CPPUNIT_ASSERT_EQUAL(title, t->title()); CPPUNIT_ASSERT_EQUAL(String(), t->artist()); CPPUNIT_ASSERT_EQUAL(String(), t->album()); From 363c471a2d9b28540324cb4807fc252c19c9d0fb Mon Sep 17 00:00:00 2001 From: Tsuda Kageyu Date: Wed, 2 Dec 2015 23:21:23 +0900 Subject: [PATCH 27/33] Small cosmetic fixes. --- taglib/ogg/xiphcomment.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/taglib/ogg/xiphcomment.cpp b/taglib/ogg/xiphcomment.cpp index 6267ee8c..9a81df17 100644 --- a/taglib/ogg/xiphcomment.cpp +++ b/taglib/ogg/xiphcomment.cpp @@ -441,7 +441,7 @@ void Ogg::XiphComment::parse(const ByteVector &data) pos += commentLength; // Don't go past data end - if (pos > data.size()) + if(pos > data.size()) break; // Handle Pictures separately @@ -452,7 +452,7 @@ void Ogg::XiphComment::parse(const ByteVector &data) // Decode base64 picture data ByteVector picturedata = ByteVector::fromBase64(entry.mid(23)); - if (picturedata.size()) { + if(picturedata.size()) { // Decode Flac Picture FLAC::Picture * picture = new FLAC::Picture(); @@ -478,7 +478,7 @@ void Ogg::XiphComment::parse(const ByteVector &data) } // Handle old picture standard - if (entry.startsWith("COVERART=")) { + if(entry.startsWith("COVERART=")) { if((entry.size() - 9) > 3 && ((entry.size() - 9) % 4) == 0) { @@ -507,7 +507,7 @@ void Ogg::XiphComment::parse(const ByteVector &data) // Check for field separator int sep = entry.find('='); - if (sep < 1) { + if(sep < 1) { debug("Discarding invalid comment field."); continue; } From 085a0ef2987496937292134adff6869b65a5be71 Mon Sep 17 00:00:00 2001 From: Tsuda Kageyu Date: Thu, 3 Dec 2015 00:03:06 +0900 Subject: [PATCH 28/33] Use a standard type rather than TagLib::ulong. This won't break the ABI compatibility. --- taglib/asf/asffile.cpp | 2 +- taglib/it/itfile.cpp | 8 +++--- taglib/mod/modfilebase.cpp | 12 ++++----- taglib/mod/modfilebase.h | 12 ++++----- taglib/mod/modfileprivate.h | 8 +++--- taglib/mpc/mpcproperties.cpp | 2 +- taglib/mpeg/mpegfile.cpp | 2 +- taglib/mpeg/xingheader.cpp | 4 +-- taglib/riff/rifffile.cpp | 4 +-- taglib/riff/rifffile.h | 2 +- taglib/toolkit/tbytevectorstream.cpp | 18 ++++++------- taglib/toolkit/tbytevectorstream.h | 6 ++--- taglib/toolkit/tfile.cpp | 6 ++--- taglib/toolkit/tfile.h | 6 ++--- taglib/toolkit/tfilestream.cpp | 12 ++++----- taglib/toolkit/tfilestream.h | 6 ++--- taglib/toolkit/tiostream.h | 7 ++--- taglib/xm/xmfile.cpp | 39 ++++++++++++++-------------- 18 files changed, 78 insertions(+), 78 deletions(-) diff --git a/taglib/asf/asffile.cpp b/taglib/asf/asffile.cpp index a5e5ea84..dc21dad4 100644 --- a/taglib/asf/asffile.cpp +++ b/taglib/asf/asffile.cpp @@ -600,7 +600,7 @@ bool ASF::File::save() writeBlock(ByteVector::fromUInt(d->objects.size(), false)); writeBlock(ByteVector("\x01\x02", 2)); - insert(data, 30, static_cast(d->headerSize - 30)); + insert(data, 30, static_cast(d->headerSize - 30)); d->headerSize = data.size() + 30; diff --git a/taglib/it/itfile.cpp b/taglib/it/itfile.cpp index 7508cfcb..7e140510 100644 --- a/taglib/it/itfile.cpp +++ b/taglib/it/itfile.cpp @@ -109,7 +109,7 @@ bool IT::File::save() StringList lines = d->tag.comment().split("\n"); for(unsigned short i = 0; i < instrumentCount; ++ i) { seek(192L + length + ((long)i << 2)); - ulong instrumentOffset = 0; + unsigned long instrumentOffset = 0; if(!readU32L(instrumentOffset)) return false; @@ -124,7 +124,7 @@ bool IT::File::save() for(unsigned short i = 0; i < sampleCount; ++ i) { seek(192L + length + ((long)instrumentCount << 2) + ((long)i << 2)); - ulong sampleOffset = 0; + unsigned long sampleOffset = 0; if(!readU32L(sampleOffset)) return false; @@ -151,13 +151,13 @@ bool IT::File::save() unsigned short special = 0; unsigned short messageLength = 0; - ulong messageOffset = 0; + unsigned long messageOffset = 0; seek(46); if(!readU16L(special)) return false; - ulong fileSize = File::length(); + unsigned long fileSize = File::length(); if(special & Properties::MessageAttached) { seek(54); if(!readU16L(messageLength) || !readU32L(messageOffset)) diff --git a/taglib/mod/modfilebase.cpp b/taglib/mod/modfilebase.cpp index 2ed16ae7..0cc15e86 100644 --- a/taglib/mod/modfilebase.cpp +++ b/taglib/mod/modfilebase.cpp @@ -33,14 +33,14 @@ Mod::FileBase::FileBase(IOStream *stream) : TagLib::File(stream) { } -void Mod::FileBase::writeString(const String &s, ulong size, char padding) +void Mod::FileBase::writeString(const String &s, unsigned long size, char padding) { ByteVector data(s.data(String::Latin1)); data.resize(size, padding); writeBlock(data); } -bool Mod::FileBase::readString(String &s, ulong size) +bool Mod::FileBase::readString(String &s, unsigned long size) { ByteVector data(readBlock(size)); if(data.size() < size) return false; @@ -66,7 +66,7 @@ void Mod::FileBase::writeU16L(unsigned short number) writeBlock(ByteVector::fromShort(number, false)); } -void Mod::FileBase::writeU32L(ulong number) +void Mod::FileBase::writeU32L(unsigned long number) { writeBlock(ByteVector::fromUInt(number, false)); } @@ -76,7 +76,7 @@ void Mod::FileBase::writeU16B(unsigned short number) writeBlock(ByteVector::fromShort(number, true)); } -void Mod::FileBase::writeU32B(ulong number) +void Mod::FileBase::writeU32B(unsigned long number) { writeBlock(ByteVector::fromUInt(number, true)); } @@ -97,7 +97,7 @@ bool Mod::FileBase::readU16L(unsigned short &number) return true; } -bool Mod::FileBase::readU32L(ulong &number) { +bool Mod::FileBase::readU32L(unsigned long &number) { ByteVector data(readBlock(4)); if(data.size() < 4) return false; number = data.toUInt(false); @@ -112,7 +112,7 @@ bool Mod::FileBase::readU16B(unsigned short &number) return true; } -bool Mod::FileBase::readU32B(ulong &number) { +bool Mod::FileBase::readU32B(unsigned long &number) { ByteVector data(readBlock(4)); if(data.size() < 4) return false; number = data.toUInt(true); diff --git a/taglib/mod/modfilebase.h b/taglib/mod/modfilebase.h index 82f3122b..5f76ccb0 100644 --- a/taglib/mod/modfilebase.h +++ b/taglib/mod/modfilebase.h @@ -40,19 +40,19 @@ namespace TagLib { FileBase(FileName file); FileBase(IOStream *stream); - void writeString(const String &s, ulong size, char padding = 0); + void writeString(const String &s, unsigned long size, char padding = 0); void writeByte(unsigned char byte); void writeU16L(unsigned short number); - void writeU32L(ulong number); + void writeU32L(unsigned long number); void writeU16B(unsigned short number); - void writeU32B(ulong number); + void writeU32B(unsigned long number); - bool readString(String &s, ulong size); + bool readString(String &s, unsigned long size); bool readByte(unsigned char &byte); bool readU16L(unsigned short &number); - bool readU32L(ulong &number); + bool readU32L(unsigned long &number); bool readU16B(unsigned short &number); - bool readU32B(ulong &number); + bool readU32B(unsigned long &number); }; } diff --git a/taglib/mod/modfileprivate.h b/taglib/mod/modfileprivate.h index a4fc8d33..781db74c 100644 --- a/taglib/mod/modfileprivate.h +++ b/taglib/mod/modfileprivate.h @@ -39,9 +39,9 @@ #define READ_BYTE(setter) READ(setter,unsigned char,readByte) #define READ_U16L(setter) READ(setter,unsigned short,readU16L) -#define READ_U32L(setter) READ(setter,ulong,readU32L) +#define READ_U32L(setter) READ(setter,unsigned long,readU32L) #define READ_U16B(setter) READ(setter,unsigned short,readU16B) -#define READ_U32B(setter) READ(setter,ulong,readU32B) +#define READ_U32B(setter) READ(setter,unsigned long,readU32B) #define READ_STRING(setter,size) \ { \ @@ -56,9 +56,9 @@ #define READ_BYTE_AS(name) READ_AS(unsigned char,name,readByte) #define READ_U16L_AS(name) READ_AS(unsigned short,name,readU16L) -#define READ_U32L_AS(name) READ_AS(ulong,name,readU32L) +#define READ_U32L_AS(name) READ_AS(unsigned long,name,readU32L) #define READ_U16B_AS(name) READ_AS(unsigned short,name,readU16B) -#define READ_U32B_AS(name) READ_AS(ulong,name,readU32B) +#define READ_U32B_AS(name) READ_AS(unsigned long,name,readU32B) #define READ_STRING_AS(name,size) \ String name; \ diff --git a/taglib/mpc/mpcproperties.cpp b/taglib/mpc/mpcproperties.cpp index 9c1274eb..2e42886e 100644 --- a/taglib/mpc/mpcproperties.cpp +++ b/taglib/mpc/mpcproperties.cpp @@ -247,7 +247,7 @@ void MPC::Properties::readSV8(File *file, long streamLength) break; } - const ulong begSilence = readSize(data, pos); + const unsigned long begSilence = readSize(data, pos); if(pos > dataSize - 2) { debug("MPC::Properties::readSV8() - \"SH\" packet is corrupt."); break; diff --git a/taglib/mpeg/mpegfile.cpp b/taglib/mpeg/mpegfile.cpp index adf7a850..716c2cfa 100644 --- a/taglib/mpeg/mpegfile.cpp +++ b/taglib/mpeg/mpegfile.cpp @@ -409,7 +409,7 @@ long MPEG::File::previousFrameOffset(long position) ByteVector buffer; while (position > 0) { - long size = ulong(position) < bufferSize() ? position : bufferSize(); + long size = std::min(position, bufferSize()); position -= size; seek(position); diff --git a/taglib/mpeg/xingheader.cpp b/taglib/mpeg/xingheader.cpp index 5a496184..6e554599 100644 --- a/taglib/mpeg/xingheader.cpp +++ b/taglib/mpeg/xingheader.cpp @@ -103,7 +103,7 @@ void MPEG::XingHeader::parse(const ByteVector &data) // Xing header found. - if(data.size() < static_cast(offset + 16)) { + if(data.size() < static_cast(offset + 16)) { debug("MPEG::XingHeader::parse() -- Xing header found but too short."); return; } @@ -127,7 +127,7 @@ void MPEG::XingHeader::parse(const ByteVector &data) // VBRI header found. - if(data.size() < static_cast(offset + 32)) { + if(data.size() < static_cast(offset + 32)) { debug("MPEG::XingHeader::parse() -- VBRI header found but too short."); return; } diff --git a/taglib/riff/rifffile.cpp b/taglib/riff/rifffile.cpp index 8317a57e..2518dd9e 100644 --- a/taglib/riff/rifffile.cpp +++ b/taglib/riff/rifffile.cpp @@ -178,7 +178,7 @@ void RIFF::File::setChunkData(const ByteVector &name, const ByteVector &data, bo // Couldn't find an existing chunk, so let's create a new one. uint i = d->chunks.size() - 1; - ulong offset = d->chunks[i].offset + d->chunks[i].size; + unsigned long offset = d->chunks[i].offset + d->chunks[i].size; // First we update the global size @@ -284,7 +284,7 @@ void RIFF::File::read() } void RIFF::File::writeChunk(const ByteVector &name, const ByteVector &data, - ulong offset, ulong replace, uint leadingPadding) + unsigned long offset, unsigned long replace, uint leadingPadding) { ByteVector combined; if(leadingPadding) { diff --git a/taglib/riff/rifffile.h b/taglib/riff/rifffile.h index 11d2b71a..766ae0c4 100644 --- a/taglib/riff/rifffile.h +++ b/taglib/riff/rifffile.h @@ -145,7 +145,7 @@ namespace TagLib { void read(); void writeChunk(const ByteVector &name, const ByteVector &data, - ulong offset, ulong replace = 0, + unsigned long offset, unsigned long replace = 0, uint leadingPadding = 0); class FilePrivate; diff --git a/taglib/toolkit/tbytevectorstream.cpp b/taglib/toolkit/tbytevectorstream.cpp index 230f7c99..90bee8e3 100644 --- a/taglib/toolkit/tbytevectorstream.cpp +++ b/taglib/toolkit/tbytevectorstream.cpp @@ -68,7 +68,7 @@ FileName ByteVectorStream::name() const return FileName(""); // XXX do we need a name? } -ByteVector ByteVectorStream::readBlock(ulong length) +ByteVector ByteVectorStream::readBlock(unsigned long length) { if(length == 0) return ByteVector(); @@ -88,7 +88,7 @@ void ByteVectorStream::writeBlock(const ByteVector &data) d->position += size; } -void ByteVectorStream::insert(const ByteVector &data, ulong start, ulong replace) +void ByteVectorStream::insert(const ByteVector &data, unsigned long start, unsigned long replace) { long sizeDiff = data.size() - replace; if(sizeDiff < 0) { @@ -96,20 +96,20 @@ void ByteVectorStream::insert(const ByteVector &data, ulong start, ulong replace } else if(sizeDiff > 0) { truncate(length() + sizeDiff); - ulong readPosition = start + replace; - ulong writePosition = start + data.size(); + unsigned long readPosition = start + replace; + unsigned long writePosition = start + data.size(); memmove(d->data.data() + writePosition, d->data.data() + readPosition, length() - sizeDiff - readPosition); } seek(start); writeBlock(data); } -void ByteVectorStream::removeBlock(ulong start, ulong length) +void ByteVectorStream::removeBlock(unsigned long start, unsigned long length) { - ulong readPosition = start + length; - ulong writePosition = start; - if(readPosition < ulong(ByteVectorStream::length())) { - ulong bytesToMove = ByteVectorStream::length() - readPosition; + unsigned long readPosition = start + length; + unsigned long writePosition = start; + if(readPosition < static_cast(ByteVectorStream::length())) { + unsigned long bytesToMove = ByteVectorStream::length() - readPosition; memmove(d->data.data() + writePosition, d->data.data() + readPosition, bytesToMove); writePosition += bytesToMove; } diff --git a/taglib/toolkit/tbytevectorstream.h b/taglib/toolkit/tbytevectorstream.h index 456b854e..84327c46 100644 --- a/taglib/toolkit/tbytevectorstream.h +++ b/taglib/toolkit/tbytevectorstream.h @@ -61,7 +61,7 @@ namespace TagLib { /*! * Reads a block of size \a length at the current get pointer. */ - ByteVector readBlock(ulong length); + ByteVector readBlock(unsigned long length); /*! * Attempts to write the block \a data at the current get pointer. If the @@ -81,7 +81,7 @@ namespace TagLib { * \note This method is slow since it requires rewriting all of the file * after the insertion point. */ - void insert(const ByteVector &data, ulong start = 0, ulong replace = 0); + void insert(const ByteVector &data, unsigned long start = 0, unsigned long replace = 0); /*! * Removes a block of the file starting a \a start and continuing for @@ -90,7 +90,7 @@ namespace TagLib { * \note This method is slow since it involves rewriting all of the file * after the removed portion. */ - void removeBlock(ulong start = 0, ulong length = 0); + void removeBlock(unsigned long start = 0, unsigned long length = 0); /*! * Returns true if the file is read only (or if the file can not be opened). diff --git a/taglib/toolkit/tfile.cpp b/taglib/toolkit/tfile.cpp index 2fca7445..4e53f505 100644 --- a/taglib/toolkit/tfile.cpp +++ b/taglib/toolkit/tfile.cpp @@ -224,7 +224,7 @@ PropertyMap File::setProperties(const PropertyMap &properties) return tag()->setProperties(properties); } -ByteVector File::readBlock(ulong length) +ByteVector File::readBlock(unsigned long length) { return d->stream->readBlock(length); } @@ -404,12 +404,12 @@ long File::rfind(const ByteVector &pattern, long fromOffset, const ByteVector &b return -1; } -void File::insert(const ByteVector &data, ulong start, ulong replace) +void File::insert(const ByteVector &data, unsigned long start, unsigned long replace) { d->stream->insert(data, start, replace); } -void File::removeBlock(ulong start, ulong length) +void File::removeBlock(unsigned long start, unsigned long length) { d->stream->removeBlock(start, length); } diff --git a/taglib/toolkit/tfile.h b/taglib/toolkit/tfile.h index 77840684..33288936 100644 --- a/taglib/toolkit/tfile.h +++ b/taglib/toolkit/tfile.h @@ -138,7 +138,7 @@ namespace TagLib { /*! * Reads a block of size \a length at the current get pointer. */ - ByteVector readBlock(ulong length); + ByteVector readBlock(unsigned long length); /*! * Attempts to write the block \a data at the current get pointer. If the @@ -190,7 +190,7 @@ namespace TagLib { * \note This method is slow since it requires rewriting all of the file * after the insertion point. */ - void insert(const ByteVector &data, ulong start = 0, ulong replace = 0); + void insert(const ByteVector &data, unsigned long start = 0, unsigned long replace = 0); /*! * Removes a block of the file starting a \a start and continuing for @@ -199,7 +199,7 @@ namespace TagLib { * \note This method is slow since it involves rewriting all of the file * after the removed portion. */ - void removeBlock(ulong start = 0, ulong length = 0); + void removeBlock(unsigned long start = 0, unsigned long length = 0); /*! * Returns true if the file is read only (or if the file can not be opened). diff --git a/taglib/toolkit/tfilestream.cpp b/taglib/toolkit/tfilestream.cpp index 0ced6c79..200b7fec 100644 --- a/taglib/toolkit/tfilestream.cpp +++ b/taglib/toolkit/tfilestream.cpp @@ -172,7 +172,7 @@ FileName FileStream::name() const return d->name; } -ByteVector FileStream::readBlock(ulong length) +ByteVector FileStream::readBlock(unsigned long length) { if(!isOpen()) { debug("FileStream::readBlock() -- invalid file."); @@ -182,7 +182,7 @@ ByteVector FileStream::readBlock(ulong length) if(length == 0) return ByteVector(); - const ulong streamLength = static_cast(FileStream::length()); + const unsigned long streamLength = static_cast(FileStream::length()); if(length > bufferSize() && length > streamLength) length = streamLength; @@ -209,7 +209,7 @@ void FileStream::writeBlock(const ByteVector &data) writeFile(d->file, data); } -void FileStream::insert(const ByteVector &data, ulong start, ulong replace) +void FileStream::insert(const ByteVector &data, unsigned long start, unsigned long replace) { if(!isOpen()) { debug("FileStream::insert() -- invalid file."); @@ -243,7 +243,7 @@ void FileStream::insert(const ByteVector &data, ulong start, ulong replace) // the *differnce* in the tag sizes. We want to avoid overwriting parts // that aren't yet in memory, so this is necessary. - ulong bufferLength = bufferSize(); + unsigned long bufferLength = bufferSize(); while(data.size() - replace > bufferLength) bufferLength += bufferSize(); @@ -291,14 +291,14 @@ void FileStream::insert(const ByteVector &data, ulong start, ulong replace) } } -void FileStream::removeBlock(ulong start, ulong length) +void FileStream::removeBlock(unsigned long start, unsigned long length) { if(!isOpen()) { debug("FileStream::removeBlock() -- invalid file."); return; } - ulong bufferLength = bufferSize(); + unsigned long bufferLength = bufferSize(); long readPosition = start + length; long writePosition = start; diff --git a/taglib/toolkit/tfilestream.h b/taglib/toolkit/tfilestream.h index fa113b73..a871032d 100644 --- a/taglib/toolkit/tfilestream.h +++ b/taglib/toolkit/tfilestream.h @@ -67,7 +67,7 @@ namespace TagLib { /*! * Reads a block of size \a length at the current get pointer. */ - ByteVector readBlock(ulong length); + ByteVector readBlock(unsigned long length); /*! * Attempts to write the block \a data at the current get pointer. If the @@ -87,7 +87,7 @@ namespace TagLib { * \note This method is slow since it requires rewriting all of the file * after the insertion point. */ - void insert(const ByteVector &data, ulong start = 0, ulong replace = 0); + void insert(const ByteVector &data, unsigned long start = 0, unsigned long replace = 0); /*! * Removes a block of the file starting a \a start and continuing for @@ -96,7 +96,7 @@ namespace TagLib { * \note This method is slow since it involves rewriting all of the file * after the removed portion. */ - void removeBlock(ulong start = 0, ulong length = 0); + void removeBlock(unsigned long start = 0, unsigned long length = 0); /*! * Returns true if the file is read only (or if the file can not be opened). diff --git a/taglib/toolkit/tiostream.h b/taglib/toolkit/tiostream.h index 6bb96b54..11053164 100644 --- a/taglib/toolkit/tiostream.h +++ b/taglib/toolkit/tiostream.h @@ -89,7 +89,7 @@ namespace TagLib { /*! * Reads a block of size \a length at the current get pointer. */ - virtual ByteVector readBlock(ulong length) = 0; + virtual ByteVector readBlock(unsigned long length) = 0; /*! * Attempts to write the block \a data at the current get pointer. If the @@ -109,7 +109,8 @@ namespace TagLib { * \note This method is slow since it requires rewriting all of the file * after the insertion point. */ - virtual void insert(const ByteVector &data, ulong start = 0, ulong replace = 0) = 0; + virtual void insert(const ByteVector &data, + unsigned long start = 0, unsigned long replace = 0) = 0; /*! * Removes a block of the file starting a \a start and continuing for @@ -118,7 +119,7 @@ namespace TagLib { * \note This method is slow since it involves rewriting all of the file * after the removed portion. */ - virtual void removeBlock(ulong start = 0, ulong length = 0) = 0; + virtual void removeBlock(unsigned long start = 0, unsigned long length = 0) = 0; /*! * Returns true if the file is read only (or if the file can not be opened). diff --git a/taglib/xm/xmfile.cpp b/taglib/xm/xmfile.cpp index 7fa032c7..7def0c09 100644 --- a/taglib/xm/xmfile.cpp +++ b/taglib/xm/xmfile.cpp @@ -31,7 +31,6 @@ using namespace TagLib; using namespace XM; using TagLib::uint; -using TagLib::ulong; /*! * The Reader classes are helpers to make handling of the stripped XM @@ -198,11 +197,11 @@ public: } }; -class U32Reader : public NumberReader +class U32Reader : public NumberReader { public: - U32Reader(ulong &value, bool bigEndian = true) : - NumberReader(value, bigEndian) + U32Reader(unsigned long &value, bool bigEndian = true) : + NumberReader(value, bigEndian) { } @@ -293,7 +292,7 @@ public: * Read a unsigned 32 Bit integer into \a number. The byte order * is controlled by \a bigEndian. */ - StructReader &u32(ulong &number, bool bigEndian) + StructReader &u32(unsigned long &number, bool bigEndian) { m_readers.append(new U32Reader(number, bigEndian)); return *this; @@ -302,7 +301,7 @@ public: /*! * Read a unsigned 32 Bit little endian integer into \a number. */ - StructReader &u32L(ulong &number) + StructReader &u32L(unsigned long &number) { return u32(number, false); } @@ -310,7 +309,7 @@ public: /*! * Read a unsigned 32 Bit big endian integer into \a number. */ - StructReader &u32B(ulong &number) + StructReader &u32B(unsigned long &number) { return u32(number, true); } @@ -410,7 +409,7 @@ bool XM::File::save() writeString(d->tag.trackerName(), 20); seek(60); - ulong headerSize = 0; + unsigned long headerSize = 0; if(!readU32L(headerSize)) return false; @@ -425,7 +424,7 @@ bool XM::File::save() // need to read patterns again in order to seek to the instruments: for(unsigned short i = 0; i < patternCount; ++ i) { seek(pos); - ulong patternHeaderLength = 0; + unsigned long patternHeaderLength = 0; if(!readU32L(patternHeaderLength) || patternHeaderLength < 4) return false; @@ -441,7 +440,7 @@ bool XM::File::save() uint sampleNameIndex = instrumentCount; for(unsigned short i = 0; i < instrumentCount; ++ i) { seek(pos); - ulong instrumentHeaderSize = 0; + unsigned long instrumentHeaderSize = 0; if(!readU32L(instrumentHeaderSize) || instrumentHeaderSize < 4) return false; @@ -459,7 +458,7 @@ bool XM::File::save() return false; } - ulong sampleHeaderSize = 0; + unsigned long sampleHeaderSize = 0; if(sampleCount > 0) { seek(pos + 29); if(instrumentHeaderSize < 33U || !readU32L(sampleHeaderSize)) @@ -471,7 +470,7 @@ bool XM::File::save() for(unsigned short j = 0; j < sampleCount; ++ j) { if(sampleHeaderSize > 4U) { seek(pos); - ulong sampleLength = 0; + unsigned long sampleLength = 0; if(!readU32L(sampleLength)) return false; @@ -532,7 +531,7 @@ void XM::File::read(bool) .u16L(bpmSpeed); uint count = header.read(*this, headerSize - 4U); - uint size = std::min(headerSize - 4U, (ulong)header.size()); + uint size = std::min(headerSize - 4U, (unsigned long)header.size()); READ_ASSERT(count == size); @@ -559,7 +558,7 @@ void XM::File::read(bool) pattern.byte(packingType).u16L(rowCount).u16L(dataSize); uint count = pattern.read(*this, patternHeaderLength - 4U); - READ_ASSERT(count == std::min(patternHeaderLength - 4U, (ulong)pattern.size())); + READ_ASSERT(count == std::min(patternHeaderLength - 4U, (unsigned long)pattern.size())); seek(patternHeaderLength - (4 + count) + dataSize, Current); } @@ -582,9 +581,9 @@ void XM::File::read(bool) // 4 for instrumentHeaderSize uint count = 4 + instrument.read(*this, instrumentHeaderSize - 4U); - READ_ASSERT(count == std::min(instrumentHeaderSize, (ulong)instrument.size() + 4)); + READ_ASSERT(count == std::min(instrumentHeaderSize, (unsigned long)instrument.size() + 4)); - ulong sampleHeaderSize = 0; + unsigned long sampleHeaderSize = 0; long offset = 0; if(sampleCount > 0) { sumSampleCount += sampleCount; @@ -594,9 +593,9 @@ void XM::File::read(bool) seek(instrumentHeaderSize - count - 4, Current); for(unsigned short j = 0; j < sampleCount; ++ j) { - ulong sampleLength = 0; - ulong loopStart = 0; - ulong loopLength = 0; + unsigned long sampleLength = 0; + unsigned long loopStart = 0; + unsigned long loopLength = 0; unsigned char volume = 0; unsigned char finetune = 0; unsigned char sampleType = 0; @@ -617,7 +616,7 @@ void XM::File::read(bool) .string(sampleName, 22); uint count = sample.read(*this, sampleHeaderSize); - READ_ASSERT(count == std::min(sampleHeaderSize, (ulong)sample.size())); + READ_ASSERT(count == std::min(sampleHeaderSize, (unsigned long)sample.size())); // skip unhandeled header proportion: seek(sampleHeaderSize - count, Current); From a0b86836568e294a6f6e83697ee6f9b1b8efb5cf Mon Sep 17 00:00:00 2001 From: Tsuda Kageyu Date: Thu, 3 Dec 2015 01:50:44 +0900 Subject: [PATCH 29/33] Use a standard type rather than TagLib::uint. This won't break the ABI compatibility. --- taglib/ape/apefile.cpp | 4 +- taglib/ape/apefooter.cpp | 20 +-- taglib/ape/apefooter.h | 14 +- taglib/ape/apeitem.cpp | 6 +- taglib/ape/apeproperties.cpp | 18 +-- taglib/ape/apeproperties.h | 2 +- taglib/ape/apetag.cpp | 18 +-- taglib/ape/apetag.h | 8 +- taglib/asf/asfattribute.cpp | 2 +- taglib/asf/asffile.cpp | 38 ++--- taglib/asf/asfpicture.cpp | 2 +- taglib/asf/asftag.cpp | 4 +- taglib/asf/asftag.h | 8 +- taglib/asf/asfutils.h | 2 +- taglib/flac/flacfile.cpp | 16 +- taglib/flac/flacpicture.cpp | 8 +- taglib/flac/flacproperties.cpp | 4 +- taglib/it/itfile.cpp | 4 +- taglib/mod/modfile.cpp | 12 +- taglib/mod/modproperties.cpp | 8 +- taglib/mod/modproperties.h | 4 +- taglib/mod/modtag.cpp | 8 +- taglib/mod/modtag.h | 8 +- taglib/mp4/mp4item.cpp | 6 +- taglib/mp4/mp4item.h | 4 +- taglib/mp4/mp4properties.cpp | 4 +- taglib/mp4/mp4tag.cpp | 8 +- taglib/mp4/mp4tag.h | 8 +- taglib/mpc/mpcfile.cpp | 4 +- taglib/mpc/mpcproperties.cpp | 46 +++--- taglib/mpc/mpcproperties.h | 6 +- taglib/mpeg/id3v1/id3v1tag.cpp | 12 +- taglib/mpeg/id3v1/id3v1tag.h | 12 +- .../id3v2/frames/attachedpictureframe.cpp | 2 +- taglib/mpeg/id3v2/frames/chapterframe.cpp | 32 ++-- taglib/mpeg/id3v2/frames/chapterframe.h | 20 +-- .../id3v2/frames/eventtimingcodesframe.cpp | 2 +- .../mpeg/id3v2/frames/eventtimingcodesframe.h | 4 +- .../mpeg/id3v2/frames/popularimeterframe.cpp | 8 +- taglib/mpeg/id3v2/frames/popularimeterframe.h | 4 +- .../mpeg/id3v2/frames/relativevolumeframe.cpp | 2 +- .../id3v2/frames/synchronizedlyricsframe.cpp | 5 +- .../id3v2/frames/synchronizedlyricsframe.h | 4 +- .../id3v2/frames/tableofcontentsframe.cpp | 10 +- .../mpeg/id3v2/frames/tableofcontentsframe.h | 2 +- .../id3v2/frames/textidentificationframe.cpp | 28 ++-- taglib/mpeg/id3v2/id3v2extendedheader.cpp | 4 +- taglib/mpeg/id3v2/id3v2extendedheader.h | 2 +- taglib/mpeg/id3v2/id3v2footer.cpp | 2 +- taglib/mpeg/id3v2/id3v2footer.h | 2 +- taglib/mpeg/id3v2/id3v2frame.cpp | 38 ++--- taglib/mpeg/id3v2/id3v2frame.h | 24 +-- taglib/mpeg/id3v2/id3v2framefactory.cpp | 8 +- taglib/mpeg/id3v2/id3v2framefactory.h | 2 +- taglib/mpeg/id3v2/id3v2header.cpp | 20 +-- taglib/mpeg/id3v2/id3v2header.h | 14 +- taglib/mpeg/id3v2/id3v2synchdata.cpp | 6 +- taglib/mpeg/id3v2/id3v2synchdata.h | 4 +- taglib/mpeg/id3v2/id3v2tag.cpp | 20 +-- taglib/mpeg/id3v2/id3v2tag.h | 8 +- taglib/mpeg/mpegfile.cpp | 6 +- taglib/mpeg/xingheader.cpp | 8 +- taglib/mpeg/xingheader.h | 4 +- taglib/ogg/flac/oggflacfile.cpp | 2 +- taglib/ogg/oggfile.cpp | 18 +-- taglib/ogg/oggfile.h | 4 +- taglib/ogg/oggpage.cpp | 6 +- taglib/ogg/oggpage.h | 6 +- taglib/ogg/oggpageheader.cpp | 6 +- taglib/ogg/oggpageheader.h | 4 +- taglib/ogg/opus/opusproperties.cpp | 2 +- taglib/ogg/speex/speexproperties.cpp | 2 +- taglib/ogg/vorbis/vorbisproperties.cpp | 2 +- taglib/ogg/xiphcomment.cpp | 22 +-- taglib/ogg/xiphcomment.h | 10 +- taglib/riff/aiff/aifffile.cpp | 2 +- taglib/riff/aiff/aiffproperties.cpp | 8 +- taglib/riff/aiff/aiffproperties.h | 2 +- taglib/riff/rifffile.cpp | 43 ++--- taglib/riff/rifffile.h | 20 +-- taglib/riff/wav/infotag.cpp | 12 +- taglib/riff/wav/infotag.h | 8 +- taglib/riff/wav/wavfile.cpp | 2 +- taglib/riff/wav/wavproperties.cpp | 16 +- taglib/riff/wav/wavproperties.h | 4 +- taglib/tag.h | 8 +- taglib/tagunion.cpp | 8 +- taglib/tagunion.h | 8 +- taglib/toolkit/taglib.h | 6 +- taglib/toolkit/tbytevector.cpp | 90 +++++------ taglib/toolkit/tbytevector.h | 46 +++--- taglib/toolkit/tbytevectorlist.cpp | 2 +- taglib/toolkit/tbytevectorstream.cpp | 2 +- taglib/toolkit/tfile.cpp | 2 +- taglib/toolkit/tfile.h | 2 +- taglib/toolkit/tfilestream.cpp | 10 +- taglib/toolkit/tfilestream.h | 2 +- taglib/toolkit/tlist.h | 6 +- taglib/toolkit/tlist.tcc | 6 +- taglib/toolkit/tmap.h | 2 +- taglib/toolkit/tmap.tcc | 2 +- taglib/toolkit/tstring.cpp | 8 +- taglib/toolkit/tstring.h | 6 +- taglib/toolkit/tutils.h | 2 +- taglib/trueaudio/trueaudiofile.cpp | 2 +- taglib/trueaudio/trueaudioproperties.cpp | 6 +- taglib/trueaudio/trueaudioproperties.h | 4 +- taglib/wavpack/wavpackfile.cpp | 2 +- taglib/wavpack/wavpackproperties.cpp | 16 +- taglib/wavpack/wavpackproperties.h | 6 +- taglib/xm/xmfile.cpp | 69 ++++---- taglib/xm/xmproperties.cpp | 6 +- taglib/xm/xmproperties.h | 4 +- tests/test_apetag.cpp | 4 +- tests/test_asf.cpp | 8 +- tests/test_bytevector.cpp | 18 +-- tests/test_bytevectorlist.cpp | 4 +- tests/test_file.cpp | 4 +- tests/test_fileref.cpp | 12 +- tests/test_flac.cpp | 26 +-- tests/test_flacpicture.cpp | 2 +- tests/test_id3v2.cpp | 78 ++++----- tests/test_info.cpp | 10 +- tests/test_it.cpp | 1 - tests/test_mp4.cpp | 20 +-- tests/test_mpeg.cpp | 6 +- tests/test_ogg.cpp | 14 +- tests/test_riff.cpp | 150 +++++++++--------- tests/test_string.cpp | 6 +- tests/test_synchdata.cpp | 12 +- tests/test_xiphcomment.cpp | 14 +- 131 files changed, 775 insertions(+), 771 deletions(-) diff --git a/taglib/ape/apefile.cpp b/taglib/ape/apefile.cpp index 24171145..18d8cecc 100644 --- a/taglib/ape/apefile.cpp +++ b/taglib/ape/apefile.cpp @@ -73,13 +73,13 @@ public: } long APELocation; - uint APESize; + unsigned int APESize; long ID3v1Location; ID3v2::Header *ID3v2Header; long ID3v2Location; - uint ID3v2Size; + unsigned int ID3v2Size; TagUnion tag; diff --git a/taglib/ape/apefooter.cpp b/taglib/ape/apefooter.cpp index c9880cdd..c5c99a5a 100644 --- a/taglib/ape/apefooter.cpp +++ b/taglib/ape/apefooter.cpp @@ -46,22 +46,22 @@ public: itemCount(0), tagSize(0) {} - uint version; + unsigned int version; bool footerPresent; bool headerPresent; bool isHeader; - uint itemCount; - uint tagSize; + unsigned int itemCount; + unsigned int tagSize; }; //////////////////////////////////////////////////////////////////////////////// // static members //////////////////////////////////////////////////////////////////////////////// -TagLib::uint APE::Footer::size() +unsigned int APE::Footer::size() { return 32; } @@ -91,7 +91,7 @@ APE::Footer::~Footer() delete d; } -TagLib::uint APE::Footer::version() const +unsigned int APE::Footer::version() const { return d->version; } @@ -116,22 +116,22 @@ void APE::Footer::setHeaderPresent(bool b) const d->headerPresent = b; } -TagLib::uint APE::Footer::itemCount() const +unsigned int APE::Footer::itemCount() const { return d->itemCount; } -void APE::Footer::setItemCount(uint s) +void APE::Footer::setItemCount(unsigned int s) { d->itemCount = s; } -TagLib::uint APE::Footer::tagSize() const +unsigned int APE::Footer::tagSize() const { return d->tagSize; } -TagLib::uint APE::Footer::completeTagSize() const +unsigned int APE::Footer::completeTagSize() const { if(d->headerPresent) return d->tagSize + size(); @@ -139,7 +139,7 @@ TagLib::uint APE::Footer::completeTagSize() const return d->tagSize; } -void APE::Footer::setTagSize(uint s) +void APE::Footer::setTagSize(unsigned int s) { d->tagSize = s; } diff --git a/taglib/ape/apefooter.h b/taglib/ape/apefooter.h index 683af12f..47741d0d 100644 --- a/taglib/ape/apefooter.h +++ b/taglib/ape/apefooter.h @@ -64,7 +64,7 @@ namespace TagLib { /*! * Returns the version number. (Note: This is the 1000 or 2000.) */ - uint version() const; + unsigned int version() const; /*! * Returns true if a header is present in the tag. @@ -89,13 +89,13 @@ namespace TagLib { /*! * Returns the number of items in the tag. */ - uint itemCount() const; + unsigned int itemCount() const; /*! * Set the item count to \a s. * \see itemCount() */ - void setItemCount(uint s); + void setItemCount(unsigned int s); /*! * Returns the tag size in bytes. This is the size of the frame content and footer. @@ -103,7 +103,7 @@ namespace TagLib { * * \see completeTagSize() */ - uint tagSize() const; + unsigned int tagSize() const; /*! * Returns the tag size, including if present, the header @@ -111,18 +111,18 @@ namespace TagLib { * * \see tagSize() */ - uint completeTagSize() const; + unsigned int completeTagSize() const; /*! * Set the tag size to \a s. * \see tagSize() */ - void setTagSize(uint s); + void setTagSize(unsigned int s); /*! * Returns the size of the footer. Presently this is always 32 bytes. */ - static uint size(); + static unsigned int size(); /*! * Returns the string used to identify an APE tag inside of a file. diff --git a/taglib/ape/apeitem.cpp b/taglib/ape/apeitem.cpp index 80bed072..ebfb13df 100644 --- a/taglib/ape/apeitem.cpp +++ b/taglib/ape/apeitem.cpp @@ -247,8 +247,8 @@ void APE::Item::parse(const ByteVector &data) return; } - const uint valueLength = data.toUInt(0, false); - const uint flags = data.toUInt(4, false); + const unsigned int valueLength = data.toUInt(0, false); + const unsigned int flags = data.toUInt(4, false); d->key = String(data.mid(8), String::UTF8); @@ -266,7 +266,7 @@ void APE::Item::parse(const ByteVector &data) ByteVector APE::Item::render() const { ByteVector data; - TagLib::uint flags = ((d->readOnly) ? 1 : 0) | (d->type << 1); + unsigned int flags = ((d->readOnly) ? 1 : 0) | (d->type << 1); ByteVector value; if(isEmpty()) diff --git a/taglib/ape/apeproperties.cpp b/taglib/ape/apeproperties.cpp index 4a339456..26efd15f 100644 --- a/taglib/ape/apeproperties.cpp +++ b/taglib/ape/apeproperties.cpp @@ -56,7 +56,7 @@ public: int channels; int version; int bitsPerSample; - uint sampleFrames; + unsigned int sampleFrames; }; //////////////////////////////////////////////////////////////////////////////// @@ -122,7 +122,7 @@ int APE::Properties::bitsPerSample() const return d->bitsPerSample; } -TagLib::uint APE::Properties::sampleFrames() const +unsigned int APE::Properties::sampleFrames() const { return d->sampleFrames; } @@ -184,7 +184,7 @@ void APE::Properties::analyzeCurrent(File *file) return; } - const uint descriptorBytes = descriptor.toUInt(0, false); + const unsigned int descriptorBytes = descriptor.toUInt(0, false); if((descriptorBytes - 52) > 0) file->seek(descriptorBytes - 52, File::Current); @@ -201,12 +201,12 @@ void APE::Properties::analyzeCurrent(File *file) d->sampleRate = header.toUInt(20, false); d->bitsPerSample = header.toShort(16, false); - const uint totalFrames = header.toUInt(12, false); + const unsigned int totalFrames = header.toUInt(12, false); if(totalFrames == 0) return; - const uint blocksPerFrame = header.toUInt(4, false); - const uint finalFrameBlocks = header.toUInt(8, false); + const unsigned int blocksPerFrame = header.toUInt(4, false); + const unsigned int finalFrameBlocks = header.toUInt(8, false); d->sampleFrames = (totalFrames - 1) * blocksPerFrame + finalFrameBlocks; } @@ -218,14 +218,14 @@ void APE::Properties::analyzeOld(File *file) return; } - const uint totalFrames = header.toUInt(18, false); + const unsigned int totalFrames = header.toUInt(18, false); // Fail on 0 length APE files (catches non-finalized APE files) if(totalFrames == 0) return; const short compressionLevel = header.toShort(0, false); - uint blocksPerFrame; + unsigned int blocksPerFrame; if(d->version >= 3950) blocksPerFrame = 73728 * 4; else if(d->version >= 3900 || (d->version >= 3800 && compressionLevel == 4000)) @@ -237,7 +237,7 @@ void APE::Properties::analyzeOld(File *file) d->channels = header.toShort(4, false); d->sampleRate = header.toUInt(6, false); - const uint finalFrameBlocks = header.toUInt(22, false); + const unsigned int finalFrameBlocks = header.toUInt(22, false); d->sampleFrames = (totalFrames - 1) * blocksPerFrame + finalFrameBlocks; // Get the bit depth from the RIFF-fmt chunk. diff --git a/taglib/ape/apeproperties.h b/taglib/ape/apeproperties.h index fcf125ff..91625483 100644 --- a/taglib/ape/apeproperties.h +++ b/taglib/ape/apeproperties.h @@ -118,7 +118,7 @@ namespace TagLib { /*! * Returns the total number of audio samples in file. */ - uint sampleFrames() const; + unsigned int sampleFrames() const; /*! * Returns APE version. diff --git a/taglib/ape/apetag.cpp b/taglib/ape/apetag.cpp index 4e282faa..16e56c1f 100644 --- a/taglib/ape/apetag.cpp +++ b/taglib/ape/apetag.cpp @@ -112,14 +112,14 @@ String APE::Tag::genre() const return d->itemListMap["GENRE"].values().toString(); } -TagLib::uint APE::Tag::year() const +unsigned int APE::Tag::year() const { if(d->itemListMap["YEAR"].isEmpty()) return 0; return d->itemListMap["YEAR"].toString().toInt(); } -TagLib::uint APE::Tag::track() const +unsigned int APE::Tag::track() const { if(d->itemListMap["TRACK"].isEmpty()) return 0; @@ -151,7 +151,7 @@ void APE::Tag::setGenre(const String &s) addValue("GENRE", s, true); } -void APE::Tag::setYear(uint i) +void APE::Tag::setYear(unsigned int i) { if(i <= 0) removeItem("YEAR"); @@ -159,7 +159,7 @@ void APE::Tag::setYear(uint i) addValue("YEAR", String::number(i), true); } -void APE::Tag::setTrack(uint i) +void APE::Tag::setTrack(unsigned int i) { if(i <= 0) removeItem("TRACK"); @@ -215,7 +215,7 @@ PropertyMap APE::Tag::setProperties(const PropertyMap &origProps) PropertyMap properties(origProps); // make a local copy that can be modified // see comment in properties() - for(uint i = 0; i < keyConversionsSize; ++i) + for(size_t i = 0; i < keyConversionsSize; ++i) if(properties.contains(keyConversions[i][0])) { properties.insert(keyConversions[i][1], properties[keyConversions[i][0]]); properties.erase(keyConversions[i][0]); @@ -333,7 +333,7 @@ void APE::Tag::read(TagLib::File *file, long footerLocation) d->footer.setData(file->readBlock(Footer::size())); if(d->footer.tagSize() <= Footer::size() || - d->footer.tagSize() > uint(file->length())) + d->footer.tagSize() > static_cast(file->length())) return; file->seek(footerLocation + Footer::size() - d->footer.tagSize()); @@ -344,7 +344,7 @@ void APE::Tag::read(TagLib::File *file, long footerLocation) ByteVector APE::Tag::render() const { ByteVector data; - uint itemCount = 0; + unsigned int itemCount = 0; for(ItemListMap::ConstIterator it = d->itemListMap.begin(); it != d->itemListMap.end(); ++it) { data.append(it->second.render()); @@ -365,9 +365,9 @@ void APE::Tag::parse(const ByteVector &data) if(data.size() < 11) return; - uint pos = 0; + unsigned int pos = 0; - for(uint i = 0; i < d->footer.itemCount() && pos <= data.size() - 11; i++) { + for(unsigned int i = 0; i < d->footer.itemCount() && pos <= data.size() - 11; i++) { APE::Item item; item.parse(data.mid(pos)); diff --git a/taglib/ape/apetag.h b/taglib/ape/apetag.h index 6c9999cf..b76419ee 100644 --- a/taglib/ape/apetag.h +++ b/taglib/ape/apetag.h @@ -92,16 +92,16 @@ namespace TagLib { virtual String album() const; virtual String comment() const; virtual String genre() const; - virtual uint year() const; - virtual uint track() const; + virtual unsigned int year() const; + virtual unsigned int 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(unsigned int i); + virtual void setTrack(unsigned int i); /*! * Implements the unified tag dictionary interface -- export function. diff --git a/taglib/asf/asfattribute.cpp b/taglib/asf/asfattribute.cpp index a70330b0..1e6ed705 100644 --- a/taglib/asf/asfattribute.cpp +++ b/taglib/asf/asfattribute.cpp @@ -182,7 +182,7 @@ ASF::Picture ASF::Attribute::toPicture() const String ASF::Attribute::parse(ASF::File &f, int kind) { - uint size, nameLength; + unsigned int size, nameLength; String name; d->pictureValue = Picture::fromInvalid(); // extended content descriptor diff --git a/taglib/asf/asffile.cpp b/taglib/asf/asffile.cpp index dc21dad4..8f395265 100644 --- a/taglib/asf/asffile.cpp +++ b/taglib/asf/asffile.cpp @@ -120,21 +120,21 @@ class ASF::File::FilePrivate::FilePropertiesObject : public ASF::File::FilePriva { public: ByteVector guid() const; - void parse(ASF::File *file, uint size); + void parse(ASF::File *file, unsigned int size); }; class ASF::File::FilePrivate::StreamPropertiesObject : public ASF::File::FilePrivate::BaseObject { public: ByteVector guid() const; - void parse(ASF::File *file, uint size); + void parse(ASF::File *file, unsigned int size); }; class ASF::File::FilePrivate::ContentDescriptionObject : public ASF::File::FilePrivate::BaseObject { public: ByteVector guid() const; - void parse(ASF::File *file, uint size); + void parse(ASF::File *file, unsigned int size); ByteVector render(ASF::File *file); }; @@ -143,7 +143,7 @@ class ASF::File::FilePrivate::ExtendedContentDescriptionObject : public ASF::Fil public: ByteVectorList attributeData; ByteVector guid() const; - void parse(ASF::File *file, uint size); + void parse(ASF::File *file, unsigned int size); ByteVector render(ASF::File *file); }; @@ -152,7 +152,7 @@ class ASF::File::FilePrivate::MetadataObject : public ASF::File::FilePrivate::Ba public: ByteVectorList attributeData; ByteVector guid() const; - void parse(ASF::File *file, uint size); + void parse(ASF::File *file, unsigned int size); ByteVector render(ASF::File *file); }; @@ -161,7 +161,7 @@ class ASF::File::FilePrivate::MetadataLibraryObject : public ASF::File::FilePriv public: ByteVectorList attributeData; ByteVector guid() const; - void parse(ASF::File *file, uint size); + void parse(ASF::File *file, unsigned int size); ByteVector render(ASF::File *file); }; @@ -171,7 +171,7 @@ public: List objects; HeaderExtensionObject(); ByteVector guid() const; - void parse(ASF::File *file, uint size); + void parse(ASF::File *file, unsigned int size); ByteVector render(ASF::File *file); }; @@ -179,7 +179,7 @@ class ASF::File::FilePrivate::CodecListObject : public ASF::File::FilePrivate::B { public: ByteVector guid() const; - void parse(ASF::File *file, uint size); + void parse(ASF::File *file, unsigned int size); private: enum CodecType @@ -218,7 +218,7 @@ ByteVector ASF::File::FilePrivate::FilePropertiesObject::guid() const return filePropertiesGuid; } -void ASF::File::FilePrivate::FilePropertiesObject::parse(ASF::File *file, uint size) +void ASF::File::FilePrivate::FilePropertiesObject::parse(ASF::File *file, unsigned int size) { BaseObject::parse(file, size); if(data.size() < 64) { @@ -236,7 +236,7 @@ ByteVector ASF::File::FilePrivate::StreamPropertiesObject::guid() const return streamPropertiesGuid; } -void ASF::File::FilePrivate::StreamPropertiesObject::parse(ASF::File *file, uint size) +void ASF::File::FilePrivate::StreamPropertiesObject::parse(ASF::File *file, unsigned int size) { BaseObject::parse(file, size); if(data.size() < 70) { @@ -256,7 +256,7 @@ ByteVector ASF::File::FilePrivate::ContentDescriptionObject::guid() const return contentDescriptionGuid; } -void ASF::File::FilePrivate::ContentDescriptionObject::parse(ASF::File *file, uint /*size*/) +void ASF::File::FilePrivate::ContentDescriptionObject::parse(ASF::File *file, unsigned int /*size*/) { file->d->contentDescriptionObject = this; const int titleLength = readWORD(file); @@ -297,7 +297,7 @@ ByteVector ASF::File::FilePrivate::ExtendedContentDescriptionObject::guid() cons return extendedContentDescriptionGuid; } -void ASF::File::FilePrivate::ExtendedContentDescriptionObject::parse(ASF::File *file, uint /*size*/) +void ASF::File::FilePrivate::ExtendedContentDescriptionObject::parse(ASF::File *file, unsigned int /*size*/) { file->d->extendedContentDescriptionObject = this; int count = readWORD(file); @@ -321,7 +321,7 @@ ByteVector ASF::File::FilePrivate::MetadataObject::guid() const return metadataGuid; } -void ASF::File::FilePrivate::MetadataObject::parse(ASF::File *file, uint /*size*/) +void ASF::File::FilePrivate::MetadataObject::parse(ASF::File *file, unsigned int /*size*/) { file->d->metadataObject = this; int count = readWORD(file); @@ -345,7 +345,7 @@ ByteVector ASF::File::FilePrivate::MetadataLibraryObject::guid() const return metadataLibraryGuid; } -void ASF::File::FilePrivate::MetadataLibraryObject::parse(ASF::File *file, uint /*size*/) +void ASF::File::FilePrivate::MetadataLibraryObject::parse(ASF::File *file, unsigned int /*size*/) { file->d->metadataLibraryObject = this; int count = readWORD(file); @@ -374,7 +374,7 @@ ByteVector ASF::File::FilePrivate::HeaderExtensionObject::guid() const return headerExtensionGuid; } -void ASF::File::FilePrivate::HeaderExtensionObject::parse(ASF::File *file, uint /*size*/) +void ASF::File::FilePrivate::HeaderExtensionObject::parse(ASF::File *file, unsigned int /*size*/) { file->d->headerExtensionObject = this; file->seek(18, File::Current); @@ -423,7 +423,7 @@ ByteVector ASF::File::FilePrivate::CodecListObject::guid() const return codecListGuid; } -void ASF::File::FilePrivate::CodecListObject::parse(ASF::File *file, uint size) +void ASF::File::FilePrivate::CodecListObject::parse(ASF::File *file, unsigned int size) { BaseObject::parse(file, size); if(data.size() <= 20) { @@ -431,7 +431,7 @@ void ASF::File::FilePrivate::CodecListObject::parse(ASF::File *file, uint size) return; } - uint pos = 16; + unsigned int pos = 16; const int count = data.toUInt(pos, false); pos += 4; @@ -447,13 +447,13 @@ void ASF::File::FilePrivate::CodecListObject::parse(ASF::File *file, uint size) int nameLength = data.toUShort(pos, false); pos += 2; - const uint namePos = pos; + const unsigned int namePos = pos; pos += nameLength * 2; const int descLength = data.toUShort(pos, false); pos += 2; - const uint descPos = pos; + const unsigned int descPos = pos; pos += descLength * 2; const int infoLength = data.toUShort(pos, false); diff --git a/taglib/asf/asfpicture.cpp b/taglib/asf/asfpicture.cpp index 5a3e4411..7039fb15 100644 --- a/taglib/asf/asfpicture.cpp +++ b/taglib/asf/asfpicture.cpp @@ -151,7 +151,7 @@ void ASF::Picture::parse(const ByteVector& bytes) return; int pos = 0; d->type = (Type)bytes[0]; ++pos; - const uint dataLen = bytes.toUInt(pos, false); pos+=4; + const unsigned int dataLen = bytes.toUInt(pos, false); pos+=4; const ByteVector nullStringTerminator(2, 0); diff --git a/taglib/asf/asftag.cpp b/taglib/asf/asftag.cpp index ea9141a3..ed2dba52 100644 --- a/taglib/asf/asftag.cpp +++ b/taglib/asf/asftag.cpp @@ -145,12 +145,12 @@ void ASF::Tag::setGenre(const String &value) setAttribute("WM/Genre", value); } -void ASF::Tag::setYear(uint value) +void ASF::Tag::setYear(unsigned int value) { setAttribute("WM/Year", String::number(value)); } -void ASF::Tag::setTrack(uint value) +void ASF::Tag::setTrack(unsigned int value) { setAttribute("WM/TrackNumber", String::number(value)); } diff --git a/taglib/asf/asftag.h b/taglib/asf/asftag.h index 8f322b18..049b9f66 100644 --- a/taglib/asf/asftag.h +++ b/taglib/asf/asftag.h @@ -90,13 +90,13 @@ namespace TagLib { /*! * Returns the year; if there is no year set, this will return 0. */ - virtual uint year() const; + virtual unsigned int year() const; /*! * Returns the track number; if there is no track number set, this will * return 0. */ - virtual uint track() const; + virtual unsigned int track() const; /*! * Sets the title to \a s. @@ -137,12 +137,12 @@ namespace TagLib { /*! * Sets the year to \a i. If \a s is 0 then this value will be cleared. */ - virtual void setYear(uint i); + virtual void setYear(unsigned int i); /*! * Sets the track to \a i. If \a s is 0 then this value will be cleared. */ - virtual void setTrack(uint i); + virtual void setTrack(unsigned int i); /*! * Returns true if the tag does not contain any data. This should be diff --git a/taglib/asf/asfutils.h b/taglib/asf/asfutils.h index 9a949413..e3595a70 100644 --- a/taglib/asf/asfutils.h +++ b/taglib/asf/asfutils.h @@ -46,7 +46,7 @@ namespace TagLib return v.toUShort(false); } - inline uint readDWORD(File *file, bool *ok = 0) + inline unsigned int readDWORD(File *file, bool *ok = 0) { const ByteVector v = file->readBlock(4); if(v.size() != 4) { diff --git a/taglib/flac/flacfile.cpp b/taglib/flac/flacfile.cpp index 252907d0..7f871c88 100644 --- a/taglib/flac/flacfile.cpp +++ b/taglib/flac/flacfile.cpp @@ -70,8 +70,8 @@ public: ~FilePrivate() { - uint size = blocks.size(); - for(uint i = 0; i < size; i++) { + unsigned int size = blocks.size(); + for(unsigned int i = 0; i < size; i++) { delete blocks[i]; } delete properties; @@ -79,7 +79,7 @@ public: const ID3v2::FrameFactory *ID3v2FrameFactory; long ID3v2Location; - uint ID3v2OriginalSize; + unsigned int ID3v2OriginalSize; long ID3v1Location; @@ -182,7 +182,7 @@ bool FLAC::File::save() bool foundVorbisCommentBlock = false; List newBlocks; - for(uint i = 0; i < d->blocks.size(); i++) { + for(unsigned int i = 0; i < d->blocks.size(); i++) { MetadataBlock *block = d->blocks[i]; if(block->code() == MetadataBlock::VorbisComment) { // Set the new Vorbis Comment block @@ -205,7 +205,7 @@ bool FLAC::File::save() // Render data for the metadata blocks ByteVector data; - for(uint i = 0; i < newBlocks.size(); i++) { + for(unsigned int i = 0; i < newBlocks.size(); i++) { FLAC::MetadataBlock *block = newBlocks[i]; ByteVector blockData = block->render(); ByteVector blockHeader = ByteVector::fromUInt(blockData.size()); @@ -300,7 +300,7 @@ long FLAC::File::streamLength() List FLAC::File::pictureList() { List pictures; - for(uint i = 0; i < d->blocks.size(); i++) { + for(unsigned int i = 0; i < d->blocks.size(); i++) { Picture *picture = dynamic_cast(d->blocks[i]); if(picture) { pictures.append(picture); @@ -328,7 +328,7 @@ void FLAC::File::removePicture(Picture *picture, bool del) void FLAC::File::removePictures() { List newBlocks; - for(uint i = 0; i < d->blocks.size(); i++) { + for(unsigned int i = 0; i < d->blocks.size(); i++) { Picture *picture = dynamic_cast(d->blocks[i]); if(picture) { delete picture; @@ -457,7 +457,7 @@ void FLAC::File::scan() char blockType = header[0] & 0x7f; bool isLastBlock = (header[0] & 0x80) != 0; - uint length = header.toUInt(1U, 3U); + unsigned int length = header.toUInt(1U, 3U); // First block should be the stream_info metadata diff --git a/taglib/flac/flacpicture.cpp b/taglib/flac/flacpicture.cpp index a2a9000b..72c97247 100644 --- a/taglib/flac/flacpicture.cpp +++ b/taglib/flac/flacpicture.cpp @@ -78,10 +78,10 @@ bool FLAC::Picture::parse(const ByteVector &data) return false; } - uint pos = 0; + unsigned int pos = 0; d->type = FLAC::Picture::Type(data.toUInt(pos)); pos += 4; - uint mimeTypeLength = data.toUInt(pos); + unsigned int mimeTypeLength = data.toUInt(pos); pos += 4; if(pos + mimeTypeLength + 24 > data.size()) { debug("Invalid picture block."); @@ -89,7 +89,7 @@ bool FLAC::Picture::parse(const ByteVector &data) } d->mimeType = String(data.mid(pos, mimeTypeLength), String::UTF8); pos += mimeTypeLength; - uint descriptionLength = data.toUInt(pos); + unsigned int descriptionLength = data.toUInt(pos); pos += 4; if(pos + descriptionLength + 20 > data.size()) { debug("Invalid picture block."); @@ -105,7 +105,7 @@ bool FLAC::Picture::parse(const ByteVector &data) pos += 4; d->numColors = data.toUInt(pos); pos += 4; - uint dataLength = data.toUInt(pos); + unsigned int dataLength = data.toUInt(pos); pos += 4; if(pos + dataLength > data.size()) { debug("Invalid picture block."); diff --git a/taglib/flac/flacproperties.cpp b/taglib/flac/flacproperties.cpp index 9f0f9256..b947f039 100644 --- a/taglib/flac/flacproperties.cpp +++ b/taglib/flac/flacproperties.cpp @@ -135,7 +135,7 @@ void FLAC::Properties::read(const ByteVector &data, long streamLength) return; } - uint pos = 0; + unsigned int pos = 0; // Minimum block size (in samples) pos += 2; @@ -149,7 +149,7 @@ void FLAC::Properties::read(const ByteVector &data, long streamLength) // Maximum frame size (in bytes) pos += 3; - const uint flags = data.toUInt(pos, true); + const unsigned int flags = data.toUInt(pos, true); pos += 4; d->sampleRate = flags >> 12; diff --git a/taglib/it/itfile.cpp b/taglib/it/itfile.cpp index 7e140510..647491e9 100644 --- a/taglib/it/itfile.cpp +++ b/taglib/it/itfile.cpp @@ -130,7 +130,7 @@ bool IT::File::save() seek(sampleOffset + 20); - if((TagLib::uint)(i + instrumentCount) < lines.size()) + if((unsigned int)(i + instrumentCount) < lines.size()) writeString(lines[i + instrumentCount], 25); else writeString(String(), 25); @@ -139,7 +139,7 @@ bool IT::File::save() // write rest as message: StringList messageLines; - for(uint i = instrumentCount + sampleCount; i < lines.size(); ++ i) + for(unsigned int i = instrumentCount + sampleCount; i < lines.size(); ++ i) messageLines.append(lines[i]); ByteVector message = messageLines.toString("\r").data(String::Latin1); diff --git a/taglib/mod/modfile.cpp b/taglib/mod/modfile.cpp index 2741e1bf..d207516e 100644 --- a/taglib/mod/modfile.cpp +++ b/taglib/mod/modfile.cpp @@ -92,13 +92,13 @@ bool Mod::File::save() seek(0); writeString(d->tag.title(), 20); StringList lines = d->tag.comment().split("\n"); - uint n = std::min(lines.size(), d->properties.instrumentCount()); - for(uint i = 0; i < n; ++ i) { + unsigned int n = std::min(lines.size(), d->properties.instrumentCount()); + for(unsigned int i = 0; i < n; ++ i) { writeString(lines[i], 22); seek(8, Current); } - for(uint i = n; i < d->properties.instrumentCount(); ++ i) { + for(unsigned int i = n; i < d->properties.instrumentCount(); ++ i) { writeString(String(), 22); seek(8, Current); } @@ -114,8 +114,8 @@ void Mod::File::read(bool) ByteVector modId = readBlock(4); READ_ASSERT(modId.size() == 4); - int channels = 4; - uint instruments = 31; + int channels = 4; + unsigned int instruments = 31; if(modId == "M.K." || modId == "M!K!" || modId == "M&K!" || modId == "N.T.") { d->tag.setTrackerName("ProTracker"); channels = 4; @@ -159,7 +159,7 @@ void Mod::File::read(bool) READ_STRING(d->tag.setTitle, 20); StringList comment; - for(uint i = 0; i < instruments; ++ i) { + for(unsigned int i = 0; i < instruments; ++ i) { READ_STRING_AS(instrumentName, 22); // value in words, * 2 (<< 1) for bytes: READ_U16B_AS(sampleLength); diff --git a/taglib/mod/modproperties.cpp b/taglib/mod/modproperties.cpp index 86fa3845..f5591298 100644 --- a/taglib/mod/modproperties.cpp +++ b/taglib/mod/modproperties.cpp @@ -34,8 +34,8 @@ public: { } - int channels; - uint instrumentCount; + int channels; + unsigned int instrumentCount; unsigned char lengthInPatterns; }; @@ -80,7 +80,7 @@ int Mod::Properties::channels() const return d->channels; } -TagLib::uint Mod::Properties::instrumentCount() const +unsigned int Mod::Properties::instrumentCount() const { return d->instrumentCount; } @@ -95,7 +95,7 @@ void Mod::Properties::setChannels(int channels) d->channels = channels; } -void Mod::Properties::setInstrumentCount(uint instrumentCount) +void Mod::Properties::setInstrumentCount(unsigned int instrumentCount) { d->instrumentCount = instrumentCount; } diff --git a/taglib/mod/modproperties.h b/taglib/mod/modproperties.h index cf0f9e7b..6b424089 100644 --- a/taglib/mod/modproperties.h +++ b/taglib/mod/modproperties.h @@ -42,12 +42,12 @@ namespace TagLib { int sampleRate() const; int channels() const; - uint instrumentCount() const; + unsigned int instrumentCount() const; unsigned char lengthInPatterns() const; void setChannels(int channels); - void setInstrumentCount(uint sampleCount); + void setInstrumentCount(unsigned int sampleCount); void setLengthInPatterns(unsigned char lengthInPatterns); private: diff --git a/taglib/mod/modtag.cpp b/taglib/mod/modtag.cpp index af98fb92..2e3cbb6d 100644 --- a/taglib/mod/modtag.cpp +++ b/taglib/mod/modtag.cpp @@ -73,12 +73,12 @@ String Mod::Tag::genre() const return String(); } -TagLib::uint Mod::Tag::year() const +unsigned int Mod::Tag::year() const { return 0; } -TagLib::uint Mod::Tag::track() const +unsigned int Mod::Tag::track() const { return 0; } @@ -110,11 +110,11 @@ void Mod::Tag::setGenre(const String &) { } -void Mod::Tag::setYear(uint) +void Mod::Tag::setYear(unsigned int) { } -void Mod::Tag::setTrack(uint) +void Mod::Tag::setTrack(unsigned int) { } diff --git a/taglib/mod/modtag.h b/taglib/mod/modtag.h index 5b660359..1810fe11 100644 --- a/taglib/mod/modtag.h +++ b/taglib/mod/modtag.h @@ -77,12 +77,12 @@ namespace TagLib { /*! * Not supported by module files. Therefore always returns 0. */ - uint year() const; + unsigned int year() const; /*! * Not supported by module files. Therefore always returns 0. */ - uint track() const; + unsigned int track() const; /*! * Returns the name of the tracker used to create/edit the module file. @@ -140,12 +140,12 @@ namespace TagLib { /*! * Not supported by module files and therefore ignored. */ - void setYear(uint year); + void setYear(unsigned int year); /*! * Not supported by module files and therefore ignored. */ - void setTrack(uint track); + void setTrack(unsigned int track); /*! * Sets the tracker name to \a trackerName. If \a trackerName is diff --git a/taglib/mp4/mp4item.cpp b/taglib/mp4/mp4item.cpp index f7edbb55..787ed457 100644 --- a/taglib/mp4/mp4item.cpp +++ b/taglib/mp4/mp4item.cpp @@ -45,7 +45,7 @@ public: int m_int; IntPair m_intPair; unsigned char m_byte; - uint m_uint; + unsigned int m_uint; long long m_longlong; }; StringList m_stringList; @@ -104,7 +104,7 @@ MP4::Item::Item(unsigned char value) : d->m_byte = value; } -MP4::Item::Item(uint value) : +MP4::Item::Item(unsigned int value) : d(new ItemPrivate()) { d->m_uint = value; @@ -169,7 +169,7 @@ MP4::Item::toByte() const return d->m_byte; } -TagLib::uint +unsigned int MP4::Item::toUInt() const { return d->m_uint; diff --git a/taglib/mp4/mp4item.h b/taglib/mp4/mp4item.h index 63fc93bd..3821135b 100644 --- a/taglib/mp4/mp4item.h +++ b/taglib/mp4/mp4item.h @@ -58,7 +58,7 @@ namespace TagLib { Item(int value); Item(unsigned char value); - Item(uint value); + Item(unsigned int value); Item(long long value); Item(bool value); Item(int first, int second); @@ -71,7 +71,7 @@ namespace TagLib { int toInt() const; unsigned char toByte() const; - uint toUInt() const; + unsigned int toUInt() const; long long toLongLong() const; bool toBool() const; IntPair toIntPair() const; diff --git a/taglib/mp4/mp4properties.cpp b/taglib/mp4/mp4properties.cpp index ba821547..4bb4d67b 100644 --- a/taglib/mp4/mp4properties.cpp +++ b/taglib/mp4/mp4properties.cpp @@ -167,7 +167,7 @@ MP4::Properties::read(File *file, Atoms *atoms) file->seek(mdhd->offset); data = file->readBlock(mdhd->length); - const uint version = data[8]; + const unsigned int version = data[8]; long long unit; long long length; if(version == 1) { @@ -202,7 +202,7 @@ MP4::Properties::read(File *file, Atoms *atoms) d->bitsPerSample = data.toShort(42U); d->sampleRate = data.toUInt(46U); if(data.containsAt("esds", 56) && data[64] == 0x03) { - uint pos = 65; + unsigned int pos = 65; if(data.containsAt("\x80\x80\x80", pos)) { pos += 3; } diff --git a/taglib/mp4/mp4tag.cpp b/taglib/mp4/mp4tag.cpp index 6ad75a87..4b8a7039 100644 --- a/taglib/mp4/mp4tag.cpp +++ b/taglib/mp4/mp4tag.cpp @@ -554,7 +554,7 @@ MP4::Tag::updateOffsets(long delta, long offset) ByteVector data = d->file->readBlock(atom->length - 12); unsigned int count = data.toUInt(); d->file->seek(atom->offset + 16); - uint pos = 4; + unsigned int pos = 4; while(count--) { long o = static_cast(data.toUInt(pos)); if(o > offset) { @@ -575,7 +575,7 @@ MP4::Tag::updateOffsets(long delta, long offset) ByteVector data = d->file->readBlock(atom->length - 12); unsigned int count = data.toUInt(); d->file->seek(atom->offset + 16); - uint pos = 4; + unsigned int pos = 4; while(count--) { long long o = data.toLongLong(pos); if(o > offset) { @@ -768,13 +768,13 @@ MP4::Tag::setGenre(const String &value) } void -MP4::Tag::setYear(uint value) +MP4::Tag::setYear(unsigned int value) { d->items["\251day"] = StringList(String::number(value)); } void -MP4::Tag::setTrack(uint value) +MP4::Tag::setTrack(unsigned int value) { d->items["trkn"] = MP4::Item(value, 0); } diff --git a/taglib/mp4/mp4tag.h b/taglib/mp4/mp4tag.h index c299c59b..7a73b3fe 100644 --- a/taglib/mp4/mp4tag.h +++ b/taglib/mp4/mp4tag.h @@ -58,16 +58,16 @@ namespace TagLib { String album() const; String comment() const; String genre() const; - uint year() const; - uint track() const; + unsigned int year() const; + unsigned int track() const; void setTitle(const String &value); void setArtist(const String &value); void setAlbum(const String &value); void setComment(const String &value); void setGenre(const String &value); - void setYear(uint value); - void setTrack(uint value); + void setYear(unsigned int value); + void setTrack(unsigned int value); virtual bool isEmpty() const; diff --git a/taglib/mpc/mpcfile.cpp b/taglib/mpc/mpcfile.cpp index 015bc0e0..6d6e668a 100644 --- a/taglib/mpc/mpcfile.cpp +++ b/taglib/mpc/mpcfile.cpp @@ -65,13 +65,13 @@ public: } long APELocation; - uint APESize; + unsigned int APESize; long ID3v1Location; ID3v2::Header *ID3v2Header; long ID3v2Location; - uint ID3v2Size; + unsigned int ID3v2Size; TagUnion tag; diff --git a/taglib/mpc/mpcproperties.cpp b/taglib/mpc/mpcproperties.cpp index 2e42886e..b9fbbf13 100644 --- a/taglib/mpc/mpcproperties.cpp +++ b/taglib/mpc/mpcproperties.cpp @@ -49,18 +49,18 @@ public: albumGain(0), albumPeak(0) {} - int version; - int length; - int bitrate; - int sampleRate; - int channels; - uint totalFrames; - uint sampleFrames; - uint trackGain; - uint trackPeak; - uint albumGain; - uint albumPeak; - String flags; + int version; + int length; + int bitrate; + int sampleRate; + int channels; + unsigned int totalFrames; + unsigned int sampleFrames; + unsigned int trackGain; + unsigned int trackPeak; + unsigned int albumGain; + unsigned int albumPeak; + String flags; }; //////////////////////////////////////////////////////////////////////////////// @@ -129,12 +129,12 @@ int MPC::Properties::mpcVersion() const return d->version; } -TagLib::uint MPC::Properties::totalFrames() const +unsigned int MPC::Properties::totalFrames() const { return d->totalFrames; } -TagLib::uint MPC::Properties::sampleFrames() const +unsigned int MPC::Properties::sampleFrames() const { return d->sampleFrames; } @@ -165,7 +165,7 @@ int MPC::Properties::albumPeak() const namespace { - unsigned long readSize(File *file, TagLib::uint &sizeLength, bool &eof) + unsigned long readSize(File *file, unsigned int &sizeLength, bool &eof) { sizeLength = 0; eof = false; @@ -187,7 +187,7 @@ namespace return size; } - unsigned long readSize(const ByteVector &data, TagLib::uint &pos) + unsigned long readSize(const ByteVector &data, unsigned int &pos) { unsigned char tmp; unsigned long size = 0; @@ -211,7 +211,7 @@ void MPC::Properties::readSV8(File *file, long streamLength) while(!readSH && !readRG) { const ByteVector packetType = file->readBlock(2); - uint packetSizeLength; + unsigned int packetSizeLength; bool eof; const unsigned long packetSize = readSize(file, packetSizeLength, eof); if(eof) { @@ -238,7 +238,7 @@ void MPC::Properties::readSV8(File *file, long streamLength) readSH = true; - TagLib::uint pos = 4; + unsigned int pos = 4; d->version = data[pos]; pos += 1; d->sampleFrames = readSize(data, pos); @@ -259,7 +259,7 @@ void MPC::Properties::readSV8(File *file, long streamLength) d->sampleRate = sftable[(flags >> 13) & 0x07]; d->channels = ((flags >> 4) & 0x0F) + 1; - const uint frameCount = d->sampleFrames - begSilence; + const unsigned int frameCount = d->sampleFrames - begSilence; if(frameCount > 0 && d->sampleRate > 0) { const double length = frameCount * 1000.0 / d->sampleRate; d->length = static_cast(length + 0.5); @@ -305,11 +305,11 @@ void MPC::Properties::readSV7(const ByteVector &data, long streamLength) d->totalFrames = data.toUInt(4, false); - const uint flags = data.toUInt(8, false); + const unsigned int flags = data.toUInt(8, false); d->sampleRate = sftable[(flags >> 16) & 0x03]; d->channels = 2; - const uint gapless = data.toUInt(5, false); + const unsigned int gapless = data.toUInt(5, false); d->trackGain = data.toShort(14, false); d->trackPeak = data.toShort(12, false); @@ -337,14 +337,14 @@ void MPC::Properties::readSV7(const ByteVector &data, long streamLength) bool trueGapless = (gapless >> 31) & 0x0001; if(trueGapless) { - uint lastFrameSamples = (gapless >> 20) & 0x07FF; + unsigned int lastFrameSamples = (gapless >> 20) & 0x07FF; d->sampleFrames = d->totalFrames * 1152 - lastFrameSamples; } else d->sampleFrames = d->totalFrames * 1152 - 576; } else { - const uint headerData = data.toUInt(0, false); + const unsigned int headerData = data.toUInt(0, false); d->bitrate = (headerData >> 23) & 0x01ff; d->version = (headerData >> 11) & 0x03ff; diff --git a/taglib/mpc/mpcproperties.h b/taglib/mpc/mpcproperties.h index d6b06691..d5fdfbb9 100644 --- a/taglib/mpc/mpcproperties.h +++ b/taglib/mpc/mpcproperties.h @@ -35,7 +35,7 @@ namespace TagLib { class File; - static const uint HeaderSize = 8*7; + static const unsigned int HeaderSize = 8 * 7; //! An implementation of audio property reading for MPC @@ -113,8 +113,8 @@ namespace TagLib { */ int mpcVersion() const; - uint totalFrames() const; - uint sampleFrames() const; + unsigned int totalFrames() const; + unsigned int sampleFrames() const; /*! * Returns the track gain as an integer value, diff --git a/taglib/mpeg/id3v1/id3v1tag.cpp b/taglib/mpeg/id3v1/id3v1tag.cpp index 1ca297e2..9b724159 100644 --- a/taglib/mpeg/id3v1/id3v1tag.cpp +++ b/taglib/mpeg/id3v1/id3v1tag.cpp @@ -144,12 +144,12 @@ String ID3v1::Tag::genre() const return ID3v1::genre(d->genre); } -TagLib::uint ID3v1::Tag::year() const +unsigned int ID3v1::Tag::year() const { return d->year.toInt(); } -TagLib::uint ID3v1::Tag::track() const +unsigned int ID3v1::Tag::track() const { return d->track; } @@ -179,22 +179,22 @@ void ID3v1::Tag::setGenre(const String &s) d->genre = ID3v1::genreIndex(s); } -void ID3v1::Tag::setYear(TagLib::uint i) +void ID3v1::Tag::setYear(unsigned int i) { d->year = i > 0 ? String::number(i) : String(); } -void ID3v1::Tag::setTrack(TagLib::uint i) +void ID3v1::Tag::setTrack(unsigned int i) { d->track = i < 256 ? i : 0; } -TagLib::uint ID3v1::Tag::genreNumber() const +unsigned int ID3v1::Tag::genreNumber() const { return d->genre; } -void ID3v1::Tag::setGenreNumber(TagLib::uint i) +void ID3v1::Tag::setGenreNumber(unsigned int i) { d->genre = i < 256 ? i : 255; } diff --git a/taglib/mpeg/id3v1/id3v1tag.h b/taglib/mpeg/id3v1/id3v1tag.h index 02642ca5..9cff408f 100644 --- a/taglib/mpeg/id3v1/id3v1tag.h +++ b/taglib/mpeg/id3v1/id3v1tag.h @@ -140,23 +140,23 @@ namespace TagLib { virtual String album() const; virtual String comment() const; virtual String genre() const; - virtual TagLib::uint year() const; - virtual TagLib::uint track() const; + virtual unsigned int year() const; + virtual unsigned int 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(TagLib::uint i); - virtual void setTrack(TagLib::uint i); + virtual void setYear(unsigned int i); + virtual void setTrack(unsigned int i); /*! * Returns the genre in number. * * \note Normally 255 indicates that this tag contains no genre. */ - TagLib::uint genreNumber() const; + unsigned int genreNumber() const; /*! * Sets the genre in number to \a i. @@ -164,7 +164,7 @@ namespace TagLib { * \note Valid value is from 0 up to 255. Normally 255 indicates that * this tag contains no genre. */ - void setGenreNumber(TagLib::uint i); + void setGenreNumber(unsigned int i); /*! * Sets the string handler that decides how the ID3v1 data will be diff --git a/taglib/mpeg/id3v2/frames/attachedpictureframe.cpp b/taglib/mpeg/id3v2/frames/attachedpictureframe.cpp index 86f8e355..849ee9ff 100644 --- a/taglib/mpeg/id3v2/frames/attachedpictureframe.cpp +++ b/taglib/mpeg/id3v2/frames/attachedpictureframe.cpp @@ -137,7 +137,7 @@ void AttachedPictureFrame::parseFields(const ByteVector &data) d->mimeType = readStringField(data, String::Latin1, &pos); /* Now we need at least two more bytes available */ - if (uint(pos) + 1 >= data.size()) { + if(static_cast(pos) + 1 >= data.size()) { debug("Truncated picture frame."); return; } diff --git a/taglib/mpeg/id3v2/frames/chapterframe.cpp b/taglib/mpeg/id3v2/frames/chapterframe.cpp index e11e2928..44cdf5e7 100644 --- a/taglib/mpeg/id3v2/frames/chapterframe.cpp +++ b/taglib/mpeg/id3v2/frames/chapterframe.cpp @@ -44,10 +44,10 @@ public: const ID3v2::Header *tagHeader; ByteVector elementID; - TagLib::uint startTime; - TagLib::uint endTime; - TagLib::uint startOffset; - TagLib::uint endOffset; + unsigned int startTime; + unsigned int endTime; + unsigned int startOffset; + unsigned int endOffset; FrameListMap embeddedFrameListMap; FrameList embeddedFrameList; }; @@ -65,8 +65,8 @@ ChapterFrame::ChapterFrame(const ID3v2::Header *tagHeader, const ByteVector &dat } ChapterFrame::ChapterFrame(const ByteVector &elementID, - TagLib::uint startTime, TagLib::uint endTime, - TagLib::uint startOffset, TagLib::uint endOffset, + unsigned int startTime, unsigned int endTime, + unsigned int startOffset, unsigned int endOffset, const FrameList &embeddedFrames) : ID3v2::Frame("CHAP") { @@ -97,22 +97,22 @@ ByteVector ChapterFrame::elementID() const return d->elementID; } -TagLib::uint ChapterFrame::startTime() const +unsigned int ChapterFrame::startTime() const { return d->startTime; } -TagLib::uint ChapterFrame::endTime() const +unsigned int ChapterFrame::endTime() const { return d->endTime; } -TagLib::uint ChapterFrame::startOffset() const +unsigned int ChapterFrame::startOffset() const { return d->startOffset; } -TagLib::uint ChapterFrame::endOffset() const +unsigned int ChapterFrame::endOffset() const { return d->endOffset; } @@ -125,22 +125,22 @@ void ChapterFrame::setElementID(const ByteVector &eID) d->elementID = d->elementID.mid(0, d->elementID.size() - 1); } -void ChapterFrame::setStartTime(const TagLib::uint &sT) +void ChapterFrame::setStartTime(const unsigned int &sT) { d->startTime = sT; } -void ChapterFrame::setEndTime(const TagLib::uint &eT) +void ChapterFrame::setEndTime(const unsigned int &eT) { d->endTime = eT; } -void ChapterFrame::setStartOffset(const TagLib::uint &sO) +void ChapterFrame::setStartOffset(const unsigned int &sO) { d->startOffset = sO; } -void ChapterFrame::setEndOffset(const TagLib::uint &eO) +void ChapterFrame::setEndOffset(const unsigned int &eO) { d->endOffset = eO; } @@ -238,7 +238,7 @@ ChapterFrame *ChapterFrame::findByElementID(const ID3v2::Tag *tag, const ByteVec void ChapterFrame::parseFields(const ByteVector &data) { - TagLib::uint size = data.size(); + unsigned int size = data.size(); if(size < 18) { debug("A CHAP frame must contain at least 18 bytes (1 byte element ID " "terminated by null and 4x4 bytes for start and end time and offset)."); @@ -246,7 +246,7 @@ void ChapterFrame::parseFields(const ByteVector &data) } int pos = 0; - TagLib::uint embPos = 0; + unsigned int embPos = 0; d->elementID = readStringField(data, String::Latin1, &pos).data(String::Latin1); d->startTime = data.toUInt(pos, true); pos += 4; diff --git a/taglib/mpeg/id3v2/frames/chapterframe.h b/taglib/mpeg/id3v2/frames/chapterframe.h index 36853062..64ee19d3 100644 --- a/taglib/mpeg/id3v2/frames/chapterframe.h +++ b/taglib/mpeg/id3v2/frames/chapterframe.h @@ -62,8 +62,8 @@ namespace TagLib { * All times are in milliseconds. */ ChapterFrame(const ByteVector &elementID, - uint startTime, uint endTime, - uint startOffset, uint endOffset, + unsigned int startTime, unsigned int endTime, + unsigned int startOffset, unsigned int endOffset, const FrameList &embeddedFrames = FrameList()); /*! @@ -84,14 +84,14 @@ namespace TagLib { * * \see setStartTime() */ - uint startTime() const; + unsigned int startTime() const; /*! * Returns time of chapter's end (in milliseconds). * * \see setEndTime() */ - uint endTime() const; + unsigned int endTime() const; /*! * Returns zero based byte offset (count of bytes from the beginning @@ -100,7 +100,7 @@ namespace TagLib { * \note If returned value is 0xFFFFFFFF, start time should be used instead. * \see setStartOffset() */ - uint startOffset() const; + unsigned int startOffset() const; /*! * Returns zero based byte offset (count of bytes from the beginning @@ -109,7 +109,7 @@ namespace TagLib { * \note If returned value is 0xFFFFFFFF, end time should be used instead. * \see setEndOffset() */ - uint endOffset() const; + unsigned int endOffset() const; /*! * Sets the element ID of the frame to \a eID. If \a eID isn't @@ -124,14 +124,14 @@ namespace TagLib { * * \see startTime() */ - void setStartTime(const uint &sT); + void setStartTime(const unsigned int &sT); /*! * Sets time of chapter's end (in milliseconds) to \a eT. * * \see endTime() */ - void setEndTime(const uint &eT); + void setEndTime(const unsigned int &eT); /*! * Sets zero based byte offset (count of bytes from the beginning @@ -139,7 +139,7 @@ namespace TagLib { * * \see startOffset() */ - void setStartOffset(const uint &sO); + void setStartOffset(const unsigned int &sO); /*! * Sets zero based byte offset (count of bytes from the beginning @@ -147,7 +147,7 @@ namespace TagLib { * * \see endOffset() */ - void setEndOffset(const uint &eO); + void setEndOffset(const unsigned int &eO); /*! * Returns a reference to the frame list map. This is an FrameListMap of diff --git a/taglib/mpeg/id3v2/frames/eventtimingcodesframe.cpp b/taglib/mpeg/id3v2/frames/eventtimingcodesframe.cpp index 6a3f7d26..7af797f0 100644 --- a/taglib/mpeg/id3v2/frames/eventtimingcodesframe.cpp +++ b/taglib/mpeg/id3v2/frames/eventtimingcodesframe.cpp @@ -110,7 +110,7 @@ void EventTimingCodesFrame::parseFields(const ByteVector &data) d->synchedEvents.clear(); while(pos + 4 < end) { EventType type = static_cast(static_cast(data[pos++])); - uint time = data.toUInt(pos, true); + unsigned int time = data.toUInt(pos, true); pos += 4; d->synchedEvents.append(SynchedEvent(time, type)); } diff --git a/taglib/mpeg/id3v2/frames/eventtimingcodesframe.h b/taglib/mpeg/id3v2/frames/eventtimingcodesframe.h index 0719f51f..3dcedb9e 100644 --- a/taglib/mpeg/id3v2/frames/eventtimingcodesframe.h +++ b/taglib/mpeg/id3v2/frames/eventtimingcodesframe.h @@ -108,8 +108,8 @@ namespace TagLib { * Single entry of time stamp and event. */ struct SynchedEvent { - SynchedEvent(uint ms, EventType t) : time(ms), type(t) {} - uint time; + SynchedEvent(unsigned int ms, EventType t) : time(ms), type(t) {} + unsigned int time; EventType type; }; diff --git a/taglib/mpeg/id3v2/frames/popularimeterframe.cpp b/taglib/mpeg/id3v2/frames/popularimeterframe.cpp index 3d4429f7..dac8589f 100644 --- a/taglib/mpeg/id3v2/frames/popularimeterframe.cpp +++ b/taglib/mpeg/id3v2/frames/popularimeterframe.cpp @@ -36,7 +36,7 @@ public: PopularimeterFramePrivate() : rating(0), counter(0) {} String email; int rating; - TagLib::uint counter; + unsigned int counter; }; //////////////////////////////////////////////////////////////////////////////// @@ -84,12 +84,12 @@ void PopularimeterFrame::setRating(int s) d->rating = s; } -TagLib::uint PopularimeterFrame::counter() const +unsigned int PopularimeterFrame::counter() const { return d->counter; } -void PopularimeterFrame::setCounter(TagLib::uint s) +void PopularimeterFrame::setCounter(unsigned int s) { d->counter = s; } @@ -109,7 +109,7 @@ void PopularimeterFrame::parseFields(const ByteVector &data) if(pos < size) { d->rating = (unsigned char)(data[pos++]); if(pos < size) { - d->counter = data.toUInt(static_cast(pos)); + d->counter = data.toUInt(static_cast(pos)); } } } diff --git a/taglib/mpeg/id3v2/frames/popularimeterframe.h b/taglib/mpeg/id3v2/frames/popularimeterframe.h index 79b88cbf..405ca69e 100644 --- a/taglib/mpeg/id3v2/frames/popularimeterframe.h +++ b/taglib/mpeg/id3v2/frames/popularimeterframe.h @@ -100,14 +100,14 @@ namespace TagLib { * * \see setCounter() */ - uint counter() const; + unsigned int counter() const; /*! * Set the counter. * * \see counter() */ - void setCounter(uint counter); + void setCounter(unsigned int counter); protected: // Reimplementations. diff --git a/taglib/mpeg/id3v2/frames/relativevolumeframe.cpp b/taglib/mpeg/id3v2/frames/relativevolumeframe.cpp index e3efbc38..44033cbc 100644 --- a/taglib/mpeg/id3v2/frames/relativevolumeframe.cpp +++ b/taglib/mpeg/id3v2/frames/relativevolumeframe.cpp @@ -191,7 +191,7 @@ void RelativeVolumeFrame::parseFields(const ByteVector &data) ChannelData &channel = d->channels[type]; - channel.volumeAdjustment = data.toShort(static_cast(pos)); + channel.volumeAdjustment = data.toShort(static_cast(pos)); pos += 2; channel.peakVolume.bitsRepresentingPeak = data[pos]; diff --git a/taglib/mpeg/id3v2/frames/synchronizedlyricsframe.cpp b/taglib/mpeg/id3v2/frames/synchronizedlyricsframe.cpp index 1d42e1c8..4fb2e15a 100644 --- a/taglib/mpeg/id3v2/frames/synchronizedlyricsframe.cpp +++ b/taglib/mpeg/id3v2/frames/synchronizedlyricsframe.cpp @@ -117,8 +117,7 @@ void SynchronizedLyricsFrame::setLanguage(const ByteVector &languageEncoding) d->language = languageEncoding.mid(0, 3); } -void SynchronizedLyricsFrame::setTimestampFormat( - SynchronizedLyricsFrame::TimestampFormat f) +void SynchronizedLyricsFrame::setTimestampFormat(SynchronizedLyricsFrame::TimestampFormat f) { d->timestampFormat = f; } @@ -193,7 +192,7 @@ void SynchronizedLyricsFrame::parseFields(const ByteVector &data) if(text.isEmpty() || pos + 4 > end) return; - uint time = data.toUInt(pos, true); + unsigned int time = data.toUInt(pos, true); pos += 4; d->synchedText.append(SynchedText(time, text)); diff --git a/taglib/mpeg/id3v2/frames/synchronizedlyricsframe.h b/taglib/mpeg/id3v2/frames/synchronizedlyricsframe.h index 704ac4b5..f520c593 100644 --- a/taglib/mpeg/id3v2/frames/synchronizedlyricsframe.h +++ b/taglib/mpeg/id3v2/frames/synchronizedlyricsframe.h @@ -85,8 +85,8 @@ namespace TagLib { * Single entry of time stamp and lyrics text. */ struct SynchedText { - SynchedText(uint ms, String str) : time(ms), text(str) {} - uint time; + SynchedText(unsigned int ms, String str) : time(ms), text(str) {} + unsigned int time; String text; }; diff --git a/taglib/mpeg/id3v2/frames/tableofcontentsframe.cpp b/taglib/mpeg/id3v2/frames/tableofcontentsframe.cpp index 1e8a1af8..50720359 100644 --- a/taglib/mpeg/id3v2/frames/tableofcontentsframe.cpp +++ b/taglib/mpeg/id3v2/frames/tableofcontentsframe.cpp @@ -121,7 +121,7 @@ bool TableOfContentsFrame::isOrdered() const return d->isOrdered; } -TagLib::uint TableOfContentsFrame::entryCount() const +unsigned int TableOfContentsFrame::entryCount() const { return d->childElements.size(); } @@ -261,7 +261,7 @@ TableOfContentsFrame *TableOfContentsFrame::findTopLevel(const ID3v2::Tag *tag) void TableOfContentsFrame::parseFields(const ByteVector &data) { - TagLib::uint size = data.size(); + unsigned int size = data.size(); if(size < 6) { debug("A CTOC frame must contain at least 6 bytes (1 byte element ID terminated by " "null, 1 byte flags, 1 byte entry count and 1 byte child element ID terminated " @@ -270,12 +270,12 @@ void TableOfContentsFrame::parseFields(const ByteVector &data) } int pos = 0; - TagLib::uint embPos = 0; + unsigned int embPos = 0; d->elementID = readStringField(data, String::Latin1, &pos).data(String::Latin1); d->isTopLevel = (data.at(pos) & 2) > 0; d->isOrdered = (data.at(pos++) & 1) > 0; - TagLib::uint entryCount = data.at(pos++); - for(TagLib::uint i = 0; i < entryCount; i++) { + unsigned int entryCount = data.at(pos++); + for(unsigned int i = 0; i < entryCount; i++) { ByteVector childElementID = readStringField(data, String::Latin1, &pos).data(String::Latin1); d->childElements.append(childElementID); } diff --git a/taglib/mpeg/id3v2/frames/tableofcontentsframe.h b/taglib/mpeg/id3v2/frames/tableofcontentsframe.h index 66facf80..31196b2e 100644 --- a/taglib/mpeg/id3v2/frames/tableofcontentsframe.h +++ b/taglib/mpeg/id3v2/frames/tableofcontentsframe.h @@ -95,7 +95,7 @@ namespace TagLib { * * \see childElements() */ - uint entryCount() const; + unsigned int entryCount() const; /*! * Returns list of child elements of the frame. diff --git a/taglib/mpeg/id3v2/frames/textidentificationframe.cpp b/taglib/mpeg/id3v2/frames/textidentificationframe.cpp index 8cd0d940..d9d3b29b 100644 --- a/taglib/mpeg/id3v2/frames/textidentificationframe.cpp +++ b/taglib/mpeg/id3v2/frames/textidentificationframe.cpp @@ -119,22 +119,26 @@ void TextIdentificationFrame::setTextEncoding(String::Type encoding) d->textEncoding = encoding; } -// array of allowed TIPL prefixes and their corresponding key value -static const TagLib::uint involvedPeopleSize = 5; -static const char* involvedPeople[][2] = { - {"ARRANGER", "ARRANGER"}, - {"ENGINEER", "ENGINEER"}, - {"PRODUCER", "PRODUCER"}, - {"DJ-MIX", "DJMIXER"}, - {"MIX", "MIXER"}, -}; +namespace +{ + // array of allowed TIPL prefixes and their corresponding key value + const char* involvedPeople[][2] = { + {"ARRANGER", "ARRANGER"}, + {"ENGINEER", "ENGINEER"}, + {"PRODUCER", "PRODUCER"}, + {"DJ-MIX", "DJMIXER"}, + {"MIX", "MIXER"}, + }; + const size_t involvedPeopleSize = sizeof(involvedPeople) / sizeof(involvedPeople[0]); +} const KeyConversionMap &TextIdentificationFrame::involvedPeopleMap() // static { static KeyConversionMap m; - if(m.isEmpty()) - for(uint i = 0; i < involvedPeopleSize; ++i) + if(m.isEmpty()) { + for(size_t i = 0; i < involvedPeopleSize; ++i) m.insert(involvedPeople[i][1], involvedPeople[i][0]); + } return m; } @@ -265,7 +269,7 @@ PropertyMap TextIdentificationFrame::makeTIPLProperties() const StringList l = fieldList(); for(StringList::ConstIterator it = l.begin(); it != l.end(); ++it) { bool found = false; - for(uint i = 0; i < involvedPeopleSize; ++i) + for(size_t i = 0; i < involvedPeopleSize; ++i) if(*it == involvedPeople[i][0]) { map.insert(involvedPeople[i][1], (++it)->split(",")); found = true; diff --git a/taglib/mpeg/id3v2/id3v2extendedheader.cpp b/taglib/mpeg/id3v2/id3v2extendedheader.cpp index ddcfd452..667e3e94 100644 --- a/taglib/mpeg/id3v2/id3v2extendedheader.cpp +++ b/taglib/mpeg/id3v2/id3v2extendedheader.cpp @@ -34,7 +34,7 @@ class ExtendedHeader::ExtendedHeaderPrivate public: ExtendedHeaderPrivate() : size(0) {} - uint size; + unsigned int size; }; //////////////////////////////////////////////////////////////////////////////// @@ -51,7 +51,7 @@ ExtendedHeader::~ExtendedHeader() delete d; } -TagLib::uint ExtendedHeader::size() const +unsigned int ExtendedHeader::size() const { return d->size; } diff --git a/taglib/mpeg/id3v2/id3v2extendedheader.h b/taglib/mpeg/id3v2/id3v2extendedheader.h index d60200e7..6d9386e6 100644 --- a/taglib/mpeg/id3v2/id3v2extendedheader.h +++ b/taglib/mpeg/id3v2/id3v2extendedheader.h @@ -62,7 +62,7 @@ namespace TagLib { * Returns the size of the extended header. This is variable for the * extended header. */ - uint size() const; + unsigned int size() const; /*! * Sets the data that will be used as the extended header. Since the diff --git a/taglib/mpeg/id3v2/id3v2footer.cpp b/taglib/mpeg/id3v2/id3v2footer.cpp index abbe054b..3622724a 100644 --- a/taglib/mpeg/id3v2/id3v2footer.cpp +++ b/taglib/mpeg/id3v2/id3v2footer.cpp @@ -42,7 +42,7 @@ Footer::~Footer() { } -TagLib::uint Footer::size() +unsigned int Footer::size() { return 10; } diff --git a/taglib/mpeg/id3v2/id3v2footer.h b/taglib/mpeg/id3v2/id3v2footer.h index 1374a149..5eb38007 100644 --- a/taglib/mpeg/id3v2/id3v2footer.h +++ b/taglib/mpeg/id3v2/id3v2footer.h @@ -62,7 +62,7 @@ namespace TagLib { /*! * Returns the size of the footer. Presently this is always 10 bytes. */ - static uint size(); + static unsigned int size(); /*! * Renders the footer based on the data in \a header. diff --git a/taglib/mpeg/id3v2/id3v2frame.cpp b/taglib/mpeg/id3v2/id3v2frame.cpp index f811ed69..8960ffe2 100644 --- a/taglib/mpeg/id3v2/id3v2frame.cpp +++ b/taglib/mpeg/id3v2/id3v2frame.cpp @@ -85,12 +85,12 @@ namespace // static methods //////////////////////////////////////////////////////////////////////////////// -TagLib::uint Frame::headerSize() +unsigned int Frame::headerSize() { return Header::size(); } -TagLib::uint Frame::headerSize(uint version) +unsigned int Frame::headerSize(unsigned int version) { return Header::size(version); } @@ -173,7 +173,7 @@ ByteVector Frame::frameID() const return ByteVector(); } -TagLib::uint Frame::size() const +unsigned int Frame::size() const { if(d->header) return d->header->frameSize(); @@ -241,10 +241,10 @@ void Frame::parse(const ByteVector &data) ByteVector Frame::fieldData(const ByteVector &frameData) const { - uint headerSize = Header::size(d->header->version()); + unsigned int headerSize = Header::size(d->header->version()); - uint frameDataOffset = headerSize; - uint frameDataLength = size(); + unsigned int frameDataOffset = headerSize; + unsigned int frameDataLength = size(); if(d->header->compression() || d->header->dataLengthIndicator()) { frameDataLength = SynchData::toUInt(frameData.mid(headerSize, 4)); @@ -268,7 +268,7 @@ ByteVector Frame::fieldData(const ByteVector &frameData) const stream.avail_in = (uLongf) frameData.size() - frameDataOffset; stream.next_in = (Bytef *) frameData.data() + frameDataOffset; - static const uint chunkSize = 1024; + static const unsigned int chunkSize = 1024; ByteVector data; ByteVector chunk(chunkSize); @@ -335,7 +335,7 @@ String::Type Frame::checkEncoding(const StringList &fields, String::Type encodin return checkEncoding(fields, encoding, 4); } -String::Type Frame::checkEncoding(const StringList &fields, String::Type encoding, uint version) // static +String::Type Frame::checkEncoding(const StringList &fields, String::Type encoding, unsigned int version) // static { if((encoding == String::UTF8 || encoding == String::UTF16BE) && version != 4) return String::UTF16; @@ -572,8 +572,8 @@ public: {} ByteVector frameID; - uint frameSize; - uint version; + unsigned int frameSize; + unsigned int version; // flags @@ -591,12 +591,12 @@ public: // static members (Frame::Header) //////////////////////////////////////////////////////////////////////////////// -TagLib::uint Frame::Header::size() +unsigned int Frame::Header::size() { return size(4); } -TagLib::uint Frame::Header::size(uint version) +unsigned int Frame::Header::size(unsigned int version) { switch(version) { case 0: @@ -620,7 +620,7 @@ Frame::Header::Header(const ByteVector &data, bool synchSafeInts) setData(data, synchSafeInts); } -Frame::Header::Header(const ByteVector &data, uint version) +Frame::Header::Header(const ByteVector &data, unsigned int version) { d = new HeaderPrivate; setData(data, version); @@ -633,10 +633,10 @@ Frame::Header::~Header() void Frame::Header::setData(const ByteVector &data, bool synchSafeInts) { - setData(data, uint(synchSafeInts ? 4 : 3)); + setData(data, static_cast(synchSafeInts ? 4 : 3)); } -void Frame::Header::setData(const ByteVector &data, uint version) +void Frame::Header::setData(const ByteVector &data, unsigned int version) { d->version = version; @@ -777,22 +777,22 @@ void Frame::Header::setFrameID(const ByteVector &id) d->frameID = id.mid(0, 4); } -TagLib::uint Frame::Header::frameSize() const +unsigned int Frame::Header::frameSize() const { return d->frameSize; } -void Frame::Header::setFrameSize(uint size) +void Frame::Header::setFrameSize(unsigned int size) { d->frameSize = size; } -TagLib::uint Frame::Header::version() const +unsigned int Frame::Header::version() const { return d->version; } -void Frame::Header::setVersion(TagLib::uint version) +void Frame::Header::setVersion(unsigned int version) { d->version = version; } diff --git a/taglib/mpeg/id3v2/id3v2frame.h b/taglib/mpeg/id3v2/id3v2frame.h index ae1e2473..a179cd42 100644 --- a/taglib/mpeg/id3v2/id3v2frame.h +++ b/taglib/mpeg/id3v2/id3v2frame.h @@ -79,7 +79,7 @@ namespace TagLib { /*! * Returns the size of the frame. */ - uint size() const; + unsigned int size() const; /*! * Returns the size of the frame header @@ -89,14 +89,14 @@ namespace TagLib { * non-binary compatible release this will be made into a non-static * member that checks the internal ID3v2 version. */ - static uint headerSize(); // BIC: remove and make non-static + static unsigned int headerSize(); // BIC: remove and make non-static /*! * Returns the size of the frame header for the given ID3v2 version. * * \deprecated Please see the explanation above. */ - static uint headerSize(uint version); // BIC: remove and make non-static + static unsigned int headerSize(unsigned int version); // BIC: remove and make non-static /*! * Sets the data that will be used as the frame. Since the length is not @@ -242,7 +242,7 @@ namespace TagLib { */ // BIC: remove and make non-static static String::Type checkEncoding(const StringList &fields, - String::Type encoding, uint version); + String::Type encoding, unsigned int version); /*! * Checks a the list of string values to see if they can be used with the @@ -343,7 +343,7 @@ namespace TagLib { * * \a version should be the ID3v2 version of the tag. */ - explicit Header(const ByteVector &data, uint version = 4); + explicit Header(const ByteVector &data, unsigned int version = 4); /*! * Destroys this Header instance. @@ -362,7 +362,7 @@ namespace TagLib { * Sets the data for the Header. \a version should indicate the ID3v2 * version number of the tag that this frame is contained in. */ - void setData(const ByteVector &data, uint version = 4); + void setData(const ByteVector &data, unsigned int version = 4); /*! * Returns the Frame ID (Structure, 4) @@ -384,24 +384,24 @@ namespace TagLib { * Returns the size of the frame data portion, as set when setData() was * called or set explicitly via setFrameSize(). */ - uint frameSize() const; + unsigned int frameSize() const; /*! * Sets the size of the frame data portion. */ - void setFrameSize(uint size); + void setFrameSize(unsigned int size); /*! * Returns the ID3v2 version of the header, as passed in from the * construction of the header or set via setVersion(). */ - uint version() const; + unsigned int version() const; /*! * Sets the ID3v2 version of the header, changing has impact on the * correct parsing/rendering of frame data. */ - void setVersion(uint version); + void setVersion(unsigned int version); /*! * Returns the size of the frame header in bytes. @@ -411,7 +411,7 @@ namespace TagLib { * removed in the next binary incompatible release (2.0) and will be * replaced with a non-static method that checks the frame version. */ - static uint size(); + static unsigned int size(); /*! * Returns the size of the frame header in bytes for the ID3v2 version @@ -419,7 +419,7 @@ namespace TagLib { * * \deprecated Please see the explanation in the version above. */ - static uint size(uint version); + static unsigned int size(unsigned int version); /*! * Returns true if the flag for tag alter preservation is set. diff --git a/taglib/mpeg/id3v2/id3v2framefactory.cpp b/taglib/mpeg/id3v2/id3v2framefactory.cpp index a462e21b..cfa6be23 100644 --- a/taglib/mpeg/id3v2/id3v2framefactory.cpp +++ b/taglib/mpeg/id3v2/id3v2framefactory.cpp @@ -117,10 +117,10 @@ FrameFactory *FrameFactory::instance() Frame *FrameFactory::createFrame(const ByteVector &data, bool synchSafeInts) const { - return createFrame(data, uint(synchSafeInts ? 4 : 3)); + return createFrame(data, static_cast(synchSafeInts ? 4 : 3)); } -Frame *FrameFactory::createFrame(const ByteVector &data, uint version) const +Frame *FrameFactory::createFrame(const ByteVector &data, unsigned int version) const { Header tagHeader; tagHeader.setMajorVersion(version); @@ -130,7 +130,7 @@ Frame *FrameFactory::createFrame(const ByteVector &data, uint version) const Frame *FrameFactory::createFrame(const ByteVector &origData, Header *tagHeader) const { ByteVector data = origData; - uint version = tagHeader->majorVersion(); + unsigned int version = tagHeader->majorVersion(); Frame::Header *header = new Frame::Header(data, version); ByteVector frameID = header->frameID(); @@ -138,7 +138,7 @@ Frame *FrameFactory::createFrame(const ByteVector &origData, Header *tagHeader) // characters. Also make sure that there is data in the frame. if(frameID.size() != (version < 3 ? 3 : 4) || - header->frameSize() <= uint(header->dataLengthIndicator() ? 4 : 0) || + header->frameSize() <= static_cast(header->dataLengthIndicator() ? 4 : 0) || header->frameSize() > data.size()) { delete header; diff --git a/taglib/mpeg/id3v2/id3v2framefactory.h b/taglib/mpeg/id3v2/id3v2framefactory.h index c7da8694..fe81c71f 100644 --- a/taglib/mpeg/id3v2/id3v2framefactory.h +++ b/taglib/mpeg/id3v2/id3v2framefactory.h @@ -85,7 +85,7 @@ namespace TagLib { * \deprecated Please use the method below that accepts a ID3v2::Header * instance in new code. */ - Frame *createFrame(const ByteVector &data, uint version = 4) const; + Frame *createFrame(const ByteVector &data, unsigned int version = 4) const; /*! * Create a frame based on \a data. \a tagHeader should be a valid diff --git a/taglib/mpeg/id3v2/id3v2header.cpp b/taglib/mpeg/id3v2/id3v2header.cpp index 69d700ee..da4aba0a 100644 --- a/taglib/mpeg/id3v2/id3v2header.cpp +++ b/taglib/mpeg/id3v2/id3v2header.cpp @@ -48,22 +48,22 @@ public: footerPresent(false), tagSize(0) {} - uint majorVersion; - uint revisionNumber; + unsigned int majorVersion; + unsigned int revisionNumber; bool unsynchronisation; bool extendedHeader; bool experimentalIndicator; bool footerPresent; - uint tagSize; + unsigned int tagSize; }; //////////////////////////////////////////////////////////////////////////////// // static members //////////////////////////////////////////////////////////////////////////////// -TagLib::uint Header::size() +unsigned int Header::size() { return 10; } @@ -93,17 +93,17 @@ Header::~Header() delete d; } -TagLib::uint Header::majorVersion() const +unsigned int Header::majorVersion() const { return d->majorVersion; } -void Header::setMajorVersion(TagLib::uint version) +void Header::setMajorVersion(unsigned int version) { d->majorVersion = version; } -TagLib::uint Header::revisionNumber() const +unsigned int Header::revisionNumber() const { return d->revisionNumber; } @@ -128,12 +128,12 @@ bool Header::footerPresent() const return d->footerPresent; } -TagLib::uint Header::tagSize() const +unsigned int Header::tagSize() const { return d->tagSize; } -TagLib::uint Header::completeTagSize() const +unsigned int Header::completeTagSize() const { if(d->footerPresent) return d->tagSize + size() + Footer::size(); @@ -141,7 +141,7 @@ TagLib::uint Header::completeTagSize() const return d->tagSize + size(); } -void Header::setTagSize(uint s) +void Header::setTagSize(unsigned int s) { d->tagSize = s; } diff --git a/taglib/mpeg/id3v2/id3v2header.h b/taglib/mpeg/id3v2/id3v2header.h index 52294ddd..12fb6d02 100644 --- a/taglib/mpeg/id3v2/id3v2header.h +++ b/taglib/mpeg/id3v2/id3v2header.h @@ -67,7 +67,7 @@ namespace TagLib { * Returns the major version number. (Note: This is the 4, not the 2 in * ID3v2.4.0. The 2 is implied.) */ - uint majorVersion() const; + unsigned int majorVersion() const; /*! * Set the the major version number to \a version. (Note: This is @@ -78,13 +78,13 @@ namespace TagLib { * version which is written and in general should not be called by API * users. */ - void setMajorVersion(uint version); + void setMajorVersion(unsigned int version); /*! * Returns the revision number. (Note: This is the 0, not the 4 in * ID3v2.4.0. The 2 is implied.) */ - uint revisionNumber() const; + unsigned int revisionNumber() const; /*! * Returns true if unsynchronisation has been applied to all frames. @@ -116,7 +116,7 @@ namespace TagLib { * * \see completeTagSize() */ - uint tagSize() const; + unsigned int tagSize() const; /*! * Returns the tag size, including the header and, if present, the footer @@ -124,18 +124,18 @@ namespace TagLib { * * \see tagSize() */ - uint completeTagSize() const; + unsigned int completeTagSize() const; /*! * Set the tag size to \a s. * \see tagSize() */ - void setTagSize(uint s); + void setTagSize(unsigned int s); /*! * Returns the size of the header. Presently this is always 10 bytes. */ - static uint size(); + static unsigned int size(); /*! * Returns the string used to identify and ID3v2 tag inside of a file. diff --git a/taglib/mpeg/id3v2/id3v2synchdata.cpp b/taglib/mpeg/id3v2/id3v2synchdata.cpp index 03767371..b16c1987 100644 --- a/taglib/mpeg/id3v2/id3v2synchdata.cpp +++ b/taglib/mpeg/id3v2/id3v2synchdata.cpp @@ -30,9 +30,9 @@ using namespace TagLib; using namespace ID3v2; -TagLib::uint SynchData::toUInt(const ByteVector &data) +unsigned int SynchData::toUInt(const ByteVector &data) { - uint sum = 0; + unsigned int sum = 0; bool notSynchSafe = false; int last = data.size() > 4 ? 3 : data.size() - 1; @@ -62,7 +62,7 @@ TagLib::uint SynchData::toUInt(const ByteVector &data) return sum; } -ByteVector SynchData::fromUInt(uint value) +ByteVector SynchData::fromUInt(unsigned int value) { ByteVector v(4, 0); diff --git a/taglib/mpeg/id3v2/id3v2synchdata.h b/taglib/mpeg/id3v2/id3v2synchdata.h index 4a1f596a..13e07161 100644 --- a/taglib/mpeg/id3v2/id3v2synchdata.h +++ b/taglib/mpeg/id3v2/id3v2synchdata.h @@ -51,12 +51,12 @@ namespace TagLib { * 6.2). The default \a length of * 4 is used if another value is not specified. */ - TAGLIB_EXPORT uint toUInt(const ByteVector &data); + TAGLIB_EXPORT unsigned int toUInt(const ByteVector &data); /*! * Returns a 4 byte (32 bit) synchsafe integer based on \a value. */ - TAGLIB_EXPORT ByteVector fromUInt(uint value); + TAGLIB_EXPORT ByteVector fromUInt(unsigned int value); /*! * Convert the data from unsynchronized data to its original format. diff --git a/taglib/mpeg/id3v2/id3v2tag.cpp b/taglib/mpeg/id3v2/id3v2tag.cpp index 224a607f..b826ecaa 100644 --- a/taglib/mpeg/id3v2/id3v2tag.cpp +++ b/taglib/mpeg/id3v2/id3v2tag.cpp @@ -212,14 +212,14 @@ String ID3v2::Tag::genre() const return genres.toString(); } -TagLib::uint ID3v2::Tag::year() const +unsigned int ID3v2::Tag::year() const { if(!d->frameListMap["TDRC"].isEmpty()) return d->frameListMap["TDRC"].front()->toString().substr(0, 4).toInt(); return 0; } -TagLib::uint ID3v2::Tag::track() const +unsigned int ID3v2::Tag::track() const { if(!d->frameListMap["TRCK"].isEmpty()) return d->frameListMap["TRCK"].front()->toString().toInt(); @@ -283,7 +283,7 @@ void ID3v2::Tag::setGenre(const String &s) #endif } -void ID3v2::Tag::setYear(uint i) +void ID3v2::Tag::setYear(unsigned int i) { if(i <= 0) { removeFrames("TDRC"); @@ -292,7 +292,7 @@ void ID3v2::Tag::setYear(uint i) setTextFrame("TDRC", String::number(i)); } -void ID3v2::Tag::setTrack(uint i) +void ID3v2::Tag::setTrack(unsigned int i) { if(i <= 0) { removeFrames("TRCK"); @@ -539,14 +539,14 @@ void ID3v2::Tag::downgradeFrames(FrameList *frames, FrameList *newFrames) const StringList people; if(frameTMCL) { StringList v24People = frameTMCL->fieldList(); - for(uint i = 0; i + 1 < v24People.size(); i += 2) { + for(unsigned int i = 0; i + 1 < v24People.size(); i += 2) { people.append(v24People[i]); people.append(v24People[i+1]); } } if(frameTIPL) { StringList v24People = frameTIPL->fieldList(); - for(uint i = 0; i + 1 < v24People.size(); i += 2) { + for(unsigned int i = 0; i + 1 < v24People.size(); i += 2) { people.append(v24People[i]); people.append(v24People[i+1]); } @@ -628,7 +628,7 @@ ByteVector ID3v2::Tag::render(int version) const paddingSize = MinPaddingSize; } - tagData.resize(static_cast(tagData.size() + paddingSize), '\0'); + tagData.resize(static_cast(tagData.size() + paddingSize), '\0'); // Set the version and data size. d->header.setMajorVersion(version); @@ -686,7 +686,7 @@ void ID3v2::Tag::read(TagLib::File *file, long offset) // This is a workaround for some faulty files that have duplicate ID3v2 tags. // Unfortunately, TagLib itself may write such duplicate tags until v1.10. - uint extraSize = 0; + unsigned int extraSize = 0; while(true) { @@ -712,8 +712,8 @@ void ID3v2::Tag::parse(const ByteVector &origData) if(d->header.unsynchronisation() && d->header.majorVersion() <= 3) data = SynchData::decode(data); - uint frameDataPosition = 0; - uint frameDataLength = data.size(); + unsigned int frameDataPosition = 0; + unsigned int frameDataLength = data.size(); // check for extended header diff --git a/taglib/mpeg/id3v2/id3v2tag.h b/taglib/mpeg/id3v2/id3v2tag.h index af0efdc3..dcd55a0c 100644 --- a/taglib/mpeg/id3v2/id3v2tag.h +++ b/taglib/mpeg/id3v2/id3v2tag.h @@ -169,16 +169,16 @@ namespace TagLib { virtual String album() const; virtual String comment() const; virtual String genre() const; - virtual uint year() const; - virtual uint track() const; + virtual unsigned int year() const; + virtual unsigned int 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(unsigned int i); + virtual void setTrack(unsigned int i); virtual bool isEmpty() const; diff --git a/taglib/mpeg/mpegfile.cpp b/taglib/mpeg/mpegfile.cpp index 716c2cfa..9db73953 100644 --- a/taglib/mpeg/mpegfile.cpp +++ b/taglib/mpeg/mpegfile.cpp @@ -87,11 +87,11 @@ public: const ID3v2::FrameFactory *ID3v2FrameFactory; long ID3v2Location; - uint ID3v2OriginalSize; + unsigned int ID3v2OriginalSize; long APELocation; long APEFooterLocation; - uint APEOriginalSize; + unsigned int APEOriginalSize; long ID3v1Location; @@ -393,7 +393,7 @@ long MPEG::File::nextFrameOffset(long position) if(foundLastSyncPattern && secondSynchByte(buffer[0])) return position - 1; - for(uint i = 0; i < buffer.size() - 1; i++) { + for(unsigned int i = 0; i < buffer.size() - 1; i++) { if(firstSyncByte(buffer[i]) && secondSynchByte(buffer[i + 1])) return position + i; } diff --git a/taglib/mpeg/xingheader.cpp b/taglib/mpeg/xingheader.cpp index 6e554599..6c2b25dc 100644 --- a/taglib/mpeg/xingheader.cpp +++ b/taglib/mpeg/xingheader.cpp @@ -40,8 +40,8 @@ public: size(0), type(MPEG::XingHeader::Invalid) {} - uint frames; - uint size; + unsigned int frames; + unsigned int size; MPEG::XingHeader::HeaderType type; }; @@ -66,12 +66,12 @@ bool MPEG::XingHeader::isValid() const return (d->type != Invalid && d->frames > 0 && d->size > 0); } -TagLib::uint MPEG::XingHeader::totalFrames() const +unsigned int MPEG::XingHeader::totalFrames() const { return d->frames; } -TagLib::uint MPEG::XingHeader::totalSize() const +unsigned int MPEG::XingHeader::totalSize() const { return d->size; } diff --git a/taglib/mpeg/xingheader.h b/taglib/mpeg/xingheader.h index cd417157..f512e234 100644 --- a/taglib/mpeg/xingheader.h +++ b/taglib/mpeg/xingheader.h @@ -93,12 +93,12 @@ namespace TagLib { /*! * Returns the total number of frames. */ - uint totalFrames() const; + unsigned int totalFrames() const; /*! * Returns the total size of stream in bytes. */ - uint totalSize() const; + unsigned int totalSize() const; /*! * Returns the type of the VBR header. diff --git a/taglib/ogg/flac/oggflacfile.cpp b/taglib/ogg/flac/oggflacfile.cpp index 1258e705..3a36ebe8 100644 --- a/taglib/ogg/flac/oggflacfile.cpp +++ b/taglib/ogg/flac/oggflacfile.cpp @@ -247,7 +247,7 @@ void Ogg::FLAC::File::scan() char blockType = header[0] & 0x7f; bool lastBlock = (header[0] & 0x80) != 0; - uint length = header.toUInt(1, 3, true); + unsigned int length = header.toUInt(1, 3, true); overhead += length; // Sanity: First block should be the stream_info metadata diff --git a/taglib/ogg/oggfile.cpp b/taglib/ogg/oggfile.cpp index 82781412..4b105b9a 100644 --- a/taglib/ogg/oggfile.cpp +++ b/taglib/ogg/oggfile.cpp @@ -53,7 +53,7 @@ public: delete lastPageHeader; } - uint streamSerialNumber; + unsigned int streamSerialNumber; List pages; PageHeader *firstPageHeader; PageHeader *lastPageHeader; @@ -78,7 +78,7 @@ Ogg::File::~File() delete d; } -ByteVector Ogg::File::packet(uint i) +ByteVector Ogg::File::packet(unsigned int i) { // Check to see if we're called setPacket() for this packet since the last // save: @@ -100,7 +100,7 @@ ByteVector Ogg::File::packet(uint i) // If the last read stopped at the packet that we're interested in, don't // reread its packet list. (This should make sequential packet reads fast.) - uint pageIndex = d->packetToPageMap[i].front(); + unsigned int pageIndex = d->packetToPageMap[i].front(); if(d->currentPacketPage != d->pages[pageIndex]) { d->currentPacketPage = d->pages[pageIndex]; d->currentPackets = d->currentPacketPage->packets(); @@ -136,7 +136,7 @@ ByteVector Ogg::File::packet(uint i) return packet; } -void Ogg::File::setPacket(uint i, const ByteVector &p) +void Ogg::File::setPacket(unsigned int i, const ByteVector &p) { while(d->packetToPageMap.size() <= i) { if(!nextPage()) { @@ -265,8 +265,8 @@ bool Ogg::File::nextPage() // Loop through the packets in the page that we just read appending the // current page number to the packet to page map for each packet. - for(uint i = 0; i < d->currentPage->packetCount(); i++) { - uint currentPacket = d->currentPage->firstPacketIndex() + i; + for(unsigned int i = 0; i < d->currentPage->packetCount(); i++) { + unsigned int currentPacket = d->currentPage->firstPacketIndex() + i; if(d->packetToPageMap.size() <= currentPacket) d->packetToPageMap.push_back(List()); d->packetToPageMap[currentPacket].append(d->pages.size() - 1); @@ -308,12 +308,12 @@ void Ogg::File::writePageGroup(const List &thePageGroup) int originalSize = 0; for(List::ConstIterator it = pageGroup.begin(); it != pageGroup.end(); ++it) { - uint firstPacket = d->pages[*it]->firstPacketIndex(); - uint lastPacket = firstPacket + d->pages[*it]->packetCount() - 1; + unsigned int firstPacket = d->pages[*it]->firstPacketIndex(); + unsigned int lastPacket = firstPacket + d->pages[*it]->packetCount() - 1; List::ConstIterator last = --pageGroup.end(); - for(uint i = firstPacket; i <= lastPacket; i++) { + for(unsigned int i = firstPacket; i <= lastPacket; i++) { if(it == last && i == lastPacket && !d->dirtyPages.contains(i)) packets.append(d->pages[*it]->packets().back()); diff --git a/taglib/ogg/oggfile.h b/taglib/ogg/oggfile.h index 8fed4ba0..c24e0153 100644 --- a/taglib/ogg/oggfile.h +++ b/taglib/ogg/oggfile.h @@ -59,12 +59,12 @@ namespace TagLib { * \warning The requires reading at least the packet header for every page * up to the requested page. */ - ByteVector packet(uint i); + ByteVector packet(unsigned int i); /*! * Sets the packet with index \a i to the value \a p. */ - void setPacket(uint i, const ByteVector &p); + void setPacket(unsigned int i, const ByteVector &p); /*! * Returns a pointer to the PageHeader for the first page in the stream or diff --git a/taglib/ogg/oggpage.cpp b/taglib/ogg/oggpage.cpp index e5f767ec..0268c739 100644 --- a/taglib/ogg/oggpage.cpp +++ b/taglib/ogg/oggpage.cpp @@ -131,7 +131,7 @@ Ogg::Page::ContainsPacketFlags Ogg::Page::containsPacket(int index) const return flags; } -TagLib::uint Ogg::Page::packetCount() const +unsigned int Ogg::Page::packetCount() const { return d->header.packetSizes().size(); } @@ -197,7 +197,7 @@ ByteVector Ogg::Page::render() const List Ogg::Page::paginate(const ByteVectorList &packets, PaginationStrategy strategy, - uint streamSerialNumber, + unsigned int streamSerialNumber, int firstPage, bool firstPacketContinued, bool lastPacketCompleted, @@ -310,7 +310,7 @@ Ogg::Page* Ogg::Page::getCopyWithNewPageSequenceNumber(int sequenceNumber) //////////////////////////////////////////////////////////////////////////////// Ogg::Page::Page(const ByteVectorList &packets, - uint streamSerialNumber, + unsigned int streamSerialNumber, int pageNumber, bool firstPacketContinued, bool lastPacketCompleted, diff --git a/taglib/ogg/oggpage.h b/taglib/ogg/oggpage.h index 9ec79407..d4bb34d2 100644 --- a/taglib/ogg/oggpage.h +++ b/taglib/ogg/oggpage.h @@ -121,7 +121,7 @@ namespace TagLib { /*! * Returns the number of packets (whole or partial) in this page. */ - uint packetCount() const; + unsigned int packetCount() const; /*! * Returns a list of the packets in this page. @@ -181,7 +181,7 @@ namespace TagLib { */ static List paginate(const ByteVectorList &packets, PaginationStrategy strategy, - uint streamSerialNumber, + unsigned int streamSerialNumber, int firstPage, bool firstPacketContinued = false, bool lastPacketCompleted = true, @@ -193,7 +193,7 @@ namespace TagLib { * for each page will be set to \a pageNumber. */ Page(const ByteVectorList &packets, - uint streamSerialNumber, + unsigned int streamSerialNumber, int pageNumber, bool firstPacketContinued = false, bool lastPacketCompleted = true, diff --git a/taglib/ogg/oggpageheader.cpp b/taglib/ogg/oggpageheader.cpp index 54c6c259..43ed2a00 100644 --- a/taglib/ogg/oggpageheader.cpp +++ b/taglib/ogg/oggpageheader.cpp @@ -63,7 +63,7 @@ public: bool firstPageOfStream; bool lastPageOfStream; long long absoluteGranularPosition; - uint streamSerialNumber; + unsigned int streamSerialNumber; int pageSequenceNumber; int size; int dataSize; @@ -160,12 +160,12 @@ void Ogg::PageHeader::setPageSequenceNumber(int sequenceNumber) d->pageSequenceNumber = sequenceNumber; } -TagLib::uint Ogg::PageHeader::streamSerialNumber() const +unsigned int Ogg::PageHeader::streamSerialNumber() const { return d->streamSerialNumber; } -void Ogg::PageHeader::setStreamSerialNumber(uint n) +void Ogg::PageHeader::setStreamSerialNumber(unsigned int n) { d->streamSerialNumber = n; } diff --git a/taglib/ogg/oggpageheader.h b/taglib/ogg/oggpageheader.h index 742710a4..8ff1232b 100644 --- a/taglib/ogg/oggpageheader.h +++ b/taglib/ogg/oggpageheader.h @@ -169,7 +169,7 @@ namespace TagLib { * * \see setStreamSerialNumber() */ - uint streamSerialNumber() const; + unsigned int streamSerialNumber() const; /*! * Every Ogg logical stream is given a random serial number which is common @@ -179,7 +179,7 @@ namespace TagLib { * * \see streamSerialNumber() */ - void setStreamSerialNumber(uint n); + void setStreamSerialNumber(unsigned int n); /*! * Returns the index of the page within the Ogg stream. This helps make it diff --git a/taglib/ogg/opus/opusproperties.cpp b/taglib/ogg/opus/opusproperties.cpp index 43858da6..537ba166 100644 --- a/taglib/ogg/opus/opusproperties.cpp +++ b/taglib/ogg/opus/opusproperties.cpp @@ -127,7 +127,7 @@ void Opus::Properties::read(File *file) const ByteVector data = file->packet(0); // *Magic Signature* - uint pos = 8; + unsigned int pos = 8; // *Version* (8 bits, unsigned) d->opusVersion = static_cast(data.at(pos)); diff --git a/taglib/ogg/speex/speexproperties.cpp b/taglib/ogg/speex/speexproperties.cpp index e486e449..fbcc5a4b 100644 --- a/taglib/ogg/speex/speexproperties.cpp +++ b/taglib/ogg/speex/speexproperties.cpp @@ -131,7 +131,7 @@ void Speex::Properties::read(File *file) return; } - uint pos = 28; + unsigned int pos = 28; // speex_version_id; /**< Version for Speex (for checking compatibility) */ d->speexVersion = data.toUInt(pos, false); diff --git a/taglib/ogg/vorbis/vorbisproperties.cpp b/taglib/ogg/vorbis/vorbisproperties.cpp index cef0b395..981400f0 100644 --- a/taglib/ogg/vorbis/vorbisproperties.cpp +++ b/taglib/ogg/vorbis/vorbisproperties.cpp @@ -144,7 +144,7 @@ void Vorbis::Properties::read(File *file) return; } - uint pos = 0; + unsigned int pos = 0; if(data.mid(pos, 7) != vorbisSetupHeaderID) { debug("Vorbis::Properties::read() -- invalid Vorbis identification header"); diff --git a/taglib/ogg/xiphcomment.cpp b/taglib/ogg/xiphcomment.cpp index 9a81df17..bb62069e 100644 --- a/taglib/ogg/xiphcomment.cpp +++ b/taglib/ogg/xiphcomment.cpp @@ -121,7 +121,7 @@ String Ogg::XiphComment::genre() const return d->fieldListMap["GENRE"].toString(); } -TagLib::uint Ogg::XiphComment::year() const +unsigned int Ogg::XiphComment::year() const { if(!d->fieldListMap["DATE"].isEmpty()) return d->fieldListMap["DATE"].front().toInt(); @@ -130,7 +130,7 @@ TagLib::uint Ogg::XiphComment::year() const return 0; } -TagLib::uint Ogg::XiphComment::track() const +unsigned int Ogg::XiphComment::track() const { if(!d->fieldListMap["TRACKNUMBER"].isEmpty()) return d->fieldListMap["TRACKNUMBER"].front().toInt(); @@ -171,7 +171,7 @@ void Ogg::XiphComment::setGenre(const String &s) addField("GENRE", s); } -void Ogg::XiphComment::setYear(uint i) +void Ogg::XiphComment::setYear(unsigned int i) { removeFields("YEAR"); if(i == 0) @@ -180,7 +180,7 @@ void Ogg::XiphComment::setYear(uint i) addField("DATE", String::number(i)); } -void Ogg::XiphComment::setTrack(uint i) +void Ogg::XiphComment::setTrack(unsigned int i) { removeFields("TRACKNUM"); if(i == 0) @@ -199,9 +199,9 @@ bool Ogg::XiphComment::isEmpty() const return true; } -TagLib::uint Ogg::XiphComment::fieldCount() const +unsigned int Ogg::XiphComment::fieldCount() const { - uint count = 0; + unsigned int count = 0; for(FieldConstIterator it = d->fieldListMap.begin(); it != d->fieldListMap.end(); ++it) count += (*it).second.size(); @@ -411,9 +411,9 @@ void Ogg::XiphComment::parse(const ByteVector &data) // The first thing in the comment data is the vendor ID length, followed by a // UTF8 string with the vendor ID. - uint pos = 0; + unsigned int pos = 0; - const uint vendorLength = data.toUInt(0, false); + const unsigned int vendorLength = data.toUInt(0, false); pos += 4; d->vendorID = String(data.mid(pos, vendorLength), String::UTF8); @@ -421,19 +421,19 @@ void Ogg::XiphComment::parse(const ByteVector &data) // Next the number of fields in the comment vector. - const uint commentFields = data.toUInt(pos, false); + const unsigned int commentFields = data.toUInt(pos, false); pos += 4; if(commentFields > (data.size() - 8) / 4) { return; } - for(uint i = 0; i < commentFields; i++) { + for(unsigned int i = 0; i < commentFields; i++) { // Each comment field is in the format "KEY=value" in a UTF8 string and has // 4 bytes before the text starts that gives the length. - const uint commentLength = data.toUInt(pos, false); + const unsigned int commentLength = data.toUInt(pos, false); pos += 4; ByteVector entry = data.mid(pos, commentLength); diff --git a/taglib/ogg/xiphcomment.h b/taglib/ogg/xiphcomment.h index 7f6d4e89..055477da 100644 --- a/taglib/ogg/xiphcomment.h +++ b/taglib/ogg/xiphcomment.h @@ -85,23 +85,23 @@ namespace TagLib { virtual String album() const; virtual String comment() const; virtual String genre() const; - virtual uint year() const; - virtual uint track() const; + virtual unsigned int year() const; + virtual unsigned int 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(unsigned int i); + virtual void setTrack(unsigned int i); virtual bool isEmpty() const; /*! * Returns the number of fields present in the comment. */ - uint fieldCount() const; + unsigned int fieldCount() const; /*! * Returns a reference to the map of field lists. Because Xiph comments diff --git a/taglib/riff/aiff/aifffile.cpp b/taglib/riff/aiff/aifffile.cpp index 28f4b803..1a29938c 100644 --- a/taglib/riff/aiff/aifffile.cpp +++ b/taglib/riff/aiff/aifffile.cpp @@ -140,7 +140,7 @@ bool RIFF::AIFF::File::hasID3v2Tag() const void RIFF::AIFF::File::read(bool readProperties) { - for(uint i = 0; i < chunkCount(); ++i) { + for(unsigned int i = 0; i < chunkCount(); ++i) { const ByteVector name = chunkName(i); if(name == "ID3 " || name == "id3 ") { if(!d->tag) { diff --git a/taglib/riff/aiff/aiffproperties.cpp b/taglib/riff/aiff/aiffproperties.cpp index 020ac6cf..e1d954fe 100644 --- a/taglib/riff/aiff/aiffproperties.cpp +++ b/taglib/riff/aiff/aiffproperties.cpp @@ -50,7 +50,7 @@ public: ByteVector compressionType; String compressionName; - uint sampleFrames; + unsigned int sampleFrames; }; //////////////////////////////////////////////////////////////////////////////// @@ -116,7 +116,7 @@ int RIFF::AIFF::Properties::sampleWidth() const return bitsPerSample(); } -TagLib::uint RIFF::AIFF::Properties::sampleFrames() const +unsigned int RIFF::AIFF::Properties::sampleFrames() const { return d->sampleFrames; } @@ -143,8 +143,8 @@ String RIFF::AIFF::Properties::compressionName() const void RIFF::AIFF::Properties::read(File *file) { ByteVector data; - uint streamLength = 0; - for(uint i = 0; i < file->chunkCount(); i++) { + unsigned int streamLength = 0; + for(unsigned int i = 0; i < file->chunkCount(); i++) { const ByteVector name = file->chunkName(i); if(name == "COMM") { if(data.isEmpty()) diff --git a/taglib/riff/aiff/aiffproperties.h b/taglib/riff/aiff/aiffproperties.h index 1d92ac87..d8bbaca9 100644 --- a/taglib/riff/aiff/aiffproperties.h +++ b/taglib/riff/aiff/aiffproperties.h @@ -124,7 +124,7 @@ namespace TagLib { /*! * Returns the number of sample frames */ - uint sampleFrames() const; + unsigned int sampleFrames() const; /*! * Returns true if the file is in AIFF-C format, false if AIFF format. diff --git a/taglib/riff/rifffile.cpp b/taglib/riff/rifffile.cpp index 2518dd9e..b96d3db5 100644 --- a/taglib/riff/rifffile.cpp +++ b/taglib/riff/rifffile.cpp @@ -37,10 +37,10 @@ using namespace TagLib; struct Chunk { - ByteVector name; - TagLib::uint offset; - TagLib::uint size; - char padding; + ByteVector name; + unsigned int offset; + unsigned int size; + unsigned int padding; }; class RIFF::File::FilePrivate @@ -51,9 +51,9 @@ public: size(0) {} const Endianness endianness; - ByteVector type; - TagLib::uint size; - ByteVector format; + ByteVector type; + unsigned int size; + ByteVector format; std::vector chunks; }; @@ -87,32 +87,32 @@ RIFF::File::File(IOStream *stream, Endianness endianness) : read(); } -TagLib::uint RIFF::File::riffSize() const +unsigned int RIFF::File::riffSize() const { return d->size; } -TagLib::uint RIFF::File::chunkCount() const +unsigned int RIFF::File::chunkCount() const { return d->chunks.size(); } -TagLib::uint RIFF::File::chunkDataSize(uint i) const +unsigned int RIFF::File::chunkDataSize(unsigned int i) const { return d->chunks[i].size; } -TagLib::uint RIFF::File::chunkOffset(uint i) const +unsigned int RIFF::File::chunkOffset(unsigned int i) const { return d->chunks[i].offset; } -TagLib::uint RIFF::File::chunkPadding(uint i) const +unsigned int RIFF::File::chunkPadding(unsigned int i) const { return d->chunks[i].padding; } -ByteVector RIFF::File::chunkName(uint i) const +ByteVector RIFF::File::chunkName(unsigned int i) const { if(i >= chunkCount()) return ByteVector(); @@ -120,7 +120,7 @@ ByteVector RIFF::File::chunkName(uint i) const return d->chunks[i].name; } -ByteVector RIFF::File::chunkData(uint i) +ByteVector RIFF::File::chunkData(unsigned int i) { if(i >= chunkCount()) return ByteVector(); @@ -129,7 +129,7 @@ ByteVector RIFF::File::chunkData(uint i) return readBlock(d->chunks[i].size); } -void RIFF::File::setChunkData(uint i, const ByteVector &data) +void RIFF::File::setChunkData(unsigned int i, const ByteVector &data) { // First we update the global size @@ -167,7 +167,7 @@ void RIFF::File::setChunkData(const ByteVector &name, const ByteVector &data, bo } if(!alwaysCreate) { - for(uint i = 0; i < d->chunks.size(); i++) { + for(unsigned int i = 0; i < d->chunks.size(); i++) { if(d->chunks[i].name == name) { setChunkData(i, data); return; @@ -177,7 +177,7 @@ void RIFF::File::setChunkData(const ByteVector &name, const ByteVector &data, bo // Couldn't find an existing chunk, so let's create a new one. - uint i = d->chunks.size() - 1; + unsigned int i = d->chunks.size() - 1; unsigned long offset = d->chunks[i].offset + d->chunks[i].size; // First we update the global size @@ -205,7 +205,7 @@ void RIFF::File::setChunkData(const ByteVector &name, const ByteVector &data, bo d->chunks.push_back(chunk); } -void RIFF::File::removeChunk(uint i) +void RIFF::File::removeChunk(unsigned int i) { if(i >= d->chunks.size()) return; @@ -213,7 +213,7 @@ void RIFF::File::removeChunk(uint i) std::vector::iterator it = d->chunks.begin(); std::advance(it, i); - const uint removeSize = it->size + it->padding + 8; + const unsigned int removeSize = it->size + it->padding + 8; removeBlock(it->offset - 8, removeSize); it = d->chunks.erase(it); @@ -244,7 +244,7 @@ void RIFF::File::read() // + 8: chunk header at least, fix for additional junk bytes while(tell() + 8 <= length()) { ByteVector chunkName = readBlock(4); - uint chunkSize = readBlock(4).toUInt(bigEndian); + unsigned int chunkSize = readBlock(4).toUInt(bigEndian); if(!isValidChunkName(chunkName)) { debug("RIFF::File::read() -- Chunk '" + chunkName + "' has invalid ID"); @@ -284,7 +284,8 @@ void RIFF::File::read() } void RIFF::File::writeChunk(const ByteVector &name, const ByteVector &data, - unsigned long offset, unsigned long replace, uint leadingPadding) + unsigned long offset, unsigned long replace, + unsigned int leadingPadding) { ByteVector combined; if(leadingPadding) { diff --git a/taglib/riff/rifffile.h b/taglib/riff/rifffile.h index 766ae0c4..52e75134 100644 --- a/taglib/riff/rifffile.h +++ b/taglib/riff/rifffile.h @@ -61,46 +61,46 @@ namespace TagLib { /*! * \return The size of the main RIFF chunk. */ - uint riffSize() const; + unsigned int riffSize() const; /*! * \return The number of chunks in the file. */ - uint chunkCount() const; + unsigned int chunkCount() const; /*! * \return The offset within the file for the selected chunk number. */ - uint chunkOffset(uint i) const; + unsigned int chunkOffset(unsigned int i) const; /*! * \return The size of the chunk data. */ - uint chunkDataSize(uint i) const; + unsigned int chunkDataSize(unsigned int i) const; /*! * \return The size of the padding after the chunk (can be either 0 or 1). */ - uint chunkPadding(uint i) const; + unsigned int chunkPadding(unsigned int i) const; /*! * \return The name of the specified chunk, for instance, "COMM" or "ID3 " */ - ByteVector chunkName(uint i) const; + ByteVector chunkName(unsigned int i) const; /*! * Reads the chunk data from the file and returns it. * * \note This \e will move the read pointer for the file. */ - ByteVector chunkData(uint i); + ByteVector chunkData(unsigned int i); /*! * Sets the data for the specified chunk to \a data. * * \warning This will update the file immediately. */ - void setChunkData(uint i, const ByteVector &data); + void setChunkData(unsigned int i, const ByteVector &data); /*! * Sets the data for the chunk \a name to \a data. If a chunk with the @@ -129,7 +129,7 @@ namespace TagLib { * * \warning This will update the file immediately. */ - void removeChunk(uint i); + void removeChunk(unsigned int i); /*! * Removes the chunk \a name. @@ -146,7 +146,7 @@ namespace TagLib { void read(); void writeChunk(const ByteVector &name, const ByteVector &data, unsigned long offset, unsigned long replace = 0, - uint leadingPadding = 0); + unsigned int leadingPadding = 0); class FilePrivate; FilePrivate *d; diff --git a/taglib/riff/wav/infotag.cpp b/taglib/riff/wav/infotag.cpp index 00d1f1c5..df1cfbee 100644 --- a/taglib/riff/wav/infotag.cpp +++ b/taglib/riff/wav/infotag.cpp @@ -113,12 +113,12 @@ String RIFF::Info::Tag::genre() const return fieldText("IGNR"); } -TagLib::uint RIFF::Info::Tag::year() const +unsigned int RIFF::Info::Tag::year() const { return fieldText("ICRD").substr(0, 4).toInt(); } -TagLib::uint RIFF::Info::Tag::track() const +unsigned int RIFF::Info::Tag::track() const { return fieldText("IPRT").toInt(); } @@ -148,7 +148,7 @@ void RIFF::Info::Tag::setGenre(const String &s) setFieldText("IGNR", s); } -void RIFF::Info::Tag::setYear(uint i) +void RIFF::Info::Tag::setYear(unsigned int i) { if(i != 0) setFieldText("ICRD", String::number(i)); @@ -156,7 +156,7 @@ void RIFF::Info::Tag::setYear(uint i) d->fieldListMap.erase("ICRD"); } -void RIFF::Info::Tag::setTrack(uint i) +void RIFF::Info::Tag::setTrack(unsigned int i) { if(i != 0) setFieldText("IPRT", String::number(i)); @@ -239,9 +239,9 @@ void RIFF::Info::Tag::setStringHandler(const StringHandler *handler) void RIFF::Info::Tag::parse(const ByteVector &data) { - uint p = 4; + unsigned int p = 4; while(p < data.size()) { - const uint size = data.toUInt(p + 4, false); + const unsigned int size = data.toUInt(p + 4, false); if(size > data.size() - p - 8) break; diff --git a/taglib/riff/wav/infotag.h b/taglib/riff/wav/infotag.h index 440e7b93..d1f0297d 100644 --- a/taglib/riff/wav/infotag.h +++ b/taglib/riff/wav/infotag.h @@ -107,16 +107,16 @@ namespace TagLib { virtual String album() const; virtual String comment() const; virtual String genre() const; - virtual uint year() const; - virtual uint track() const; + virtual unsigned int year() const; + virtual unsigned int 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(unsigned int i); + virtual void setTrack(unsigned int i); virtual bool isEmpty() const; diff --git a/taglib/riff/wav/wavfile.cpp b/taglib/riff/wav/wavfile.cpp index bdcfa474..79ff9167 100644 --- a/taglib/riff/wav/wavfile.cpp +++ b/taglib/riff/wav/wavfile.cpp @@ -189,7 +189,7 @@ bool RIFF::WAV::File::hasInfoTag() const void RIFF::WAV::File::read(bool readProperties) { - for(uint i = 0; i < chunkCount(); ++i) { + for(unsigned int i = 0; i < chunkCount(); ++i) { const ByteVector name = chunkName(i); if(name == "ID3 " || name == "id3 ") { if(!d->tag[ID3v2Index]) { diff --git a/taglib/riff/wav/wavproperties.cpp b/taglib/riff/wav/wavproperties.cpp index 39f0dddc..df7cdbae 100644 --- a/taglib/riff/wav/wavproperties.cpp +++ b/taglib/riff/wav/wavproperties.cpp @@ -57,21 +57,21 @@ public: int sampleRate; int channels; int bitsPerSample; - uint sampleFrames; + unsigned int sampleFrames; }; //////////////////////////////////////////////////////////////////////////////// // public members //////////////////////////////////////////////////////////////////////////////// -RIFF::WAV::Properties::Properties(const ByteVector & /*data*/, ReadStyle style) : +RIFF::WAV::Properties::Properties(const ByteVector &, ReadStyle style) : AudioProperties(style), d(new PropertiesPrivate()) { debug("RIFF::WAV::Properties::Properties() -- This constructor is no longer used."); } -RIFF::WAV::Properties::Properties(const ByteVector & /*data*/, uint /*streamLength*/, ReadStyle style) : +RIFF::WAV::Properties::Properties(const ByteVector &, unsigned int, ReadStyle style) : AudioProperties(style), d(new PropertiesPrivate()) { @@ -130,7 +130,7 @@ int RIFF::WAV::Properties::sampleWidth() const return bitsPerSample(); } -TagLib::uint RIFF::WAV::Properties::sampleFrames() const +unsigned int RIFF::WAV::Properties::sampleFrames() const { return d->sampleFrames; } @@ -147,10 +147,10 @@ int RIFF::WAV::Properties::format() const void RIFF::WAV::Properties::read(File *file) { ByteVector data; - uint streamLength = 0; - uint totalSamples = 0; + unsigned int streamLength = 0; + unsigned int totalSamples = 0; - for(uint i = 0; i < file->chunkCount(); ++i) { + for(unsigned int i = 0; i < file->chunkCount(); ++i) { const ByteVector name = file->chunkName(i); if(name == "fmt ") { if(data.isEmpty()) @@ -203,7 +203,7 @@ void RIFF::WAV::Properties::read(File *file) d->bitrate = static_cast(streamLength * 8.0 / length + 0.5); } else { - const uint byteRate = data.toUInt(8, false); + const unsigned int byteRate = data.toUInt(8, false); if(byteRate > 0) { d->length = static_cast(streamLength * 1000.0 / byteRate + 0.5); d->bitrate = static_cast(byteRate * 8.0 / 1000.0 + 0.5); diff --git a/taglib/riff/wav/wavproperties.h b/taglib/riff/wav/wavproperties.h index 1fd6a136..6716876a 100644 --- a/taglib/riff/wav/wavproperties.h +++ b/taglib/riff/wav/wavproperties.h @@ -63,7 +63,7 @@ namespace TagLib { * * \deprecated */ - Properties(const ByteVector &data, uint streamLength, ReadStyle style); + Properties(const ByteVector &data, unsigned int streamLength, ReadStyle style); /*! * Create an instance of WAV::Properties with the data read from the @@ -135,7 +135,7 @@ namespace TagLib { /*! * Returns the number of sample frames. */ - uint sampleFrames() const; + unsigned int sampleFrames() const; /*! * Returns the format ID of the file. diff --git a/taglib/tag.h b/taglib/tag.h index e04567b7..be9628c8 100644 --- a/taglib/tag.h +++ b/taglib/tag.h @@ -111,13 +111,13 @@ namespace TagLib { /*! * Returns the year; if there is no year set, this will return 0. */ - virtual uint year() const = 0; + virtual unsigned int year() const = 0; /*! * Returns the track number; if there is no track number set, this will * return 0. */ - virtual uint track() const = 0; + virtual unsigned int track() const = 0; /*! * Sets the title to \a s. If \a s is String::null then this value will be @@ -155,12 +155,12 @@ namespace TagLib { /*! * Sets the year to \a i. If \a s is 0 then this value will be cleared. */ - virtual void setYear(uint i) = 0; + virtual void setYear(unsigned int i) = 0; /*! * Sets the track to \a i. If \a s is 0 then this value will be cleared. */ - virtual void setTrack(uint i) = 0; + virtual void setTrack(unsigned int i) = 0; /*! * Returns true if the tag does not contain any data. This should be diff --git a/taglib/tagunion.cpp b/taglib/tagunion.cpp index 30a53583..c10d72b2 100644 --- a/taglib/tagunion.cpp +++ b/taglib/tagunion.cpp @@ -190,12 +190,12 @@ String TagUnion::genre() const stringUnion(genre); } -TagLib::uint TagUnion::year() const +unsigned int TagUnion::year() const { numberUnion(year); } -TagLib::uint TagUnion::track() const +unsigned int TagUnion::track() const { numberUnion(track); } @@ -225,12 +225,12 @@ void TagUnion::setGenre(const String &s) setUnion(Genre, s); } -void TagUnion::setYear(uint i) +void TagUnion::setYear(unsigned int i) { setUnion(Year, i); } -void TagUnion::setTrack(uint i) +void TagUnion::setTrack(unsigned int i) { setUnion(Track, i); } diff --git a/taglib/tagunion.h b/taglib/tagunion.h index 0a3b3a20..1eb38a01 100644 --- a/taglib/tagunion.h +++ b/taglib/tagunion.h @@ -64,16 +64,16 @@ namespace TagLib { virtual String album() const; virtual String comment() const; virtual String genre() const; - virtual uint year() const; - virtual uint track() const; + virtual unsigned int year() const; + virtual unsigned int 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(unsigned int i); + virtual void setTrack(unsigned int i); virtual bool isEmpty() const; template T *access(int index, bool create) diff --git a/taglib/toolkit/taglib.h b/taglib/toolkit/taglib.h index e9116e6d..4534f186 100644 --- a/taglib/toolkit/taglib.h +++ b/taglib/toolkit/taglib.h @@ -60,15 +60,15 @@ namespace TagLib { class String; + // These integer types are deprecated. Do not use them. + typedef wchar_t wchar; // Assumed to be sufficient to store a UTF-16 char. typedef unsigned char uchar; typedef unsigned short ushort; typedef unsigned int uint; + typedef unsigned long ulong; typedef unsigned long long ulonglong; - // long/ulong can be either 32-bit or 64-bit wide. - typedef unsigned long ulong; - /*! * Unfortunately std::wstring isn't defined on some systems, (i.e. GCC < 3) * so I'm providing something here that should be constant. diff --git a/taglib/toolkit/tbytevector.cpp b/taglib/toolkit/tbytevector.cpp index 6aff6423..1fba30a2 100644 --- a/taglib/toolkit/tbytevector.cpp +++ b/taglib/toolkit/tbytevector.cpp @@ -53,7 +53,7 @@ namespace TagLib { static const char hexTable[17] = "0123456789abcdef"; -static const uint crcTable[256] = { +static const unsigned int crcTable[256] = { 0x00000000, 0x04c11db7, 0x09823b6e, 0x0d4326d9, 0x130476dc, 0x17c56b6b, 0x1a864db2, 0x1e475005, 0x2608edb8, 0x22c9f00f, 0x2f8ad6d6, 0x2b4bcb61, 0x350c9b64, 0x31cd86d3, 0x3c8ea00a, 0x384fbdbd, 0x4c11db70, 0x48d0c6c7, @@ -102,7 +102,7 @@ static const uint crcTable[256] = { template int findChar( const TIterator dataBegin, const TIterator dataEnd, - char c, uint offset, int byteAlign) + char c, unsigned int offset, int byteAlign) { const size_t dataSize = dataEnd - dataBegin; if(offset + 1 > dataSize) @@ -125,7 +125,7 @@ template int findVector( const TIterator dataBegin, const TIterator dataEnd, const TIterator patternBegin, const TIterator patternEnd, - uint offset, int byteAlign) + unsigned int offset, int byteAlign) { const size_t dataSize = dataEnd - dataBegin; const size_t patternSize = patternEnd - patternBegin; @@ -308,19 +308,19 @@ long double toFloat80(const ByteVector &v, size_t offset) class ByteVector::ByteVectorPrivate { public: - ByteVectorPrivate(uint l, char c) : + ByteVectorPrivate(unsigned int l, char c) : counter(new RefCounter()), data(new std::vector(l, c)), offset(0), length(l) {} - ByteVectorPrivate(const char *s, uint l) : + ByteVectorPrivate(const char *s, unsigned int l) : counter(new RefCounter()), data(new std::vector(s, s + l)), offset(0), length(l) {} - ByteVectorPrivate(const ByteVectorPrivate &d, uint o, uint l) : + ByteVectorPrivate(const ByteVectorPrivate &d, unsigned int o, unsigned int l) : counter(d.counter), data(d.data), offset(d.offset + o), @@ -339,8 +339,8 @@ public: RefCounter *counter; std::vector *data; - uint offset; - uint length; + unsigned int offset; + unsigned int length; }; //////////////////////////////////////////////////////////////////////////////// @@ -349,7 +349,7 @@ public: ByteVector ByteVector::null; -ByteVector ByteVector::fromCString(const char *s, uint length) +ByteVector ByteVector::fromCString(const char *s, unsigned int length) { if(length == 0xffffffff) return ByteVector(s, ::strlen(s)); @@ -357,9 +357,9 @@ ByteVector ByteVector::fromCString(const char *s, uint length) return ByteVector(s, length); } -ByteVector ByteVector::fromUInt(uint value, bool mostSignificantByteFirst) +ByteVector ByteVector::fromUInt(unsigned int value, bool mostSignificantByteFirst) { - return fromNumber(value, mostSignificantByteFirst); + return fromNumber(value, mostSignificantByteFirst); } ByteVector ByteVector::fromShort(short value, bool mostSignificantByteFirst) @@ -374,12 +374,12 @@ ByteVector ByteVector::fromLongLong(long long value, bool mostSignificantByteFir ByteVector ByteVector::fromFloat32LE(float value) { - return fromFloat(value); + return fromFloat(value); } ByteVector ByteVector::fromFloat32BE(float value) { - return fromFloat(value); + return fromFloat(value); } ByteVector ByteVector::fromFloat64LE(double value) @@ -401,7 +401,7 @@ ByteVector::ByteVector() : { } -ByteVector::ByteVector(uint size, char value) : +ByteVector::ByteVector(unsigned int size, char value) : d(new ByteVectorPrivate(size, value)) { } @@ -411,7 +411,7 @@ ByteVector::ByteVector(const ByteVector &v) : { } -ByteVector::ByteVector(const ByteVector &v, uint offset, uint length) : +ByteVector::ByteVector(const ByteVector &v, unsigned int offset, unsigned int length) : d(new ByteVectorPrivate(*v.d, offset, length)) { } @@ -421,7 +421,7 @@ ByteVector::ByteVector(char c) : { } -ByteVector::ByteVector(const char *data, uint length) : +ByteVector::ByteVector(const char *data, unsigned int length) : d(new ByteVectorPrivate(data, length)) { } @@ -436,7 +436,7 @@ ByteVector::~ByteVector() delete d; } -ByteVector &ByteVector::setData(const char *s, uint length) +ByteVector &ByteVector::setData(const char *s, unsigned int length) { ByteVector(s, length).swap(*this); return *this; @@ -459,7 +459,7 @@ const char *ByteVector::data() const return (size() > 0) ? (&(*d->data)[d->offset]) : 0; } -ByteVector ByteVector::mid(uint index, uint length) const +ByteVector ByteVector::mid(unsigned int index, unsigned int length) const { index = std::min(index, size()); length = std::min(length, size() - index); @@ -467,23 +467,23 @@ ByteVector ByteVector::mid(uint index, uint length) const return ByteVector(*this, index, length); } -char ByteVector::at(uint index) const +char ByteVector::at(unsigned int index) const { return (index < size()) ? (*d->data)[d->offset + index] : 0; } -int ByteVector::find(const ByteVector &pattern, uint offset, int byteAlign) const +int ByteVector::find(const ByteVector &pattern, unsigned int offset, int byteAlign) const { return findVector( begin(), end(), pattern.begin(), pattern.end(), offset, byteAlign); } -int ByteVector::find(char c, uint offset, int byteAlign) const +int ByteVector::find(char c, unsigned int offset, int byteAlign) const { return findChar(begin(), end(), c, offset, byteAlign); } -int ByteVector::rfind(const ByteVector &pattern, uint offset, int byteAlign) const +int ByteVector::rfind(const ByteVector &pattern, unsigned int offset, int byteAlign) const { if(offset > 0) { offset = size() - offset - pattern.size(); @@ -500,13 +500,13 @@ int ByteVector::rfind(const ByteVector &pattern, uint offset, int byteAlign) con return size() - pos - pattern.size(); } -bool ByteVector::containsAt(const ByteVector &pattern, uint offset, uint patternOffset, uint patternLength) const +bool ByteVector::containsAt(const ByteVector &pattern, unsigned int offset, unsigned int patternOffset, unsigned int patternLength) const { if(pattern.size() < patternLength) patternLength = pattern.size(); // do some sanity checking -- all of these things are needed for the search to be valid - const uint compareLength = patternLength - patternOffset; + const unsigned int compareLength = patternLength - patternOffset; if(offset + compareLength > size() || patternOffset >= pattern.size() || patternLength == 0) return false; @@ -576,7 +576,7 @@ int ByteVector::endsWithPartialMatch(const ByteVector &pattern) const // try to match the last n-1 bytes from the vector (where n is the pattern // size) -- continue trying to match n-2, n-3...1 bytes - for(uint i = 1; i < pattern.size(); i++) { + for(unsigned int i = 1; i < pattern.size(); i++) { if(containsAt(pattern, startIndex + i, 0, pattern.size() - i)) return startIndex + i; } @@ -588,7 +588,7 @@ ByteVector &ByteVector::append(const ByteVector &v) { if(v.d->length != 0) { detach(); - uint originalSize = size(); + unsigned int originalSize = size(); resize(originalSize + v.size()); ::memcpy(data() + originalSize, v.data(), v.size()); } @@ -608,12 +608,12 @@ ByteVector &ByteVector::clear() return *this; } -TagLib::uint ByteVector::size() const +unsigned int ByteVector::size() const { return d->length; } -ByteVector &ByteVector::resize(uint size, char padding) +ByteVector &ByteVector::resize(unsigned int size, char padding) { if(size != d->length) { detach(); @@ -691,27 +691,27 @@ bool ByteVector::isEmpty() const return (d->length == 0); } -TagLib::uint ByteVector::checksum() const +unsigned int ByteVector::checksum() const { - uint sum = 0; + unsigned int sum = 0; for(ByteVector::ConstIterator it = begin(); it != end(); ++it) sum = (sum << 8) ^ crcTable[((sum >> 24) & 0xff) ^ static_cast(*it)]; return sum; } -TagLib::uint ByteVector::toUInt(bool mostSignificantByteFirst) const +unsigned int ByteVector::toUInt(bool mostSignificantByteFirst) const { - return toNumber(*this, 0, mostSignificantByteFirst); + return toNumber(*this, 0, mostSignificantByteFirst); } -TagLib::uint ByteVector::toUInt(uint offset, bool mostSignificantByteFirst) const +unsigned int ByteVector::toUInt(unsigned int offset, bool mostSignificantByteFirst) const { - return toNumber(*this, offset, mostSignificantByteFirst); + return toNumber(*this, offset, mostSignificantByteFirst); } -TagLib::uint ByteVector::toUInt(uint offset, uint length, bool mostSignificantByteFirst) const +unsigned int ByteVector::toUInt(unsigned int offset, unsigned int length, bool mostSignificantByteFirst) const { - return toNumber(*this, offset, length, mostSignificantByteFirst); + return toNumber(*this, offset, length, mostSignificantByteFirst); } short ByteVector::toShort(bool mostSignificantByteFirst) const @@ -719,7 +719,7 @@ short ByteVector::toShort(bool mostSignificantByteFirst) const return toNumber(*this, 0, mostSignificantByteFirst); } -short ByteVector::toShort(uint offset, bool mostSignificantByteFirst) const +short ByteVector::toShort(unsigned int offset, bool mostSignificantByteFirst) const { return toNumber(*this, offset, mostSignificantByteFirst); } @@ -729,7 +729,7 @@ unsigned short ByteVector::toUShort(bool mostSignificantByteFirst) const return toNumber(*this, 0, mostSignificantByteFirst); } -unsigned short ByteVector::toUShort(uint offset, bool mostSignificantByteFirst) const +unsigned short ByteVector::toUShort(unsigned int offset, bool mostSignificantByteFirst) const { return toNumber(*this, offset, mostSignificantByteFirst); } @@ -739,19 +739,19 @@ long long ByteVector::toLongLong(bool mostSignificantByteFirst) const return toNumber(*this, 0, mostSignificantByteFirst); } -long long ByteVector::toLongLong(uint offset, bool mostSignificantByteFirst) const +long long ByteVector::toLongLong(unsigned int offset, bool mostSignificantByteFirst) const { return toNumber(*this, offset, mostSignificantByteFirst); } float ByteVector::toFloat32LE(size_t offset) const { - return toFloat(*this, offset); + return toFloat(*this, offset); } float ByteVector::toFloat32BE(size_t offset) const { - return toFloat(*this, offset); + return toFloat(*this, offset); } double ByteVector::toFloat64LE(size_t offset) const @@ -862,7 +862,7 @@ ByteVector ByteVector::toHex() const ByteVector encoded(size() * 2); char *p = encoded.data(); - for(uint i = 0; i < size(); i++) { + for(unsigned int i = 0; i < size(); i++) { unsigned char c = data()[i]; *p++ = hexTable[(c >> 4) & 0x0F]; *p++ = hexTable[(c ) & 0x0F]; @@ -892,7 +892,7 @@ ByteVector ByteVector::fromBase64(const ByteVector & input) 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80 }; - uint len = input.size(); + unsigned int len = input.size(); ByteVector output(len); @@ -957,7 +957,7 @@ ByteVector ByteVector::toBase64() const { static const char alphabet[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; if (size()) { - uint len = size(); + unsigned int len = size(); ByteVector output(4 * ((len - 1) / 3 + 1)); // note roundup const char * src = data(); @@ -1009,7 +1009,7 @@ void ByteVector::detach() std::ostream &operator<<(std::ostream &s, const TagLib::ByteVector &v) { - for(TagLib::uint i = 0; i < v.size(); i++) + for(unsigned int i = 0; i < v.size(); i++) s << v[i]; return s; } diff --git a/taglib/toolkit/tbytevector.h b/taglib/toolkit/tbytevector.h index b2847c9f..e897307e 100644 --- a/taglib/toolkit/tbytevector.h +++ b/taglib/toolkit/tbytevector.h @@ -61,7 +61,7 @@ namespace TagLib { * Construct a vector of size \a size with all values set to \a value by * default. */ - ByteVector(uint size, char value = 0); + ByteVector(unsigned int size, char value = 0); /*! * Constructs a byte vector that is a copy of \a v. @@ -71,7 +71,7 @@ namespace TagLib { /*! * Constructs a byte vector that is a copy of \a v. */ - ByteVector(const ByteVector &v, uint offset, uint length); + ByteVector(const ByteVector &v, unsigned int offset, unsigned int length); /*! * Constructs a byte vector that contains \a c. @@ -81,7 +81,7 @@ namespace TagLib { /*! * Constructs a byte vector that copies \a data for up to \a length bytes. */ - ByteVector(const char *data, uint length); + ByteVector(const char *data, unsigned int length); /*! * Constructs a byte vector that copies \a data up to the first null @@ -100,7 +100,7 @@ namespace TagLib { /*! * Sets the data for the byte array using the first \a length bytes of \a data */ - ByteVector &setData(const char *data, uint length); + ByteVector &setData(const char *data, unsigned int length); /*! * Sets the data for the byte array copies \a data up to the first null @@ -127,13 +127,13 @@ namespace TagLib { * for \a length bytes. If \a length is not specified it will return the bytes * from \a index to the end of the vector. */ - ByteVector mid(uint index, uint length = 0xffffffff) const; + ByteVector mid(unsigned int index, unsigned int length = 0xffffffff) const; /*! * This essentially performs the same as operator[](), but instead of causing * a runtime error if the index is out of bounds, it will return a null byte. */ - char at(uint index) const; + char at(unsigned int index) const; /*! * Searches the ByteVector for \a pattern starting at \a offset and returns @@ -141,7 +141,7 @@ namespace TagLib { * specified the pattern will only be matched if it starts on a byte divisible * by \a byteAlign (starting from \a offset). */ - int find(const ByteVector &pattern, uint offset = 0, int byteAlign = 1) const; + int find(const ByteVector &pattern, unsigned int offset = 0, int byteAlign = 1) const; /*! * Searches the char for \a c starting at \a offset and returns @@ -149,7 +149,7 @@ namespace TagLib { * specified the pattern will only be matched if it starts on a byte divisible * by \a byteAlign (starting from \a offset). */ - int find(char c, uint offset = 0, int byteAlign = 1) const; + int find(char c, unsigned int offset = 0, int byteAlign = 1) const; /*! * Searches the ByteVector for \a pattern starting from either the end of the @@ -157,7 +157,7 @@ namespace TagLib { * not found. If \a byteAlign is specified the pattern will only be matched * if it starts on a byte divisible by \a byteAlign (starting from \a offset). */ - int rfind(const ByteVector &pattern, uint offset = 0, int byteAlign = 1) const; + int rfind(const ByteVector &pattern, unsigned int offset = 0, int byteAlign = 1) const; /*! * Checks to see if the vector contains the \a pattern starting at position @@ -166,7 +166,8 @@ namespace TagLib { * specify to only check for the first \a patternLength bytes of \a pattern with * the \a patternLength argument. */ - bool containsAt(const ByteVector &pattern, uint offset, uint patternOffset = 0, uint patternLength = 0xffffffff) const; + bool containsAt(const ByteVector &pattern, unsigned int offset, + unsigned int patternOffset = 0, unsigned int patternLength = 0xffffffff) const; /*! * Returns true if the vector starts with \a pattern. @@ -214,14 +215,14 @@ namespace TagLib { /*! * Returns the size of the array. */ - uint size() const; + unsigned int size() const; /*! * Resize the vector to \a size. If the vector is currently less than * \a size, pad the remaining spaces with \a padding. Returns a reference * to the resized vector. */ - ByteVector &resize(uint size, char padding = 0); + ByteVector &resize(unsigned int size, char padding = 0); /*! * Returns an Iterator that points to the front of the vector. @@ -290,7 +291,7 @@ namespace TagLib { * \note This uses an uncommon variant of CRC32 specializes in Ogg. */ // BIC: Remove or make generic. - uint checksum() const; + unsigned int checksum() const; /*! * Converts the first 4 bytes of the vector to an unsigned integer. @@ -302,7 +303,7 @@ namespace TagLib { * * \see fromUInt() */ - uint toUInt(bool mostSignificantByteFirst = true) const; + unsigned int toUInt(bool mostSignificantByteFirst = true) const; /*! * Converts the 4 bytes at \a offset of the vector to an unsigned integer. @@ -314,7 +315,7 @@ namespace TagLib { * * \see fromUInt() */ - uint toUInt(uint offset, bool mostSignificantByteFirst = true) const; + unsigned int toUInt(unsigned int offset, bool mostSignificantByteFirst = true) const; /*! * Converts the \a length bytes at \a offset of the vector to an unsigned @@ -327,7 +328,8 @@ namespace TagLib { * * \see fromUInt() */ - uint toUInt(uint offset, uint length, bool mostSignificantByteFirst = true) const; + unsigned int toUInt(unsigned int offset, unsigned int length, + bool mostSignificantByteFirst = true) const; /*! * Converts the first 2 bytes of the vector to a (signed) short. @@ -349,7 +351,7 @@ namespace TagLib { * * \see fromShort() */ - short toShort(uint offset, bool mostSignificantByteFirst = true) const; + short toShort(unsigned int offset, bool mostSignificantByteFirst = true) const; /*! * Converts the first 2 bytes of the vector to a unsigned short. @@ -371,7 +373,7 @@ namespace TagLib { * * \see fromShort() */ - unsigned short toUShort(uint offset, bool mostSignificantByteFirst = true) const; + unsigned short toUShort(unsigned int offset, bool mostSignificantByteFirst = true) const; /*! * Converts the first 8 bytes of the vector to a (signed) long long. @@ -395,7 +397,7 @@ namespace TagLib { * * \see fromUInt() */ - long long toLongLong(uint offset, bool mostSignificantByteFirst = true) const; + long long toLongLong(unsigned int offset, bool mostSignificantByteFirst = true) const; /* * Converts the 4 bytes at \a offset of the vector to a float as an IEEE754 @@ -446,7 +448,7 @@ namespace TagLib { * * \see toUInt() */ - static ByteVector fromUInt(uint value, bool mostSignificantByteFirst = true); + static ByteVector fromUInt(unsigned int value, bool mostSignificantByteFirst = true); /*! * Creates a 2 byte ByteVector based on \a value. If @@ -504,7 +506,7 @@ namespace TagLib { /*! * Returns a ByteVector based on the CString \a s. */ - static ByteVector fromCString(const char *s, uint length = 0xffffffff); + static ByteVector fromCString(const char *s, unsigned int length = 0xffffffff); /*! * Returns a const reference to the byte at \a index. @@ -600,7 +602,7 @@ namespace TagLib { ByteVector toBase64() const; /*! - * Decodes the base64 encoded byte vector. + * Decodes the base64 encoded byte vector. */ static ByteVector fromBase64(const ByteVector &); diff --git a/taglib/toolkit/tbytevectorlist.cpp b/taglib/toolkit/tbytevectorlist.cpp index 40e088d8..c4fdf593 100644 --- a/taglib/toolkit/tbytevectorlist.cpp +++ b/taglib/toolkit/tbytevectorlist.cpp @@ -47,7 +47,7 @@ ByteVectorList ByteVectorList::split(const ByteVector &v, const ByteVector &patt { ByteVectorList l; - uint previousOffset = 0; + unsigned int previousOffset = 0; for(int offset = v.find(pattern, 0, byteAlign); offset != -1 && (max == 0 || max > int(l.size()) + 1); offset = v.find(pattern, offset + pattern.size(), byteAlign)) diff --git a/taglib/toolkit/tbytevectorstream.cpp b/taglib/toolkit/tbytevectorstream.cpp index 90bee8e3..5e200b3d 100644 --- a/taglib/toolkit/tbytevectorstream.cpp +++ b/taglib/toolkit/tbytevectorstream.cpp @@ -80,7 +80,7 @@ ByteVector ByteVectorStream::readBlock(unsigned long length) void ByteVectorStream::writeBlock(const ByteVector &data) { - uint size = data.size(); + unsigned int size = data.size(); if(long(d->position + size) > length()) { truncate(d->position + size); } diff --git a/taglib/toolkit/tfile.cpp b/taglib/toolkit/tfile.cpp index 4e53f505..c634baa8 100644 --- a/taglib/toolkit/tfile.cpp +++ b/taglib/toolkit/tfile.cpp @@ -488,7 +488,7 @@ bool File::isWritable(const char *file) // protected members //////////////////////////////////////////////////////////////////////////////// -TagLib::uint File::bufferSize() +unsigned int File::bufferSize() { return 1024; } diff --git a/taglib/toolkit/tfile.h b/taglib/toolkit/tfile.h index 33288936..a6dda7ba 100644 --- a/taglib/toolkit/tfile.h +++ b/taglib/toolkit/tfile.h @@ -291,7 +291,7 @@ namespace TagLib { /*! * Returns the buffer size that is used for internal buffering. */ - static uint bufferSize(); + static unsigned int bufferSize(); private: File(const File &); diff --git a/taglib/toolkit/tfilestream.cpp b/taglib/toolkit/tfilestream.cpp index 200b7fec..e20412f2 100644 --- a/taglib/toolkit/tfilestream.cpp +++ b/taglib/toolkit/tfilestream.cpp @@ -186,10 +186,10 @@ ByteVector FileStream::readBlock(unsigned long length) if(length > bufferSize() && length > streamLength) length = streamLength; - ByteVector buffer(static_cast(length)); + ByteVector buffer(static_cast(length)); const size_t count = readFile(d->file, buffer); - buffer.resize(static_cast(count)); + buffer.resize(static_cast(count)); return buffer; } @@ -254,7 +254,7 @@ void FileStream::insert(const ByteVector &data, unsigned long start, unsigned lo long writePosition = start; ByteVector buffer = data; - ByteVector aboutToOverwrite(static_cast(bufferLength)); + ByteVector aboutToOverwrite(static_cast(bufferLength)); while(true) { @@ -303,7 +303,7 @@ void FileStream::removeBlock(unsigned long start, unsigned long length) long readPosition = start + length; long writePosition = start; - ByteVector buffer(static_cast(bufferLength)); + ByteVector buffer(static_cast(bufferLength)); for(size_t bytesRead = -1; bytesRead != 0;) { @@ -490,7 +490,7 @@ void FileStream::truncate(long length) #endif } -TagLib::uint FileStream::bufferSize() +unsigned int FileStream::bufferSize() { return 1024; } diff --git a/taglib/toolkit/tfilestream.h b/taglib/toolkit/tfilestream.h index a871032d..96a476d6 100644 --- a/taglib/toolkit/tfilestream.h +++ b/taglib/toolkit/tfilestream.h @@ -142,7 +142,7 @@ namespace TagLib { /*! * Returns the buffer size that is used for internal buffering. */ - static uint bufferSize(); + static unsigned int bufferSize(); private: class FileStreamPrivate; diff --git a/taglib/toolkit/tlist.h b/taglib/toolkit/tlist.h index 7375d752..6b4aa0a5 100644 --- a/taglib/toolkit/tlist.h +++ b/taglib/toolkit/tlist.h @@ -149,7 +149,7 @@ namespace TagLib { * * \see isEmpty() */ - uint size() const; + unsigned int size() const; /*! * Returns whether or not the list is empty. @@ -213,14 +213,14 @@ namespace TagLib { * * \warning This method is slow. Use iterators to loop through the list. */ - T &operator[](uint i); + T &operator[](unsigned int i); /*! * Returns a const reference to item \a i in the list. * * \warning This method is slow. Use iterators to loop through the list. */ - const T &operator[](uint i) const; + const T &operator[](unsigned int i) const; /*! * Make a shallow, implicitly shared, copy of \a l. Because this is diff --git a/taglib/toolkit/tlist.tcc b/taglib/toolkit/tlist.tcc index 5f8414ca..bf8b0007 100644 --- a/taglib/toolkit/tlist.tcc +++ b/taglib/toolkit/tlist.tcc @@ -194,7 +194,7 @@ List &List::clear() } template -TagLib::uint List::size() const +unsigned int List::size() const { return d->list.size(); } @@ -263,7 +263,7 @@ T &List::back() } template -T &List::operator[](uint i) +T &List::operator[](unsigned int i) { Iterator it = d->list.begin(); std::advance(it, i); @@ -272,7 +272,7 @@ T &List::operator[](uint i) } template -const T &List::operator[](uint i) const +const T &List::operator[](unsigned int i) const { ConstIterator it = d->list.begin(); std::advance(it, i); diff --git a/taglib/toolkit/tmap.h b/taglib/toolkit/tmap.h index a7d99303..c24c7636 100644 --- a/taglib/toolkit/tmap.h +++ b/taglib/toolkit/tmap.h @@ -119,7 +119,7 @@ namespace TagLib { * * \see isEmpty() */ - uint size() const; + unsigned int size() const; /*! * Returns true if the map is empty. diff --git a/taglib/toolkit/tmap.tcc b/taglib/toolkit/tmap.tcc index 8c1106df..68f0d311 100644 --- a/taglib/toolkit/tmap.tcc +++ b/taglib/toolkit/tmap.tcc @@ -150,7 +150,7 @@ Map &Map::erase(const Key &key) } template -TagLib::uint Map::size() const +unsigned int Map::size() const { return d->map.size(); } diff --git a/taglib/toolkit/tstring.cpp b/taglib/toolkit/tstring.cpp index 6ad80528..8a596e4c 100644 --- a/taglib/toolkit/tstring.cpp +++ b/taglib/toolkit/tstring.cpp @@ -234,7 +234,7 @@ public: StringPrivate() : RefCounter() {} - StringPrivate(uint n, wchar_t c) : + StringPrivate(unsigned int n, wchar_t c) : RefCounter(), data(static_cast(n), c) {} @@ -448,7 +448,7 @@ bool String::startsWith(const String &s) const return substr(0, s.length()) == s; } -String String::substr(uint position, uint n) const +String String::substr(unsigned int position, unsigned int n) const { return String(d->data.substr(position, n)); } @@ -482,12 +482,12 @@ String String::upper() const return s; } -TagLib::uint String::size() const +unsigned int String::size() const { return d->data.size(); } -TagLib::uint String::length() const +unsigned int String::length() const { return size(); } diff --git a/taglib/toolkit/tstring.h b/taglib/toolkit/tstring.h index 839b2f23..97e9ff66 100644 --- a/taglib/toolkit/tstring.h +++ b/taglib/toolkit/tstring.h @@ -291,7 +291,7 @@ namespace TagLib { * Extract a substring from this string starting at \a position and * continuing for \a n characters. */ - String substr(uint position, uint n = 0xffffffff) const; + String substr(unsigned int position, unsigned int n = 0xffffffff) const; /*! * Append \a s to the current string and return a reference to the current @@ -314,12 +314,12 @@ namespace TagLib { /*! * Returns the size of the string. */ - uint size() const; + unsigned int size() const; /*! * Returns the length of the string. Equivalent to size(). */ - uint length() const; + unsigned int length() const; /*! * Returns true if the string is empty. diff --git a/taglib/toolkit/tutils.h b/taglib/toolkit/tutils.h index 4e2c13ce..5b5bfd6e 100644 --- a/taglib/toolkit/tutils.h +++ b/taglib/toolkit/tutils.h @@ -95,7 +95,7 @@ namespace TagLib /*! * Reverses the order of bytes in an 32-bit integer. */ - inline uint byteSwap(uint x) + inline unsigned int byteSwap(unsigned int x) { #if defined(HAVE_BOOST_BYTESWAP) diff --git a/taglib/trueaudio/trueaudiofile.cpp b/taglib/trueaudio/trueaudiofile.cpp index 0ff3fa5e..7910c485 100644 --- a/taglib/trueaudio/trueaudiofile.cpp +++ b/taglib/trueaudio/trueaudiofile.cpp @@ -66,7 +66,7 @@ public: const ID3v2::FrameFactory *ID3v2FrameFactory; long ID3v2Location; - uint ID3v2OriginalSize; + unsigned int ID3v2OriginalSize; long ID3v1Location; diff --git a/taglib/trueaudio/trueaudioproperties.cpp b/taglib/trueaudio/trueaudioproperties.cpp index 17e3a2ab..0aab2419 100644 --- a/taglib/trueaudio/trueaudioproperties.cpp +++ b/taglib/trueaudio/trueaudioproperties.cpp @@ -54,7 +54,7 @@ public: int sampleRate; int channels; int bitsPerSample; - uint sampleFrames; + unsigned int sampleFrames; }; //////////////////////////////////////////////////////////////////////////////// @@ -108,7 +108,7 @@ int TrueAudio::Properties::channels() const return d->channels; } -TagLib::uint TrueAudio::Properties::sampleFrames() const +unsigned int TrueAudio::Properties::sampleFrames() const { return d->sampleFrames; } @@ -134,7 +134,7 @@ void TrueAudio::Properties::read(const ByteVector &data, long streamLength) return; } - uint pos = 3; + unsigned int pos = 3; d->version = data[pos] - '0'; pos += 1; diff --git a/taglib/trueaudio/trueaudioproperties.h b/taglib/trueaudio/trueaudioproperties.h index 4d8cd451..8dfcf375 100644 --- a/taglib/trueaudio/trueaudioproperties.h +++ b/taglib/trueaudio/trueaudioproperties.h @@ -38,7 +38,7 @@ namespace TagLib { class File; - static const uint HeaderSize = 18; + static const unsigned int HeaderSize = 18; //! An implementation of audio property reading for TrueAudio @@ -111,7 +111,7 @@ namespace TagLib { /*! * Returns the total number of sample frames */ - uint sampleFrames() const; + unsigned int sampleFrames() const; /*! * Returns the major version number. diff --git a/taglib/wavpack/wavpackfile.cpp b/taglib/wavpack/wavpackfile.cpp index f7c97f7e..e7b7049e 100644 --- a/taglib/wavpack/wavpackfile.cpp +++ b/taglib/wavpack/wavpackfile.cpp @@ -64,7 +64,7 @@ public: } long APELocation; - uint APESize; + unsigned int APESize; long ID3v1Location; diff --git a/taglib/wavpack/wavpackproperties.cpp b/taglib/wavpack/wavpackproperties.cpp index 12d47c44..c1d04fd2 100644 --- a/taglib/wavpack/wavpackproperties.cpp +++ b/taglib/wavpack/wavpackproperties.cpp @@ -58,7 +58,7 @@ public: int version; int bitsPerSample; bool lossless; - uint sampleFrames; + unsigned int sampleFrames; }; //////////////////////////////////////////////////////////////////////////////// @@ -129,7 +129,7 @@ bool WavPack::Properties::isLossless() const return d->lossless; } -TagLib::uint WavPack::Properties::sampleFrames() const +unsigned int WavPack::Properties::sampleFrames() const { return d->sampleFrames; } @@ -178,7 +178,7 @@ void WavPack::Properties::read(File *file, long streamLength) break; } - const uint flags = data.toUInt(24, false); + const unsigned int flags = data.toUInt(24, false); if(offset == 0) { d->version = data.toShort(8, false); @@ -196,7 +196,7 @@ void WavPack::Properties::read(File *file, long streamLength) if(flags & FINAL_BLOCK) break; - const uint blockSize = data.toUInt(4, false); + const unsigned int blockSize = data.toUInt(4, false); offset += blockSize + 8; } @@ -210,7 +210,7 @@ void WavPack::Properties::read(File *file, long streamLength) } } -TagLib::uint WavPack::Properties::seekFinalIndex(File *file, long streamLength) +unsigned int WavPack::Properties::seekFinalIndex(File *file, long streamLength) { const long offset = file->rfind("wvpk", streamLength); if(offset == -1) @@ -225,12 +225,12 @@ TagLib::uint WavPack::Properties::seekFinalIndex(File *file, long streamLength) if(version < MIN_STREAM_VERS || version > MAX_STREAM_VERS) return 0; - const uint flags = data.toUInt(24, false); + const unsigned int flags = data.toUInt(24, false); if(!(flags & FINAL_BLOCK)) return 0; - const uint blockIndex = data.toUInt(16, false); - const uint blockSamples = data.toUInt(20, false); + const unsigned int blockIndex = data.toUInt(16, false); + const unsigned int blockSamples = data.toUInt(20, false); return blockIndex + blockSamples; } diff --git a/taglib/wavpack/wavpackproperties.h b/taglib/wavpack/wavpackproperties.h index 2955b1d8..0f5d1dcb 100644 --- a/taglib/wavpack/wavpackproperties.h +++ b/taglib/wavpack/wavpackproperties.h @@ -39,7 +39,7 @@ namespace TagLib { class File; - static const uint HeaderSize = 32; + static const unsigned int HeaderSize = 32; //! An implementation of audio property reading for WavPack @@ -126,7 +126,7 @@ namespace TagLib { /*! * Returns the total number of audio samples in file. */ - uint sampleFrames() const; + unsigned int sampleFrames() const; /*! * Returns WavPack version. @@ -138,7 +138,7 @@ namespace TagLib { Properties &operator=(const Properties &); void read(File *file, long streamLength); - uint seekFinalIndex(File *file, long streamLength); + unsigned int seekFinalIndex(File *file, long streamLength); class PropertiesPrivate; PropertiesPrivate *d; diff --git a/taglib/xm/xmfile.cpp b/taglib/xm/xmfile.cpp index 7def0c09..0a3b950e 100644 --- a/taglib/xm/xmfile.cpp +++ b/taglib/xm/xmfile.cpp @@ -30,7 +30,6 @@ using namespace TagLib; using namespace XM; -using TagLib::uint; /*! * The Reader classes are helpers to make handling of the stripped XM @@ -72,35 +71,35 @@ public: * Reads associated values from \a file, but never reads more * then \a limit bytes. */ - virtual uint read(TagLib::File &file, uint limit) = 0; + virtual unsigned int read(TagLib::File &file, unsigned int limit) = 0; /*! * Returns the number of bytes this reader would like to read. */ - virtual uint size() const = 0; + virtual unsigned int size() const = 0; }; class SkipReader : public Reader { public: - SkipReader(uint size) : m_size(size) + SkipReader(unsigned int size) : m_size(size) { } - uint read(TagLib::File &file, uint limit) + unsigned int read(TagLib::File &file, unsigned int limit) { - uint count = std::min(m_size, limit); + unsigned int count = std::min(m_size, limit); file.seek(count, TagLib::File::Current); return count; } - uint size() const + unsigned int size() const { return m_size; } private: - uint m_size; + unsigned int m_size; }; template @@ -118,15 +117,15 @@ protected: class StringReader : public ValueReader { public: - StringReader(String &string, uint size) : + StringReader(String &string, unsigned int size) : ValueReader(string), m_size(size) { } - uint read(TagLib::File &file, uint limit) + unsigned int read(TagLib::File &file, unsigned int limit) { ByteVector data = file.readBlock(std::min(m_size, limit)); - uint count = data.size(); + unsigned int count = data.size(); int index = data.find((char) 0); if(index > -1) { data.resize(index); @@ -136,13 +135,13 @@ public: return count; } - uint size() const + unsigned int size() const { return m_size; } private: - uint m_size; + unsigned int m_size; }; class ByteReader : public ValueReader @@ -150,7 +149,7 @@ class ByteReader : public ValueReader public: ByteReader(unsigned char &byte) : ValueReader(byte) {} - uint read(TagLib::File &file, uint limit) + unsigned int read(TagLib::File &file, unsigned int limit) { ByteVector data = file.readBlock(std::min(1U,limit)); if(data.size() > 0) { @@ -159,7 +158,7 @@ public: return data.size(); } - uint size() const + unsigned int size() const { return 1; } @@ -184,14 +183,14 @@ public: U16Reader(unsigned short &value, bool bigEndian) : NumberReader(value, bigEndian) {} - uint read(TagLib::File &file, uint limit) + unsigned int read(TagLib::File &file, unsigned int limit) { ByteVector data = file.readBlock(std::min(2U,limit)); value = data.toUShort(bigEndian); return data.size(); } - uint size() const + unsigned int size() const { return 2; } @@ -205,14 +204,14 @@ public: { } - uint read(TagLib::File &file, uint limit) + unsigned int read(TagLib::File &file, unsigned int limit) { ByteVector data = file.readBlock(std::min(4U,limit)); value = data.toUInt(bigEndian); return data.size(); } - uint size() const + unsigned int size() const { return 4; } @@ -238,7 +237,7 @@ public: /*! * Don't read anything but skip \a size bytes. */ - StructReader &skip(uint size) + StructReader &skip(unsigned int size) { m_readers.append(new SkipReader(size)); return *this; @@ -247,7 +246,7 @@ public: /*! * Read a string of \a size characters (bytes) into \a string. */ - StructReader &string(String &string, uint size) + StructReader &string(String &string, unsigned int size) { m_readers.append(new StringReader(string, size)); return *this; @@ -314,9 +313,9 @@ public: return u32(number, true); } - uint size() const + unsigned int size() const { - uint size = 0; + unsigned int size = 0; for(List::ConstIterator i = m_readers.begin(); i != m_readers.end(); ++ i) { size += (*i)->size(); @@ -324,12 +323,12 @@ public: return size; } - uint read(TagLib::File &file, uint limit) + unsigned int read(TagLib::File &file, unsigned int limit) { - uint sumcount = 0; + unsigned int sumcount = 0; for(List::ConstIterator i = m_readers.begin(); limit > 0 && i != m_readers.end(); ++ i) { - uint count = (*i)->read(file, limit); + unsigned int count = (*i)->read(file, limit); limit -= count; sumcount += count; } @@ -437,7 +436,7 @@ bool XM::File::save() } const StringList lines = d->tag.comment().split("\n"); - uint sampleNameIndex = instrumentCount; + unsigned int sampleNameIndex = instrumentCount; for(unsigned short i = 0; i < instrumentCount; ++ i) { seek(pos); unsigned long instrumentHeaderSize = 0; @@ -445,7 +444,7 @@ bool XM::File::save() return false; seek(pos + 4); - const uint len = std::min(22UL, instrumentHeaderSize - 4U); + const unsigned int len = std::min(22UL, instrumentHeaderSize - 4U); if(i >= lines.size()) writeString(String(), len); else @@ -476,7 +475,7 @@ bool XM::File::save() if(sampleHeaderSize > 18U) { seek(pos + 18); - const uint len = std::min(sampleHeaderSize - 18U, 22UL); + const unsigned int len = std::min(sampleHeaderSize - 18U, 22UL); if(sampleNameIndex >= lines.size()) writeString(String(), len); else @@ -530,8 +529,8 @@ void XM::File::read(bool) .u16L(tempo) .u16L(bpmSpeed); - uint count = header.read(*this, headerSize - 4U); - uint size = std::min(headerSize - 4U, (unsigned long)header.size()); + unsigned int count = header.read(*this, headerSize - 4U); + unsigned int size = std::min(headerSize - 4U, (unsigned long)header.size()); READ_ASSERT(count == size); @@ -557,7 +556,7 @@ void XM::File::read(bool) StructReader pattern; pattern.byte(packingType).u16L(rowCount).u16L(dataSize); - uint count = pattern.read(*this, patternHeaderLength - 4U); + unsigned int count = pattern.read(*this, patternHeaderLength - 4U); READ_ASSERT(count == std::min(patternHeaderLength - 4U, (unsigned long)pattern.size())); seek(patternHeaderLength - (4 + count) + dataSize, Current); @@ -565,7 +564,7 @@ void XM::File::read(bool) StringList intrumentNames; StringList sampleNames; - uint sumSampleCount = 0; + unsigned int sumSampleCount = 0; // read instruments: for(unsigned short i = 0; i < instrumentCount; ++ i) { @@ -580,7 +579,7 @@ void XM::File::read(bool) instrument.string(instrumentName, 22).byte(instrumentType).u16L(sampleCount); // 4 for instrumentHeaderSize - uint count = 4 + instrument.read(*this, instrumentHeaderSize - 4U); + unsigned int count = 4 + instrument.read(*this, instrumentHeaderSize - 4U); READ_ASSERT(count == std::min(instrumentHeaderSize, (unsigned long)instrument.size() + 4)); unsigned long sampleHeaderSize = 0; @@ -615,7 +614,7 @@ void XM::File::read(bool) .byte(compression) .string(sampleName, 22); - uint count = sample.read(*this, sampleHeaderSize); + unsigned int count = sample.read(*this, sampleHeaderSize); READ_ASSERT(count == std::min(sampleHeaderSize, (unsigned long)sample.size())); // skip unhandeled header proportion: seek(sampleHeaderSize - count, Current); diff --git a/taglib/xm/xmproperties.cpp b/taglib/xm/xmproperties.cpp index 9a7fa6b2..5002a4e5 100644 --- a/taglib/xm/xmproperties.cpp +++ b/taglib/xm/xmproperties.cpp @@ -47,7 +47,7 @@ public: unsigned short restartPosition; unsigned short patternCount; unsigned short instrumentCount; - uint sampleCount; + unsigned int sampleCount; unsigned short flags; unsigned short tempo; unsigned short bpmSpeed; @@ -119,7 +119,7 @@ unsigned short XM::Properties::instrumentCount() const return d->instrumentCount; } -TagLib::uint XM::Properties::sampleCount() const +unsigned int XM::Properties::sampleCount() const { return d->sampleCount; } @@ -169,7 +169,7 @@ void XM::Properties::setInstrumentCount(unsigned short instrumentCount) d->instrumentCount = instrumentCount; } -void XM::Properties::setSampleCount(uint sampleCount) +void XM::Properties::setSampleCount(unsigned int sampleCount) { d->sampleCount = sampleCount; } diff --git a/taglib/xm/xmproperties.h b/taglib/xm/xmproperties.h index 4fdf8b4b..db948815 100644 --- a/taglib/xm/xmproperties.h +++ b/taglib/xm/xmproperties.h @@ -51,7 +51,7 @@ namespace TagLib { unsigned short restartPosition() const; unsigned short patternCount() const; unsigned short instrumentCount() const; - uint sampleCount() const; + unsigned int sampleCount() const; unsigned short flags() const; unsigned short tempo() const; unsigned short bpmSpeed() const; @@ -63,7 +63,7 @@ namespace TagLib { void setRestartPosition(unsigned short restartPosition); void setPatternCount(unsigned short patternCount); void setInstrumentCount(unsigned short instrumentCount); - void setSampleCount(uint sampleCount); + void setSampleCount(unsigned int sampleCount); void setFlags(unsigned short flags); void setTempo(unsigned short tempo); void setBpmSpeed(unsigned short bpmSpeed); diff --git a/tests/test_apetag.cpp b/tests/test_apetag.cpp index 42475766..71d0be26 100644 --- a/tests/test_apetag.cpp +++ b/tests/test_apetag.cpp @@ -78,7 +78,7 @@ public: APE::Item item3 = APE::Item("TRACKNUMBER", "29"); tag.setItem("TRACKNUMBER", item3); properties = tag.properties(); - CPPUNIT_ASSERT_EQUAL(TagLib::uint(2), properties["TRACKNUMBER"].size()); + CPPUNIT_ASSERT_EQUAL((unsigned int)2, properties["TRACKNUMBER"].size()); CPPUNIT_ASSERT_EQUAL(String("17"), properties["TRACKNUMBER"][0]); CPPUNIT_ASSERT_EQUAL(String("29"), properties["TRACKNUMBER"][1]); @@ -94,7 +94,7 @@ public: APE::Tag tag; PropertyMap unsuccessful = tag.setProperties(properties); - CPPUNIT_ASSERT_EQUAL(TagLib::uint(2), unsuccessful.size()); + CPPUNIT_ASSERT_EQUAL((unsigned int)2, unsuccessful.size()); CPPUNIT_ASSERT(unsuccessful.contains("A")); CPPUNIT_ASSERT(unsuccessful.contains("MP+")); } diff --git a/tests/test_asf.cpp b/tests/test_asf.cpp index 2dfcb64d..0098fdc3 100644 --- a/tests/test_asf.cpp +++ b/tests/test_asf.cpp @@ -105,7 +105,7 @@ public: CPPUNIT_ASSERT(f.tag()->contains("WM/TrackNumber")); CPPUNIT_ASSERT_EQUAL(ASF::Attribute::DWordType, f.tag()->attribute("WM/TrackNumber").front().type()); - CPPUNIT_ASSERT_EQUAL(TagLib::uint(123), f.tag()->track()); + CPPUNIT_ASSERT_EQUAL((unsigned int)123, f.tag()->track()); f.tag()->setTrack(234); f.save(); } @@ -114,7 +114,7 @@ public: CPPUNIT_ASSERT(f.tag()->contains("WM/TrackNumber")); CPPUNIT_ASSERT_EQUAL(ASF::Attribute::UnicodeType, f.tag()->attribute("WM/TrackNumber").front().type()); - CPPUNIT_ASSERT_EQUAL(TagLib::uint(234), f.tag()->track()); + CPPUNIT_ASSERT_EQUAL((unsigned int)234, f.tag()->track()); } } @@ -193,7 +193,7 @@ public: { ASF::File f(newname.c_str()); ASF::AttributeList values2 = f.tag()->attribute("WM/Picture"); - CPPUNIT_ASSERT_EQUAL(TagLib::uint(1), values2.size()); + CPPUNIT_ASSERT_EQUAL((unsigned int)1, values2.size()); ASF::Attribute attr2 = values2.front(); ASF::Picture picture2 = attr2.toPicture(); CPPUNIT_ASSERT(picture2.isValid()); @@ -230,7 +230,7 @@ public: { ASF::File f(newname.c_str()); ASF::AttributeList values2 = f.tag()->attribute("WM/Picture"); - CPPUNIT_ASSERT_EQUAL(TagLib::uint(2), values2.size()); + CPPUNIT_ASSERT_EQUAL((unsigned int)2, values2.size()); ASF::Picture picture3 = values2[1].toPicture(); CPPUNIT_ASSERT(picture3.isValid()); CPPUNIT_ASSERT_EQUAL(String("image/jpeg"), picture3.mimeType()); diff --git a/tests/test_bytevector.cpp b/tests/test_bytevector.cpp index 5d82fedb..9ff71272 100644 --- a/tests/test_bytevector.cpp +++ b/tests/test_bytevector.cpp @@ -350,24 +350,24 @@ public: ByteVector a = ByteVector("0123456789"); ByteVector b = a.mid(3, 4); b.resize(6, 'A'); - CPPUNIT_ASSERT_EQUAL(TagLib::uint(6), b.size()); + CPPUNIT_ASSERT_EQUAL((unsigned int)6, b.size()); CPPUNIT_ASSERT_EQUAL('6', b[3]); CPPUNIT_ASSERT_EQUAL('A', b[4]); CPPUNIT_ASSERT_EQUAL('A', b[5]); b.resize(10, 'B'); - CPPUNIT_ASSERT_EQUAL(TagLib::uint(10), b.size()); + CPPUNIT_ASSERT_EQUAL((unsigned int)10, b.size()); CPPUNIT_ASSERT_EQUAL('6', b[3]); CPPUNIT_ASSERT_EQUAL('B', b[6]); CPPUNIT_ASSERT_EQUAL('B', b[9]); b.resize(3, 'C'); - CPPUNIT_ASSERT_EQUAL(TagLib::uint(3), b.size()); + CPPUNIT_ASSERT_EQUAL((unsigned int)3, b.size()); CPPUNIT_ASSERT_EQUAL(-1, b.find('C')); b.resize(3); - CPPUNIT_ASSERT_EQUAL(TagLib::uint(3), b.size()); + CPPUNIT_ASSERT_EQUAL((unsigned int)3, b.size()); // Check if a and b were properly detached. - CPPUNIT_ASSERT_EQUAL(TagLib::uint(10), a.size()); + CPPUNIT_ASSERT_EQUAL((unsigned int)10, a.size()); CPPUNIT_ASSERT_EQUAL('3', a[3]); CPPUNIT_ASSERT_EQUAL('5', a[5]); @@ -375,17 +375,17 @@ public: ByteVector c = ByteVector("0123456789").mid(3, 4); c.resize(6, 'A'); - CPPUNIT_ASSERT_EQUAL(TagLib::uint(6), c.size()); + CPPUNIT_ASSERT_EQUAL((unsigned int)6, c.size()); CPPUNIT_ASSERT_EQUAL('6', c[3]); CPPUNIT_ASSERT_EQUAL('A', c[4]); CPPUNIT_ASSERT_EQUAL('A', c[5]); c.resize(10, 'B'); - CPPUNIT_ASSERT_EQUAL(TagLib::uint(10), c.size()); + CPPUNIT_ASSERT_EQUAL((unsigned int)10, c.size()); CPPUNIT_ASSERT_EQUAL('6', c[3]); CPPUNIT_ASSERT_EQUAL('B', c[6]); CPPUNIT_ASSERT_EQUAL('B', c[9]); c.resize(3, 'C'); - CPPUNIT_ASSERT_EQUAL(TagLib::uint(3), c.size()); + CPPUNIT_ASSERT_EQUAL((unsigned int)3, c.size()); CPPUNIT_ASSERT_EQUAL(-1, c.find('C')); } @@ -439,7 +439,7 @@ public: CPPUNIT_ASSERT_EQUAL(t2, ByteVector::fromBase64(s2.toBase64())); CPPUNIT_ASSERT_EQUAL(t3, ByteVector::fromBase64(s3.toBase64())); - ByteVector all((uint)256); + ByteVector all((unsigned int)256); // in order { diff --git a/tests/test_bytevectorlist.cpp b/tests/test_bytevectorlist.cpp index 7e4a9fd7..ff5ef2fe 100644 --- a/tests/test_bytevectorlist.cpp +++ b/tests/test_bytevectorlist.cpp @@ -19,7 +19,7 @@ public: ByteVector v("a b"); ByteVectorList l = ByteVectorList::split(v, " "); - CPPUNIT_ASSERT_EQUAL(TagLib::uint(2), l.size()); + CPPUNIT_ASSERT_EQUAL((unsigned int)2, l.size()); CPPUNIT_ASSERT_EQUAL(ByteVector("a"), l[0]); CPPUNIT_ASSERT_EQUAL(ByteVector("b"), l[1]); } @@ -29,7 +29,7 @@ public: ByteVector v("a"); ByteVectorList l = ByteVectorList::split(v, " "); - CPPUNIT_ASSERT_EQUAL(TagLib::uint(1), l.size()); + CPPUNIT_ASSERT_EQUAL((unsigned int)1, l.size()); CPPUNIT_ASSERT_EQUAL(ByteVector("a"), l[0]); } diff --git a/tests/test_file.cpp b/tests/test_file.cpp index a19bce89..5c4aaa0f 100644 --- a/tests/test_file.cpp +++ b/tests/test_file.cpp @@ -65,7 +65,7 @@ public: file.seek(0); const ByteVector v = file.readBlock(file.length()); - CPPUNIT_ASSERT_EQUAL((TagLib::uint)10, v.size()); + CPPUNIT_ASSERT_EQUAL((unsigned int)10, v.size()); CPPUNIT_ASSERT_EQUAL((long)v.find("23"), file.find("23")); CPPUNIT_ASSERT_EQUAL((long)v.find("23", 2), file.find("23", 2)); @@ -93,7 +93,7 @@ public: file.seek(0); const ByteVector v = file.readBlock(file.length()); - CPPUNIT_ASSERT_EQUAL((TagLib::uint)10, v.size()); + CPPUNIT_ASSERT_EQUAL((unsigned int)10, v.size()); CPPUNIT_ASSERT_EQUAL((long)v.rfind("23"), file.rfind("23")); CPPUNIT_ASSERT_EQUAL((long)v.rfind("23", 7), file.rfind("23", 7)); diff --git a/tests/test_fileref.cpp b/tests/test_fileref.cpp index 88f711a7..d7945e48 100644 --- a/tests/test_fileref.cpp +++ b/tests/test_fileref.cpp @@ -71,8 +71,8 @@ public: CPPUNIT_ASSERT_EQUAL(f.tag()->title(), String("test title")); CPPUNIT_ASSERT_EQUAL(f.tag()->genre(), String("Test!")); CPPUNIT_ASSERT_EQUAL(f.tag()->album(), String("albummmm")); - CPPUNIT_ASSERT_EQUAL(f.tag()->track(), TagLib::uint(5)); - CPPUNIT_ASSERT_EQUAL(f.tag()->year(), TagLib::uint(2020)); + CPPUNIT_ASSERT_EQUAL(f.tag()->track(), (unsigned int)5); + CPPUNIT_ASSERT_EQUAL(f.tag()->year(), (unsigned int)2020); f.tag()->setArtist("ttest artist"); f.tag()->setTitle("ytest title"); f.tag()->setGenre("uTest!"); @@ -88,8 +88,8 @@ public: CPPUNIT_ASSERT_EQUAL(f.tag()->title(), String("ytest title")); CPPUNIT_ASSERT_EQUAL(f.tag()->genre(), String("uTest!")); CPPUNIT_ASSERT_EQUAL(f.tag()->album(), String("ialbummmm")); - CPPUNIT_ASSERT_EQUAL(f.tag()->track(), TagLib::uint(7)); - CPPUNIT_ASSERT_EQUAL(f.tag()->year(), TagLib::uint(2080)); + CPPUNIT_ASSERT_EQUAL(f.tag()->track(), (unsigned int)7); + CPPUNIT_ASSERT_EQUAL(f.tag()->year(), (unsigned int)2080); } { FileStream fs(newname.c_str()); @@ -99,8 +99,8 @@ public: CPPUNIT_ASSERT_EQUAL(f.tag()->title(), String("ytest title")); CPPUNIT_ASSERT_EQUAL(f.tag()->genre(), String("uTest!")); CPPUNIT_ASSERT_EQUAL(f.tag()->album(), String("ialbummmm")); - CPPUNIT_ASSERT_EQUAL(f.tag()->track(), TagLib::uint(7)); - CPPUNIT_ASSERT_EQUAL(f.tag()->year(), TagLib::uint(2080)); + CPPUNIT_ASSERT_EQUAL(f.tag()->track(), (unsigned int)7); + CPPUNIT_ASSERT_EQUAL(f.tag()->year(), (unsigned int)2080); } } diff --git a/tests/test_flac.cpp b/tests/test_flac.cpp index 9fdd51e1..8ab81c86 100644 --- a/tests/test_flac.cpp +++ b/tests/test_flac.cpp @@ -63,7 +63,7 @@ public: FLAC::File f(newname.c_str()); List lst = f.pictureList(); - CPPUNIT_ASSERT_EQUAL(TagLib::uint(1), lst.size()); + CPPUNIT_ASSERT_EQUAL((unsigned int)1, lst.size()); FLAC::Picture *pic = lst.front(); CPPUNIT_ASSERT_EQUAL(FLAC::Picture::FrontCover, pic->type()); @@ -73,7 +73,7 @@ public: CPPUNIT_ASSERT_EQUAL(0, pic->numColors()); CPPUNIT_ASSERT_EQUAL(String("image/png"), pic->mimeType()); CPPUNIT_ASSERT_EQUAL(String("A pixel."), pic->description()); - CPPUNIT_ASSERT_EQUAL(TagLib::uint(150), pic->data().size()); + CPPUNIT_ASSERT_EQUAL((unsigned int)150, pic->data().size()); } void testAddPicture() @@ -84,7 +84,7 @@ public: { FLAC::File f(newname.c_str()); List lst = f.pictureList(); - CPPUNIT_ASSERT_EQUAL(TagLib::uint(1), lst.size()); + CPPUNIT_ASSERT_EQUAL((unsigned int)1, lst.size()); FLAC::Picture *newpic = new FLAC::Picture(); newpic->setType(FLAC::Picture::BackCover); @@ -101,7 +101,7 @@ public: { FLAC::File f(newname.c_str()); List lst = f.pictureList(); - CPPUNIT_ASSERT_EQUAL(TagLib::uint(2), lst.size()); + CPPUNIT_ASSERT_EQUAL((unsigned int)2, lst.size()); FLAC::Picture *pic = lst[0]; CPPUNIT_ASSERT_EQUAL(FLAC::Picture::FrontCover, pic->type()); @@ -111,7 +111,7 @@ public: CPPUNIT_ASSERT_EQUAL(0, pic->numColors()); CPPUNIT_ASSERT_EQUAL(String("image/png"), pic->mimeType()); CPPUNIT_ASSERT_EQUAL(String("A pixel."), pic->description()); - CPPUNIT_ASSERT_EQUAL(TagLib::uint(150), pic->data().size()); + CPPUNIT_ASSERT_EQUAL((unsigned int)150, pic->data().size()); pic = lst[1]; CPPUNIT_ASSERT_EQUAL(FLAC::Picture::BackCover, pic->type()); @@ -133,7 +133,7 @@ public: { FLAC::File f(newname.c_str()); List lst = f.pictureList(); - CPPUNIT_ASSERT_EQUAL(TagLib::uint(1), lst.size()); + CPPUNIT_ASSERT_EQUAL((unsigned int)1, lst.size()); FLAC::Picture *newpic = new FLAC::Picture(); newpic->setType(FLAC::Picture::BackCover); @@ -151,7 +151,7 @@ public: { FLAC::File f(newname.c_str()); List lst = f.pictureList(); - CPPUNIT_ASSERT_EQUAL(TagLib::uint(1), lst.size()); + CPPUNIT_ASSERT_EQUAL((unsigned int)1, lst.size()); FLAC::Picture *pic = lst[0]; CPPUNIT_ASSERT_EQUAL(FLAC::Picture::BackCover, pic->type()); @@ -173,7 +173,7 @@ public: { FLAC::File f(newname.c_str()); List lst = f.pictureList(); - CPPUNIT_ASSERT_EQUAL(TagLib::uint(1), lst.size()); + CPPUNIT_ASSERT_EQUAL((unsigned int)1, lst.size()); f.removePictures(); f.save(); @@ -181,7 +181,7 @@ public: { FLAC::File f(newname.c_str()); List lst = f.pictureList(); - CPPUNIT_ASSERT_EQUAL(TagLib::uint(0), lst.size()); + CPPUNIT_ASSERT_EQUAL((unsigned int)0, lst.size()); } } @@ -220,7 +220,7 @@ public: { FLAC::File f(newname.c_str()); Ogg::FieldListMap m = f.xiphComment()->fieldListMap(); - CPPUNIT_ASSERT_EQUAL(TagLib::uint(2), m["ARTIST"].size()); + CPPUNIT_ASSERT_EQUAL((unsigned int)2, m["ARTIST"].size()); CPPUNIT_ASSERT_EQUAL(String("artist 1"), m["ARTIST"][0]); CPPUNIT_ASSERT_EQUAL(String("artist 2"), m["ARTIST"][1]); } @@ -243,7 +243,7 @@ public: { FLAC::File f(newname.c_str()); PropertyMap dict = f.properties(); - CPPUNIT_ASSERT_EQUAL(TagLib::uint(2), dict["ARTIST"].size()); + CPPUNIT_ASSERT_EQUAL((unsigned int)2, dict["ARTIST"].size()); CPPUNIT_ASSERT_EQUAL(String("artøst 1"), dict["ARTIST"][0]); CPPUNIT_ASSERT_EQUAL(String("artöst 2"), dict["ARTIST"][1]); } @@ -256,8 +256,8 @@ public: map[L"H\x00c4\x00d6"] = String("bla"); FLAC::File f(copy.fileName().c_str()); PropertyMap invalid = f.setProperties(map); - CPPUNIT_ASSERT_EQUAL(TagLib::uint(1), invalid.size()); - CPPUNIT_ASSERT_EQUAL(TagLib::uint(0), f.properties().size()); + CPPUNIT_ASSERT_EQUAL((unsigned int)1, invalid.size()); + CPPUNIT_ASSERT_EQUAL((unsigned int)0, f.properties().size()); } void testAudioProperties() diff --git a/tests/test_flacpicture.cpp b/tests/test_flacpicture.cpp index eefa9306..c5043d2f 100644 --- a/tests/test_flacpicture.cpp +++ b/tests/test_flacpicture.cpp @@ -34,7 +34,7 @@ public: CPPUNIT_ASSERT_EQUAL(0, pic.numColors()); CPPUNIT_ASSERT_EQUAL(String("image/png"), pic.mimeType()); CPPUNIT_ASSERT_EQUAL(String("A pixel."), pic.description()); - CPPUNIT_ASSERT_EQUAL(TagLib::uint(150), pic.data().size()); + CPPUNIT_ASSERT_EQUAL((unsigned int)150, pic.data().size()); } void testPassThrough() diff --git a/tests/test_id3v2.cpp b/tests/test_id3v2.cpp index fe188505..28fa467f 100644 --- a/tests/test_id3v2.cpp +++ b/tests/test_id3v2.cpp @@ -204,7 +204,7 @@ public: "d\x00" "\x00", 14); ID3v2::AttachedPictureFrame *frame = - static_cast(factory->createFrame(data, TagLib::uint(2))); + static_cast(factory->createFrame(data, (unsigned int)2)); CPPUNIT_ASSERT(frame); CPPUNIT_ASSERT_EQUAL(String("image/jpeg"), frame->mimeType()); @@ -225,13 +225,13 @@ public: "d\x00" "\x00", 14); ID3v2::AttachedPictureFrame *frame = - static_cast(factory->createFrame(data, TagLib::uint(2))); + static_cast(factory->createFrame(data, (unsigned int)2)); CPPUNIT_ASSERT(frame); ID3v2::Tag tag; tag.addFrame(frame); - CPPUNIT_ASSERT_EQUAL(TagLib::uint(1034), tag.render().size()); + CPPUNIT_ASSERT_EQUAL((unsigned int)1034, tag.render().size()); } // http://bugs.kde.org/show_bug.cgi?id=151078 @@ -260,7 +260,7 @@ public: "\x00\x00\x00\x03", 33)); CPPUNIT_ASSERT_EQUAL(String("email@example.com"), f.email()); CPPUNIT_ASSERT_EQUAL(2, f.rating()); - CPPUNIT_ASSERT_EQUAL(TagLib::uint(3), f.counter()); + CPPUNIT_ASSERT_EQUAL((unsigned int)3, f.counter()); } void testParsePOPMWithoutCounter() @@ -272,7 +272,7 @@ public: "\x02", 29)); CPPUNIT_ASSERT_EQUAL(String("email@example.com"), f.email()); CPPUNIT_ASSERT_EQUAL(2, f.rating()); - CPPUNIT_ASSERT_EQUAL(TagLib::uint(0), f.counter()); + CPPUNIT_ASSERT_EQUAL((unsigned int)0, f.counter()); } void testRenderPOPM() @@ -476,11 +476,11 @@ public: CPPUNIT_ASSERT_EQUAL(ID3v2::SynchronizedLyricsFrame::Lyrics, f.type()); CPPUNIT_ASSERT_EQUAL(String("foo"), f.description()); ID3v2::SynchronizedLyricsFrame::SynchedTextList stl = f.synchedText(); - CPPUNIT_ASSERT_EQUAL(TagLib::uint(2), stl.size()); + CPPUNIT_ASSERT_EQUAL((unsigned int)2, stl.size()); CPPUNIT_ASSERT_EQUAL(String("Example"), stl[0].text); - CPPUNIT_ASSERT_EQUAL(TagLib::uint(1234), stl[0].time); + CPPUNIT_ASSERT_EQUAL((unsigned int)1234, stl[0].time); CPPUNIT_ASSERT_EQUAL(String("Lyrics"), stl[1].text); - CPPUNIT_ASSERT_EQUAL(TagLib::uint(4567), stl[1].time); + CPPUNIT_ASSERT_EQUAL((unsigned int)4567, stl[1].time); } void testRenderSynchronizedLyricsFrame() @@ -525,11 +525,11 @@ public: CPPUNIT_ASSERT_EQUAL(ID3v2::EventTimingCodesFrame::AbsoluteMilliseconds, f.timestampFormat()); ID3v2::EventTimingCodesFrame::SynchedEventList sel = f.synchedEvents(); - CPPUNIT_ASSERT_EQUAL(TagLib::uint(2), sel.size()); + CPPUNIT_ASSERT_EQUAL((unsigned int)2, sel.size()); CPPUNIT_ASSERT_EQUAL(ID3v2::EventTimingCodesFrame::IntroStart, sel[0].type); - CPPUNIT_ASSERT_EQUAL(TagLib::uint(62300), sel[0].time); + CPPUNIT_ASSERT_EQUAL((unsigned int)62300, sel[0].time); CPPUNIT_ASSERT_EQUAL(ID3v2::EventTimingCodesFrame::AudioFileEnds, sel[1].type); - CPPUNIT_ASSERT_EQUAL(TagLib::uint(3600000), sel[1].time); + CPPUNIT_ASSERT_EQUAL((unsigned int)3600000, sel[1].time); } void testRenderEventTimingCodesFrame() @@ -589,8 +589,8 @@ public: "\x00" // Encoding "(22)Death Metal", 26); // Text ID3v2::TextIdentificationFrame *frame = - static_cast(factory->createFrame(data, TagLib::uint(3))); - CPPUNIT_ASSERT_EQUAL(TagLib::uint(1), frame->fieldList().size()); + static_cast(factory->createFrame(data, (unsigned int)3)); + CPPUNIT_ASSERT_EQUAL((unsigned int)1, frame->fieldList().size()); CPPUNIT_ASSERT_EQUAL(String("Death Metal"), frame->fieldList()[0]); ID3v2::Tag tag; @@ -608,8 +608,8 @@ public: "\x00" // Encoding "(4)Eurodisco", 23); // Text ID3v2::TextIdentificationFrame *frame = - static_cast(factory->createFrame(data, TagLib::uint(3))); - CPPUNIT_ASSERT_EQUAL(TagLib::uint(2), frame->fieldList().size()); + static_cast(factory->createFrame(data, (unsigned int)3)); + CPPUNIT_ASSERT_EQUAL((unsigned int)2, frame->fieldList().size()); CPPUNIT_ASSERT_EQUAL(String("4"), frame->fieldList()[0]); CPPUNIT_ASSERT_EQUAL(String("Eurodisco"), frame->fieldList()[1]); @@ -627,8 +627,8 @@ public: "\0" // Encoding "14\0Eurodisco", 23); // Text ID3v2::TextIdentificationFrame *frame = - static_cast(factory->createFrame(data, TagLib::uint(4))); - CPPUNIT_ASSERT_EQUAL(TagLib::uint(2), frame->fieldList().size()); + static_cast(factory->createFrame(data, (unsigned int)4)); + CPPUNIT_ASSERT_EQUAL((unsigned int)2, frame->fieldList().size()); CPPUNIT_ASSERT_EQUAL(String("14"), frame->fieldList()[0]); CPPUNIT_ASSERT_EQUAL(String("Eurodisco"), frame->fieldList()[1]); @@ -641,7 +641,7 @@ public: { MPEG::File f(TEST_FILE_PATH_C("id3v22-tda.mp3"), false); CPPUNIT_ASSERT(f.tag()); - CPPUNIT_ASSERT_EQUAL(TagLib::uint(2010), f.tag()->year()); + CPPUNIT_ASSERT_EQUAL((unsigned int)2010, f.tag()->year()); } void testUpdateFullDate22() @@ -685,15 +685,15 @@ public: MPEG::File bar(newname.c_str()); tf = static_cast(bar.ID3v2Tag()->frameList("TDOR").front()); CPPUNIT_ASSERT(tf); - CPPUNIT_ASSERT_EQUAL(TagLib::uint(1), tf->fieldList().size()); + CPPUNIT_ASSERT_EQUAL((unsigned int)1, tf->fieldList().size()); CPPUNIT_ASSERT_EQUAL(String("2011"), tf->fieldList().front()); tf = static_cast(bar.ID3v2Tag()->frameList("TDRC").front()); CPPUNIT_ASSERT(tf); - CPPUNIT_ASSERT_EQUAL(TagLib::uint(1), tf->fieldList().size()); + CPPUNIT_ASSERT_EQUAL((unsigned int)1, tf->fieldList().size()); CPPUNIT_ASSERT_EQUAL(String("2012-04-17T12:01"), tf->fieldList().front()); tf = dynamic_cast(bar.ID3v2Tag()->frameList("TIPL").front()); CPPUNIT_ASSERT(tf); - CPPUNIT_ASSERT_EQUAL(TagLib::uint(8), tf->fieldList().size()); + CPPUNIT_ASSERT_EQUAL((unsigned int)8, tf->fieldList().size()); CPPUNIT_ASSERT_EQUAL(String("Guitar"), tf->fieldList()[0]); CPPUNIT_ASSERT_EQUAL(String("Artist 1"), tf->fieldList()[1]); CPPUNIT_ASSERT_EQUAL(String("Drums"), tf->fieldList()[2]); @@ -726,7 +726,7 @@ public: CPPUNIT_ASSERT_EQUAL(String("image/bmp"), frame->mimeType()); CPPUNIT_ASSERT_EQUAL(ID3v2::AttachedPictureFrame::Other, frame->type()); CPPUNIT_ASSERT_EQUAL(String(""), frame->description()); - CPPUNIT_ASSERT_EQUAL(TagLib::uint(86414), frame->picture().size()); + CPPUNIT_ASSERT_EQUAL((unsigned int)86414, frame->picture().size()); #else @@ -756,12 +756,12 @@ public: string newname = copy.fileName(); MPEG::File f(newname.c_str()); PropertyMap dict = f.ID3v2Tag(false)->properties(); - CPPUNIT_ASSERT_EQUAL(TagLib::uint(6), dict.size()); + CPPUNIT_ASSERT_EQUAL((unsigned int)6, dict.size()); CPPUNIT_ASSERT(dict.contains("USERTEXTDESCRIPTION1")); CPPUNIT_ASSERT(dict.contains("QuodLibet::USERTEXTDESCRIPTION2")); - CPPUNIT_ASSERT_EQUAL(TagLib::uint(2), dict["USERTEXTDESCRIPTION1"].size()); - CPPUNIT_ASSERT_EQUAL(TagLib::uint(2), dict["QuodLibet::USERTEXTDESCRIPTION2"].size()); + CPPUNIT_ASSERT_EQUAL((unsigned int)2, dict["USERTEXTDESCRIPTION1"].size()); + CPPUNIT_ASSERT_EQUAL((unsigned int)2, dict["QuodLibet::USERTEXTDESCRIPTION2"].size()); CPPUNIT_ASSERT_EQUAL(String("userTextData1"), dict["USERTEXTDESCRIPTION1"][0]); CPPUNIT_ASSERT_EQUAL(String("userTextData2"), dict["USERTEXTDESCRIPTION1"][1]); CPPUNIT_ASSERT_EQUAL(String("userTextData1"), dict["QuodLibet::USERTEXTDESCRIPTION2"][0]); @@ -912,20 +912,20 @@ public: ID3v2::ChapterFrame f1(&header, chapterData); CPPUNIT_ASSERT_EQUAL(ByteVector("C"), f1.elementID()); - CPPUNIT_ASSERT((TagLib::uint)0x03 == f1.startTime()); - CPPUNIT_ASSERT((TagLib::uint)0x05 == f1.endTime()); - CPPUNIT_ASSERT((TagLib::uint)0x02 == f1.startOffset()); - CPPUNIT_ASSERT((TagLib::uint)0x03 == f1.endOffset()); - CPPUNIT_ASSERT((TagLib::uint)0x00 == f1.embeddedFrameList().size()); + CPPUNIT_ASSERT((unsigned int)0x03 == f1.startTime()); + CPPUNIT_ASSERT((unsigned int)0x05 == f1.endTime()); + CPPUNIT_ASSERT((unsigned int)0x02 == f1.startOffset()); + CPPUNIT_ASSERT((unsigned int)0x03 == f1.endOffset()); + CPPUNIT_ASSERT((unsigned int)0x00 == f1.embeddedFrameList().size()); ID3v2::ChapterFrame f2(&header, chapterData + embeddedFrameData); CPPUNIT_ASSERT_EQUAL(ByteVector("C"), f2.elementID()); - CPPUNIT_ASSERT((TagLib::uint)0x03 == f2.startTime()); - CPPUNIT_ASSERT((TagLib::uint)0x05 == f2.endTime()); - CPPUNIT_ASSERT((TagLib::uint)0x02 == f2.startOffset()); - CPPUNIT_ASSERT((TagLib::uint)0x03 == f2.endOffset()); - CPPUNIT_ASSERT((TagLib::uint)0x01 == f2.embeddedFrameList().size()); + CPPUNIT_ASSERT((unsigned int)0x03 == f2.startTime()); + CPPUNIT_ASSERT((unsigned int)0x05 == f2.endTime()); + CPPUNIT_ASSERT((unsigned int)0x02 == f2.startOffset()); + CPPUNIT_ASSERT((unsigned int)0x03 == f2.endOffset()); + CPPUNIT_ASSERT((unsigned int)0x01 == f2.embeddedFrameList().size()); CPPUNIT_ASSERT(f2.embeddedFrameList("TIT2").size() == 1); CPPUNIT_ASSERT(f2.embeddedFrameList("TIT2")[0]->toString() == "CH1"); } @@ -1018,10 +1018,10 @@ public: CPPUNIT_ASSERT_EQUAL(ByteVector("T"), f.elementID()); CPPUNIT_ASSERT(!f.isTopLevel()); CPPUNIT_ASSERT(f.isOrdered()); - CPPUNIT_ASSERT((TagLib::uint)0x02 == f.entryCount()); + CPPUNIT_ASSERT((unsigned int)0x02 == f.entryCount()); CPPUNIT_ASSERT_EQUAL(ByteVector("C"), f.childElements()[0]); CPPUNIT_ASSERT_EQUAL(ByteVector("D"), f.childElements()[1]); - CPPUNIT_ASSERT((TagLib::uint)0x01 == f.embeddedFrameList().size()); + CPPUNIT_ASSERT((unsigned int)0x01 == f.embeddedFrameList().size()); CPPUNIT_ASSERT(f.embeddedFrameList("TIT2").size() == 1); CPPUNIT_ASSERT(f.embeddedFrameList("TIT2")[0]->toString() == "TC1"); } @@ -1132,7 +1132,7 @@ public: // Sample rate will be 32000 if we can't skip the second tag. CPPUNIT_ASSERT(f.hasID3v2Tag()); - CPPUNIT_ASSERT_EQUAL((TagLib::uint)8049, f.ID3v2Tag()->header()->completeTagSize()); + CPPUNIT_ASSERT_EQUAL((unsigned int)8049, f.ID3v2Tag()->header()->completeTagSize()); CPPUNIT_ASSERT_EQUAL(44100, f.audioProperties()->sampleRate()); @@ -1143,7 +1143,7 @@ public: MPEG::File f(copy.fileName().c_str()); CPPUNIT_ASSERT(f.hasID3v2Tag()); CPPUNIT_ASSERT_EQUAL((long)3594, f.length()); - CPPUNIT_ASSERT_EQUAL((TagLib::uint)1505, f.ID3v2Tag()->header()->completeTagSize()); + CPPUNIT_ASSERT_EQUAL((unsigned int)1505, f.ID3v2Tag()->header()->completeTagSize()); CPPUNIT_ASSERT_EQUAL(String("Artist A"), f.ID3v2Tag()->artist()); CPPUNIT_ASSERT_EQUAL(44100, f.audioProperties()->sampleRate()); diff --git a/tests/test_info.cpp b/tests/test_info.cpp index de1f4bbe..6b583b2c 100644 --- a/tests/test_info.cpp +++ b/tests/test_info.cpp @@ -24,7 +24,7 @@ public: tag.setFieldText("TEST", "Dummy Text"); CPPUNIT_ASSERT_EQUAL(String("Test title 1"), tag.title()); - + RIFF::Info::FieldListMap map = tag.fieldListMap(); CPPUNIT_ASSERT_EQUAL(String("Test title 1"), map["INAM"]); CPPUNIT_ASSERT_EQUAL(String("Dummy Text"), map["TEST"]); @@ -34,14 +34,14 @@ public: { RIFF::Info::Tag tag; - CPPUNIT_ASSERT_EQUAL((TagLib::uint)0, tag.track()); + CPPUNIT_ASSERT_EQUAL((unsigned int)0, tag.track()); tag.setTrack(1234); - CPPUNIT_ASSERT_EQUAL((TagLib::uint)1234, tag.track()); + CPPUNIT_ASSERT_EQUAL((unsigned int)1234, tag.track()); CPPUNIT_ASSERT_EQUAL(String("1234"), tag.fieldText("IPRT")); - CPPUNIT_ASSERT_EQUAL((TagLib::uint)0, tag.year()); + CPPUNIT_ASSERT_EQUAL((unsigned int)0, tag.year()); tag.setYear(1234); - CPPUNIT_ASSERT_EQUAL((TagLib::uint)1234, tag.year()); + CPPUNIT_ASSERT_EQUAL((unsigned int)1234, tag.year()); CPPUNIT_ASSERT_EQUAL(String("1234"), tag.fieldText("ICRD")); } }; diff --git a/tests/test_it.cpp b/tests/test_it.cpp index 24cfb1a6..0558884c 100644 --- a/tests/test_it.cpp +++ b/tests/test_it.cpp @@ -26,7 +26,6 @@ using namespace std; using namespace TagLib; -using TagLib::uint; static const String titleBefore("test song name"); static const String titleAfter("changed title"); diff --git a/tests/test_mp4.cpp b/tests/test_mp4.cpp index b47ddedf..b5a2bf98 100644 --- a/tests/test_mp4.cpp +++ b/tests/test_mp4.cpp @@ -249,11 +249,11 @@ public: MP4::File f(TEST_FILE_PATH_C("has-tags.m4a")); CPPUNIT_ASSERT(f.tag()->contains("covr")); MP4::CoverArtList l = f.tag()->item("covr").toCoverArtList(); - CPPUNIT_ASSERT_EQUAL(TagLib::uint(2), l.size()); + CPPUNIT_ASSERT_EQUAL((unsigned int)2, l.size()); CPPUNIT_ASSERT_EQUAL(MP4::CoverArt::PNG, l[0].format()); - CPPUNIT_ASSERT_EQUAL(TagLib::uint(79), l[0].data().size()); + CPPUNIT_ASSERT_EQUAL((unsigned int)79, l[0].data().size()); CPPUNIT_ASSERT_EQUAL(MP4::CoverArt::JPEG, l[1].format()); - CPPUNIT_ASSERT_EQUAL(TagLib::uint(287), l[1].data().size()); + CPPUNIT_ASSERT_EQUAL((unsigned int)287, l[1].data().size()); } void testCovrWrite() @@ -273,13 +273,13 @@ public: MP4::File f(filename.c_str()); CPPUNIT_ASSERT(f.tag()->contains("covr")); MP4::CoverArtList l = f.tag()->item("covr").toCoverArtList(); - CPPUNIT_ASSERT_EQUAL(TagLib::uint(3), l.size()); + CPPUNIT_ASSERT_EQUAL((unsigned int)3, l.size()); CPPUNIT_ASSERT_EQUAL(MP4::CoverArt::PNG, l[0].format()); - CPPUNIT_ASSERT_EQUAL(TagLib::uint(79), l[0].data().size()); + CPPUNIT_ASSERT_EQUAL((unsigned int)79, l[0].data().size()); CPPUNIT_ASSERT_EQUAL(MP4::CoverArt::JPEG, l[1].format()); - CPPUNIT_ASSERT_EQUAL(TagLib::uint(287), l[1].data().size()); + CPPUNIT_ASSERT_EQUAL((unsigned int)287, l[1].data().size()); CPPUNIT_ASSERT_EQUAL(MP4::CoverArt::PNG, l[2].format()); - CPPUNIT_ASSERT_EQUAL(TagLib::uint(3), l[2].data().size()); + CPPUNIT_ASSERT_EQUAL((unsigned int)3, l[2].data().size()); } } @@ -288,11 +288,11 @@ public: MP4::File f(TEST_FILE_PATH_C("covr-junk.m4a")); CPPUNIT_ASSERT(f.tag()->contains("covr")); MP4::CoverArtList l = f.tag()->item("covr").toCoverArtList(); - CPPUNIT_ASSERT_EQUAL(TagLib::uint(2), l.size()); + CPPUNIT_ASSERT_EQUAL((unsigned int)2, l.size()); CPPUNIT_ASSERT_EQUAL(MP4::CoverArt::PNG, l[0].format()); - CPPUNIT_ASSERT_EQUAL(TagLib::uint(79), l[0].data().size()); + CPPUNIT_ASSERT_EQUAL((unsigned int)79, l[0].data().size()); CPPUNIT_ASSERT_EQUAL(MP4::CoverArt::JPEG, l[1].format()); - CPPUNIT_ASSERT_EQUAL(TagLib::uint(287), l[1].data().size()); + CPPUNIT_ASSERT_EQUAL((unsigned int)287, l[1].data().size()); } void testProperties() diff --git a/tests/test_mpeg.cpp b/tests/test_mpeg.cpp index ee3575e3..a4ceced4 100644 --- a/tests/test_mpeg.cpp +++ b/tests/test_mpeg.cpp @@ -128,7 +128,7 @@ public: } { MPEG::File f2(newname.c_str()); - CPPUNIT_ASSERT_EQUAL(TagLib::uint(4), f2.ID3v2Tag()->header()->majorVersion()); + CPPUNIT_ASSERT_EQUAL((unsigned int)4, f2.ID3v2Tag()->header()->majorVersion()); CPPUNIT_ASSERT_EQUAL(String("Artist A"), f2.tag()->artist()); CPPUNIT_ASSERT_EQUAL(xxx, f2.tag()->title()); } @@ -148,7 +148,7 @@ public: } { MPEG::File f2(newname.c_str()); - CPPUNIT_ASSERT_EQUAL(TagLib::uint(4), f2.ID3v2Tag()->header()->majorVersion()); + CPPUNIT_ASSERT_EQUAL((unsigned int)4, f2.ID3v2Tag()->header()->majorVersion()); CPPUNIT_ASSERT_EQUAL(String("Artist A"), f2.tag()->artist()); CPPUNIT_ASSERT_EQUAL(xxx, f2.tag()->title()); } @@ -171,7 +171,7 @@ public: } { MPEG::File f2(newname.c_str()); - CPPUNIT_ASSERT_EQUAL(TagLib::uint(3), f2.ID3v2Tag()->header()->majorVersion()); + CPPUNIT_ASSERT_EQUAL((unsigned int)3, f2.ID3v2Tag()->header()->majorVersion()); CPPUNIT_ASSERT_EQUAL(String("Artist A"), f2.tag()->artist()); CPPUNIT_ASSERT_EQUAL(xxx, f2.tag()->title()); } diff --git a/tests/test_ogg.cpp b/tests/test_ogg.cpp index 4adf0c50..2469aa15 100644 --- a/tests/test_ogg.cpp +++ b/tests/test_ogg.cpp @@ -95,7 +95,7 @@ public: Vorbis::File f(newname.c_str()); - CPPUNIT_ASSERT_EQUAL(TagLib::uint(0), f.tag()->properties().size()); + CPPUNIT_ASSERT_EQUAL((unsigned int)0, f.tag()->properties().size()); PropertyMap newTags; StringList values("value 1"); @@ -104,8 +104,8 @@ public: f.tag()->setProperties(newTags); PropertyMap map = f.tag()->properties(); - CPPUNIT_ASSERT_EQUAL(TagLib::uint(1), map.size()); - CPPUNIT_ASSERT_EQUAL(TagLib::uint(2), map["ARTIST"].size()); + CPPUNIT_ASSERT_EQUAL((unsigned int)1, map.size()); + CPPUNIT_ASSERT_EQUAL((unsigned int)2, map["ARTIST"].size()); CPPUNIT_ASSERT_EQUAL(String("value 1"), map["ARTIST"][0]); } @@ -117,7 +117,7 @@ public: Vorbis::File f(newname.c_str()); PropertyMap tags = f.tag()->properties(); - CPPUNIT_ASSERT_EQUAL(TagLib::uint(2), tags["UNUSUALTAG"].size()); + CPPUNIT_ASSERT_EQUAL((unsigned int)2, tags["UNUSUALTAG"].size()); CPPUNIT_ASSERT_EQUAL(String("usual value"), tags["UNUSUALTAG"][0]); CPPUNIT_ASSERT_EQUAL(String("another value"), tags["UNUSUALTAG"][1]); CPPUNIT_ASSERT_EQUAL( @@ -160,7 +160,7 @@ public: f.save(); f.seek(0x50); - CPPUNIT_ASSERT_EQUAL((TagLib::uint)0x3d3bd92d, f.readBlock(4).toUInt(0, true)); + CPPUNIT_ASSERT_EQUAL((unsigned int)0x3d3bd92d, f.readBlock(4).toUInt(0, true)); } { Vorbis::File f(copy.fileName().c_str()); @@ -168,7 +168,7 @@ public: f.save(); f.seek(0x50); - CPPUNIT_ASSERT_EQUAL((TagLib::uint)0xd985291c, f.readBlock(4).toUInt(0, true)); + CPPUNIT_ASSERT_EQUAL((unsigned int)0xd985291c, f.readBlock(4).toUInt(0, true)); } } @@ -194,7 +194,7 @@ public: f = new Vorbis::File(newname.c_str()); List lst = f->tag()->pictureList(); - CPPUNIT_ASSERT_EQUAL(TagLib::uint(1), lst.size()); + CPPUNIT_ASSERT_EQUAL((unsigned int)1, lst.size()); CPPUNIT_ASSERT_EQUAL(int(5), lst[0]->width()); CPPUNIT_ASSERT_EQUAL(int(6), lst[0]->height()); CPPUNIT_ASSERT_EQUAL(int(16), lst[0]->colorDepth()); diff --git a/tests/test_riff.cpp b/tests/test_riff.cpp index 4ee8d080..8efedf89 100644 --- a/tests/test_riff.cpp +++ b/tests/test_riff.cpp @@ -13,14 +13,14 @@ class PublicRIFF : public RIFF::File { public: PublicRIFF(FileName file) : RIFF::File(file, BigEndian) {}; - TagLib::uint riffSize() { return RIFF::File::riffSize(); }; - TagLib::uint chunkCount() { return RIFF::File::chunkCount(); }; - TagLib::uint chunkOffset(TagLib::uint i) { return RIFF::File::chunkOffset(i); }; - TagLib::uint chunkPadding(TagLib::uint i) { return RIFF::File::chunkPadding(i); }; - TagLib::uint chunkDataSize(TagLib::uint i) { return RIFF::File::chunkDataSize(i); }; - ByteVector chunkName(TagLib::uint i) { return RIFF::File::chunkName(i); }; - ByteVector chunkData(TagLib::uint i) { return RIFF::File::chunkData(i); }; - void setChunkData(TagLib::uint i, const ByteVector &data) { + unsigned int riffSize() { return RIFF::File::riffSize(); }; + unsigned int chunkCount() { return RIFF::File::chunkCount(); }; + unsigned int chunkOffset(unsigned int i) { return RIFF::File::chunkOffset(i); }; + unsigned int chunkPadding(unsigned int i) { return RIFF::File::chunkPadding(i); }; + unsigned int chunkDataSize(unsigned int i) { return RIFF::File::chunkDataSize(i); }; + ByteVector chunkName(unsigned int i) { return RIFF::File::chunkName(i); }; + ByteVector chunkData(unsigned int i) { return RIFF::File::chunkData(i); }; + void setChunkData(unsigned int i, const ByteVector &data) { RIFF::File::setChunkData(i, data); } void setChunkData(const ByteVector &name, const ByteVector &data) { @@ -29,7 +29,7 @@ public: virtual TagLib::Tag* tag() const { return 0; }; virtual TagLib::AudioProperties* audioProperties() const { return 0;}; virtual bool save() { return false; }; - void removeChunk(TagLib::uint i) { RIFF::File::removeChunk(i); } + void removeChunk(unsigned int i) { RIFF::File::removeChunk(i); } void removeChunk(const ByteVector &name) { RIFF::File::removeChunk(name); } }; @@ -53,7 +53,7 @@ public: { PublicRIFF f(filename.c_str()); CPPUNIT_ASSERT_EQUAL(ByteVector("TEST"), f.chunkName(2)); - CPPUNIT_ASSERT_EQUAL(TagLib::uint(0x1728 + 8), f.chunkOffset(2)); + CPPUNIT_ASSERT_EQUAL((unsigned int)(0x1728 + 8), f.chunkOffset(2)); f.setChunkData("TEST", "foo"); } @@ -61,8 +61,8 @@ public: PublicRIFF f(filename.c_str()); CPPUNIT_ASSERT_EQUAL(ByteVector("TEST"), f.chunkName(2)); CPPUNIT_ASSERT_EQUAL(ByteVector("foo"), f.chunkData(2)); - CPPUNIT_ASSERT_EQUAL(TagLib::uint(3), f.chunkDataSize(2)); - CPPUNIT_ASSERT_EQUAL(TagLib::uint(0x1728 + 8), f.chunkOffset(2)); + CPPUNIT_ASSERT_EQUAL((unsigned int)(3), f.chunkDataSize(2)); + CPPUNIT_ASSERT_EQUAL((unsigned int)(0x1728 + 8), f.chunkOffset(2)); f.setChunkData("SSND", "abcd"); @@ -95,33 +95,33 @@ public: { PublicRIFF f(filename.c_str()); - CPPUNIT_ASSERT_EQUAL(TagLib::uint(0xff0 + 8), f.chunkOffset(2)); - CPPUNIT_ASSERT_EQUAL(TagLib::uint(311), f.chunkDataSize(2)); + CPPUNIT_ASSERT_EQUAL((unsigned int)(0xff0 + 8), f.chunkOffset(2)); + CPPUNIT_ASSERT_EQUAL((unsigned int)(311), f.chunkDataSize(2)); CPPUNIT_ASSERT_EQUAL(ByteVector("SSND"), f.chunkName(2)); - CPPUNIT_ASSERT_EQUAL(TagLib::uint(1), f.chunkPadding(2)); + CPPUNIT_ASSERT_EQUAL((unsigned int)(1), f.chunkPadding(2)); CPPUNIT_ASSERT_EQUAL(long(4400), f.length()); - CPPUNIT_ASSERT_EQUAL(TagLib::uint(4399 - 8), f.riffSize()); + CPPUNIT_ASSERT_EQUAL((unsigned int)(4399 - 8), f.riffSize()); f.setChunkData("TEST", "abcd"); - CPPUNIT_ASSERT_EQUAL(TagLib::uint(4088), f.chunkOffset(2)); - CPPUNIT_ASSERT_EQUAL(TagLib::uint(311), f.chunkDataSize(2)); + CPPUNIT_ASSERT_EQUAL((unsigned int)(4088), f.chunkOffset(2)); + CPPUNIT_ASSERT_EQUAL((unsigned int)(311), f.chunkDataSize(2)); CPPUNIT_ASSERT_EQUAL(ByteVector("SSND"), f.chunkName(2)); - CPPUNIT_ASSERT_EQUAL(TagLib::uint(1), f.chunkPadding(2)); - CPPUNIT_ASSERT_EQUAL(TagLib::uint(4408), f.chunkOffset(3)); - CPPUNIT_ASSERT_EQUAL(TagLib::uint(4), f.chunkDataSize(3)); + CPPUNIT_ASSERT_EQUAL((unsigned int)(1), f.chunkPadding(2)); + CPPUNIT_ASSERT_EQUAL((unsigned int)(4408), f.chunkOffset(3)); + CPPUNIT_ASSERT_EQUAL((unsigned int)(4), f.chunkDataSize(3)); CPPUNIT_ASSERT_EQUAL(ByteVector("TEST"), f.chunkName(3)); - CPPUNIT_ASSERT_EQUAL(TagLib::uint(0), f.chunkPadding(3)); - CPPUNIT_ASSERT_EQUAL(TagLib::uint(4412 - 8), f.riffSize()); + CPPUNIT_ASSERT_EQUAL((unsigned int)(0), f.chunkPadding(3)); + CPPUNIT_ASSERT_EQUAL((unsigned int)(4412 - 8), f.riffSize()); } { PublicRIFF f(filename.c_str()); - CPPUNIT_ASSERT_EQUAL(TagLib::uint(4088), f.chunkOffset(2)); - CPPUNIT_ASSERT_EQUAL(TagLib::uint(311), f.chunkDataSize(2)); + CPPUNIT_ASSERT_EQUAL((unsigned int)(4088), f.chunkOffset(2)); + CPPUNIT_ASSERT_EQUAL((unsigned int)(311), f.chunkDataSize(2)); CPPUNIT_ASSERT_EQUAL(ByteVector("SSND"), f.chunkName(2)); - CPPUNIT_ASSERT_EQUAL(TagLib::uint(1), f.chunkPadding(2)); - CPPUNIT_ASSERT_EQUAL(TagLib::uint(4408), f.chunkOffset(3)); - CPPUNIT_ASSERT_EQUAL(TagLib::uint(4), f.chunkDataSize(3)); + CPPUNIT_ASSERT_EQUAL((unsigned int)(1), f.chunkPadding(2)); + CPPUNIT_ASSERT_EQUAL((unsigned int)(4408), f.chunkOffset(3)); + CPPUNIT_ASSERT_EQUAL((unsigned int)(4), f.chunkDataSize(3)); CPPUNIT_ASSERT_EQUAL(ByteVector("TEST"), f.chunkName(3)); - CPPUNIT_ASSERT_EQUAL(TagLib::uint(0), f.chunkPadding(3)); + CPPUNIT_ASSERT_EQUAL((unsigned int)(0), f.chunkPadding(3)); CPPUNIT_ASSERT_EQUAL(long(4412), f.length()); } } @@ -133,33 +133,33 @@ public: { PublicRIFF f(filename.c_str()); - CPPUNIT_ASSERT_EQUAL(TagLib::uint(0xff0 + 8), f.chunkOffset(2)); - CPPUNIT_ASSERT_EQUAL(TagLib::uint(311), f.chunkDataSize(2)); + CPPUNIT_ASSERT_EQUAL((unsigned int)(0xff0 + 8), f.chunkOffset(2)); + CPPUNIT_ASSERT_EQUAL((unsigned int)(311), f.chunkDataSize(2)); CPPUNIT_ASSERT_EQUAL(ByteVector("SSND"), f.chunkName(2)); - CPPUNIT_ASSERT_EQUAL(TagLib::uint(0), f.chunkPadding(2)); + CPPUNIT_ASSERT_EQUAL((unsigned int)(0), f.chunkPadding(2)); CPPUNIT_ASSERT_EQUAL(long(4399), f.length()); - CPPUNIT_ASSERT_EQUAL(TagLib::uint(4399 - 8), f.riffSize()); + CPPUNIT_ASSERT_EQUAL((unsigned int)(4399 - 8), f.riffSize()); f.setChunkData("TEST", "abcd"); - CPPUNIT_ASSERT_EQUAL(TagLib::uint(4088), f.chunkOffset(2)); - CPPUNIT_ASSERT_EQUAL(TagLib::uint(311), f.chunkDataSize(2)); + CPPUNIT_ASSERT_EQUAL((unsigned int)(4088), f.chunkOffset(2)); + CPPUNIT_ASSERT_EQUAL((unsigned int)(311), f.chunkDataSize(2)); CPPUNIT_ASSERT_EQUAL(ByteVector("SSND"), f.chunkName(2)); - CPPUNIT_ASSERT_EQUAL(TagLib::uint(1), f.chunkPadding(2)); - CPPUNIT_ASSERT_EQUAL(TagLib::uint(4408), f.chunkOffset(3)); - CPPUNIT_ASSERT_EQUAL(TagLib::uint(4), f.chunkDataSize(3)); + CPPUNIT_ASSERT_EQUAL((unsigned int)(1), f.chunkPadding(2)); + CPPUNIT_ASSERT_EQUAL((unsigned int)(4408), f.chunkOffset(3)); + CPPUNIT_ASSERT_EQUAL((unsigned int)(4), f.chunkDataSize(3)); CPPUNIT_ASSERT_EQUAL(ByteVector("TEST"), f.chunkName(3)); - CPPUNIT_ASSERT_EQUAL(TagLib::uint(0), f.chunkPadding(3)); - CPPUNIT_ASSERT_EQUAL(TagLib::uint(4412 - 8), f.riffSize()); + CPPUNIT_ASSERT_EQUAL((unsigned int)(0), f.chunkPadding(3)); + CPPUNIT_ASSERT_EQUAL((unsigned int)(4412 - 8), f.riffSize()); } { PublicRIFF f(filename.c_str()); - CPPUNIT_ASSERT_EQUAL(TagLib::uint(4088), f.chunkOffset(2)); - CPPUNIT_ASSERT_EQUAL(TagLib::uint(311), f.chunkDataSize(2)); + CPPUNIT_ASSERT_EQUAL((unsigned int)(4088), f.chunkOffset(2)); + CPPUNIT_ASSERT_EQUAL((unsigned int)(311), f.chunkDataSize(2)); CPPUNIT_ASSERT_EQUAL(ByteVector("SSND"), f.chunkName(2)); - CPPUNIT_ASSERT_EQUAL(TagLib::uint(1), f.chunkPadding(2)); - CPPUNIT_ASSERT_EQUAL(TagLib::uint(4408), f.chunkOffset(3)); - CPPUNIT_ASSERT_EQUAL(TagLib::uint(4), f.chunkDataSize(3)); + CPPUNIT_ASSERT_EQUAL((unsigned int)(1), f.chunkPadding(2)); + CPPUNIT_ASSERT_EQUAL((unsigned int)(4408), f.chunkOffset(3)); + CPPUNIT_ASSERT_EQUAL((unsigned int)(4), f.chunkDataSize(3)); CPPUNIT_ASSERT_EQUAL(ByteVector("TEST"), f.chunkName(3)); - CPPUNIT_ASSERT_EQUAL(TagLib::uint(0), f.chunkPadding(3)); + CPPUNIT_ASSERT_EQUAL((unsigned int)(0), f.chunkPadding(3)); CPPUNIT_ASSERT_EQUAL(long(4412), f.length()); } } @@ -171,33 +171,33 @@ public: { PublicRIFF f(filename.c_str()); - CPPUNIT_ASSERT_EQUAL(TagLib::uint(0xff0 + 8), f.chunkOffset(2)); - CPPUNIT_ASSERT_EQUAL(TagLib::uint(311), f.chunkDataSize(2)); + CPPUNIT_ASSERT_EQUAL((unsigned int)(0xff0 + 8), f.chunkOffset(2)); + CPPUNIT_ASSERT_EQUAL((unsigned int)(311), f.chunkDataSize(2)); CPPUNIT_ASSERT_EQUAL(ByteVector("SSND"), f.chunkName(2)); - CPPUNIT_ASSERT_EQUAL(TagLib::uint(0), f.chunkPadding(2)); + CPPUNIT_ASSERT_EQUAL((unsigned int)(0), f.chunkPadding(2)); CPPUNIT_ASSERT_EQUAL(long(4399), f.length()); - CPPUNIT_ASSERT_EQUAL(TagLib::uint(4399 - 8), f.riffSize()); + CPPUNIT_ASSERT_EQUAL((unsigned int)(4399 - 8), f.riffSize()); f.setChunkData("TEST", "abc"); - CPPUNIT_ASSERT_EQUAL(TagLib::uint(4088), f.chunkOffset(2)); - CPPUNIT_ASSERT_EQUAL(TagLib::uint(311), f.chunkDataSize(2)); + CPPUNIT_ASSERT_EQUAL((unsigned int)(4088), f.chunkOffset(2)); + CPPUNIT_ASSERT_EQUAL((unsigned int)(311), f.chunkDataSize(2)); CPPUNIT_ASSERT_EQUAL(ByteVector("SSND"), f.chunkName(2)); - CPPUNIT_ASSERT_EQUAL(TagLib::uint(1), f.chunkPadding(2)); - CPPUNIT_ASSERT_EQUAL(TagLib::uint(4408), f.chunkOffset(3)); - CPPUNIT_ASSERT_EQUAL(TagLib::uint(3), f.chunkDataSize(3)); + CPPUNIT_ASSERT_EQUAL((unsigned int)(1), f.chunkPadding(2)); + CPPUNIT_ASSERT_EQUAL((unsigned int)(4408), f.chunkOffset(3)); + CPPUNIT_ASSERT_EQUAL((unsigned int)(3), f.chunkDataSize(3)); CPPUNIT_ASSERT_EQUAL(ByteVector("TEST"), f.chunkName(3)); - CPPUNIT_ASSERT_EQUAL(TagLib::uint(1), f.chunkPadding(3)); - CPPUNIT_ASSERT_EQUAL(TagLib::uint(4411 - 8), f.riffSize()); + CPPUNIT_ASSERT_EQUAL((unsigned int)(1), f.chunkPadding(3)); + CPPUNIT_ASSERT_EQUAL((unsigned int)(4411 - 8), f.riffSize()); } { PublicRIFF f(filename.c_str()); - CPPUNIT_ASSERT_EQUAL(TagLib::uint(4088), f.chunkOffset(2)); - CPPUNIT_ASSERT_EQUAL(TagLib::uint(311), f.chunkDataSize(2)); + CPPUNIT_ASSERT_EQUAL((unsigned int)(4088), f.chunkOffset(2)); + CPPUNIT_ASSERT_EQUAL((unsigned int)(311), f.chunkDataSize(2)); CPPUNIT_ASSERT_EQUAL(ByteVector("SSND"), f.chunkName(2)); - CPPUNIT_ASSERT_EQUAL(TagLib::uint(1), f.chunkPadding(2)); - CPPUNIT_ASSERT_EQUAL(TagLib::uint(4408), f.chunkOffset(3)); - CPPUNIT_ASSERT_EQUAL(TagLib::uint(3), f.chunkDataSize(3)); + CPPUNIT_ASSERT_EQUAL((unsigned int)(1), f.chunkPadding(2)); + CPPUNIT_ASSERT_EQUAL((unsigned int)(4408), f.chunkOffset(3)); + CPPUNIT_ASSERT_EQUAL((unsigned int)(3), f.chunkDataSize(3)); CPPUNIT_ASSERT_EQUAL(ByteVector("TEST"), f.chunkName(3)); - CPPUNIT_ASSERT_EQUAL(TagLib::uint(1), f.chunkPadding(3)); + CPPUNIT_ASSERT_EQUAL((unsigned int)(1), f.chunkPadding(3)); CPPUNIT_ASSERT_EQUAL(long(4412), f.length()); } } @@ -210,17 +210,17 @@ public: PublicRIFF f(filename.c_str()); CPPUNIT_ASSERT_EQUAL(ByteVector("COMM"), f.chunkName(0)); - CPPUNIT_ASSERT_EQUAL(TagLib::uint(0x000C + 8), f.chunkOffset(0)); + CPPUNIT_ASSERT_EQUAL((unsigned int)(0x000C + 8), f.chunkOffset(0)); CPPUNIT_ASSERT_EQUAL(ByteVector("SSND"), f.chunkName(1)); - CPPUNIT_ASSERT_EQUAL(TagLib::uint(0x0026 + 8), f.chunkOffset(1)); + CPPUNIT_ASSERT_EQUAL((unsigned int)(0x0026 + 8), f.chunkOffset(1)); CPPUNIT_ASSERT_EQUAL(ByteVector("TEST"), f.chunkName(2)); - CPPUNIT_ASSERT_EQUAL(TagLib::uint(0x1728 + 8), f.chunkOffset(2)); + CPPUNIT_ASSERT_EQUAL((unsigned int)(0x1728 + 8), f.chunkOffset(2)); const ByteVector data(0x400, ' '); f.setChunkData("SSND", data); - CPPUNIT_ASSERT_EQUAL(TagLib::uint(0x000C + 8), f.chunkOffset(0)); - CPPUNIT_ASSERT_EQUAL(TagLib::uint(0x0026 + 8), f.chunkOffset(1)); - CPPUNIT_ASSERT_EQUAL(TagLib::uint(0x042E + 8), f.chunkOffset(2)); + CPPUNIT_ASSERT_EQUAL((unsigned int)(0x000C + 8), f.chunkOffset(0)); + CPPUNIT_ASSERT_EQUAL((unsigned int)(0x0026 + 8), f.chunkOffset(1)); + CPPUNIT_ASSERT_EQUAL((unsigned int)(0x042E + 8), f.chunkOffset(2)); f.seek(f.chunkOffset(0) - 8); CPPUNIT_ASSERT_EQUAL(ByteVector("COMM"), f.readBlock(4)); @@ -230,9 +230,9 @@ public: CPPUNIT_ASSERT_EQUAL(ByteVector("TEST"), f.readBlock(4)); f.setChunkData(0, data); - CPPUNIT_ASSERT_EQUAL(TagLib::uint(0x000C + 8), f.chunkOffset(0)); - CPPUNIT_ASSERT_EQUAL(TagLib::uint(0x0414 + 8), f.chunkOffset(1)); - CPPUNIT_ASSERT_EQUAL(TagLib::uint(0x081C + 8), f.chunkOffset(2)); + CPPUNIT_ASSERT_EQUAL((unsigned int)(0x000C + 8), f.chunkOffset(0)); + CPPUNIT_ASSERT_EQUAL((unsigned int)(0x0414 + 8), f.chunkOffset(1)); + CPPUNIT_ASSERT_EQUAL((unsigned int)(0x081C + 8), f.chunkOffset(2)); f.seek(f.chunkOffset(0) - 8); CPPUNIT_ASSERT_EQUAL(ByteVector("COMM"), f.readBlock(4)); @@ -242,8 +242,8 @@ public: CPPUNIT_ASSERT_EQUAL(ByteVector("TEST"), f.readBlock(4)); f.removeChunk("SSND"); - CPPUNIT_ASSERT_EQUAL(TagLib::uint(0x000C + 8), f.chunkOffset(0)); - CPPUNIT_ASSERT_EQUAL(TagLib::uint(0x0414 + 8), f.chunkOffset(1)); + CPPUNIT_ASSERT_EQUAL((unsigned int)(0x000C + 8), f.chunkOffset(0)); + CPPUNIT_ASSERT_EQUAL((unsigned int)(0x0414 + 8), f.chunkOffset(1)); f.seek(f.chunkOffset(0) - 8); CPPUNIT_ASSERT_EQUAL(ByteVector("COMM"), f.readBlock(4)); @@ -251,7 +251,7 @@ public: CPPUNIT_ASSERT_EQUAL(ByteVector("TEST"), f.readBlock(4)); f.removeChunk(0); - CPPUNIT_ASSERT_EQUAL(TagLib::uint(0x000C + 8), f.chunkOffset(0)); + CPPUNIT_ASSERT_EQUAL((unsigned int)(0x000C + 8), f.chunkOffset(0)); f.seek(f.chunkOffset(0) - 8); CPPUNIT_ASSERT_EQUAL(ByteVector("TEST"), f.readBlock(4)); diff --git a/tests/test_string.cpp b/tests/test_string.cpp index 73b08073..2ccba7b2 100644 --- a/tests/test_string.cpp +++ b/tests/test_string.cpp @@ -266,9 +266,9 @@ public: ByteVector lf("abc\x0axyz", 7); ByteVector crlf("abc\x0d\x0axyz", 8); - CPPUNIT_ASSERT_EQUAL(TagLib::uint(7), String(cr).size()); - CPPUNIT_ASSERT_EQUAL(TagLib::uint(7), String(lf).size()); - CPPUNIT_ASSERT_EQUAL(TagLib::uint(8), String(crlf).size()); + CPPUNIT_ASSERT_EQUAL((unsigned int)7, String(cr).size()); + CPPUNIT_ASSERT_EQUAL((unsigned int)7, String(lf).size()); + CPPUNIT_ASSERT_EQUAL((unsigned int)8, String(crlf).size()); CPPUNIT_ASSERT_EQUAL(L'\x0d', String(cr)[3]); CPPUNIT_ASSERT_EQUAL(L'\x0a', String(lf)[3]); diff --git a/tests/test_synchdata.cpp b/tests/test_synchdata.cpp index 2e3021ea..04a5c07b 100644 --- a/tests/test_synchdata.cpp +++ b/tests/test_synchdata.cpp @@ -47,7 +47,7 @@ public: char data[] = { 0, 0, 0, 127 }; ByteVector v(data, 4); - CPPUNIT_ASSERT_EQUAL(ID3v2::SynchData::toUInt(v), TagLib::uint(127)); + CPPUNIT_ASSERT_EQUAL(ID3v2::SynchData::toUInt(v), (unsigned int)127); CPPUNIT_ASSERT_EQUAL(ID3v2::SynchData::fromUInt(127), v); } @@ -56,7 +56,7 @@ public: char data[] = { 0, 0, 1, 0 }; ByteVector v(data, 4); - CPPUNIT_ASSERT_EQUAL(ID3v2::SynchData::toUInt(v), TagLib::uint(128)); + CPPUNIT_ASSERT_EQUAL(ID3v2::SynchData::toUInt(v), (unsigned int)128); CPPUNIT_ASSERT_EQUAL(ID3v2::SynchData::fromUInt(128), v); } @@ -65,7 +65,7 @@ public: char data[] = { 0, 0, 1, 1 }; ByteVector v(data, 4); - CPPUNIT_ASSERT_EQUAL(ID3v2::SynchData::toUInt(v), TagLib::uint(129)); + CPPUNIT_ASSERT_EQUAL(ID3v2::SynchData::toUInt(v), (unsigned int)129); CPPUNIT_ASSERT_EQUAL(ID3v2::SynchData::fromUInt(129), v); } @@ -74,8 +74,8 @@ public: char data[] = { 0, 0, 0, -1 }; char data2[] = { 0, 0, -1, -1 }; - CPPUNIT_ASSERT_EQUAL(TagLib::uint(255), ID3v2::SynchData::toUInt(ByteVector(data, 4))); - CPPUNIT_ASSERT_EQUAL(TagLib::uint(65535), ID3v2::SynchData::toUInt(ByteVector(data2, 4))); + CPPUNIT_ASSERT_EQUAL((unsigned int)255, ID3v2::SynchData::toUInt(ByteVector(data, 4))); + CPPUNIT_ASSERT_EQUAL((unsigned int)65535, ID3v2::SynchData::toUInt(ByteVector(data2, 4))); } void testToUIntBrokenAndTooLarge() @@ -83,7 +83,7 @@ public: char data[] = { 0, 0, 0, -1, 0 }; ByteVector v(data, 5); - CPPUNIT_ASSERT_EQUAL(TagLib::uint(255), ID3v2::SynchData::toUInt(v)); + CPPUNIT_ASSERT_EQUAL((unsigned int)255, ID3v2::SynchData::toUInt(v)); } void testDecode1() diff --git a/tests/test_xiphcomment.cpp b/tests/test_xiphcomment.cpp index 617bd765..621179fe 100644 --- a/tests/test_xiphcomment.cpp +++ b/tests/test_xiphcomment.cpp @@ -27,11 +27,11 @@ public: void testYear() { Ogg::XiphComment cmt; - CPPUNIT_ASSERT_EQUAL(TagLib::uint(0), cmt.year()); + CPPUNIT_ASSERT_EQUAL((unsigned int)0, cmt.year()); cmt.addField("YEAR", "2009"); - CPPUNIT_ASSERT_EQUAL(TagLib::uint(2009), cmt.year()); + CPPUNIT_ASSERT_EQUAL((unsigned int)2009, cmt.year()); cmt.addField("DATE", "2008"); - CPPUNIT_ASSERT_EQUAL(TagLib::uint(2008), cmt.year()); + CPPUNIT_ASSERT_EQUAL((unsigned int)2008, cmt.year()); } void testSetYear() @@ -47,11 +47,11 @@ public: void testTrack() { Ogg::XiphComment cmt; - CPPUNIT_ASSERT_EQUAL(TagLib::uint(0), cmt.track()); + CPPUNIT_ASSERT_EQUAL((unsigned int)0, cmt.track()); cmt.addField("TRACKNUM", "7"); - CPPUNIT_ASSERT_EQUAL(TagLib::uint(7), cmt.track()); + CPPUNIT_ASSERT_EQUAL((unsigned int)7, cmt.track()); cmt.addField("TRACKNUMBER", "8"); - CPPUNIT_ASSERT_EQUAL(TagLib::uint(8), cmt.track()); + CPPUNIT_ASSERT_EQUAL((unsigned int)8, cmt.track()); } void testSetTrack() @@ -73,7 +73,7 @@ public: Ogg::XiphComment cmt; PropertyMap unsuccessful = cmt.setProperties(map); - CPPUNIT_ASSERT_EQUAL(TagLib::uint(3), unsuccessful.size()); + CPPUNIT_ASSERT_EQUAL((unsigned int)3, unsuccessful.size()); CPPUNIT_ASSERT(cmt.properties().isEmpty()); } From 88ad2843f470cc40182e530e92211cded98051e9 Mon Sep 17 00:00:00 2001 From: Tsuda Kageyu Date: Thu, 3 Dec 2015 02:25:16 +0900 Subject: [PATCH 30/33] Small cosmetic fixes. --- taglib/toolkit/tbytevector.cpp | 100 ++++++++++++++++----------------- 1 file changed, 50 insertions(+), 50 deletions(-) diff --git a/taglib/toolkit/tbytevector.cpp b/taglib/toolkit/tbytevector.cpp index 1fba30a2..47c9dd31 100644 --- a/taglib/toolkit/tbytevector.cpp +++ b/taglib/toolkit/tbytevector.cpp @@ -51,54 +51,6 @@ namespace TagLib { -static const char hexTable[17] = "0123456789abcdef"; - -static const unsigned int crcTable[256] = { - 0x00000000, 0x04c11db7, 0x09823b6e, 0x0d4326d9, 0x130476dc, 0x17c56b6b, - 0x1a864db2, 0x1e475005, 0x2608edb8, 0x22c9f00f, 0x2f8ad6d6, 0x2b4bcb61, - 0x350c9b64, 0x31cd86d3, 0x3c8ea00a, 0x384fbdbd, 0x4c11db70, 0x48d0c6c7, - 0x4593e01e, 0x4152fda9, 0x5f15adac, 0x5bd4b01b, 0x569796c2, 0x52568b75, - 0x6a1936c8, 0x6ed82b7f, 0x639b0da6, 0x675a1011, 0x791d4014, 0x7ddc5da3, - 0x709f7b7a, 0x745e66cd, 0x9823b6e0, 0x9ce2ab57, 0x91a18d8e, 0x95609039, - 0x8b27c03c, 0x8fe6dd8b, 0x82a5fb52, 0x8664e6e5, 0xbe2b5b58, 0xbaea46ef, - 0xb7a96036, 0xb3687d81, 0xad2f2d84, 0xa9ee3033, 0xa4ad16ea, 0xa06c0b5d, - 0xd4326d90, 0xd0f37027, 0xddb056fe, 0xd9714b49, 0xc7361b4c, 0xc3f706fb, - 0xceb42022, 0xca753d95, 0xf23a8028, 0xf6fb9d9f, 0xfbb8bb46, 0xff79a6f1, - 0xe13ef6f4, 0xe5ffeb43, 0xe8bccd9a, 0xec7dd02d, 0x34867077, 0x30476dc0, - 0x3d044b19, 0x39c556ae, 0x278206ab, 0x23431b1c, 0x2e003dc5, 0x2ac12072, - 0x128e9dcf, 0x164f8078, 0x1b0ca6a1, 0x1fcdbb16, 0x018aeb13, 0x054bf6a4, - 0x0808d07d, 0x0cc9cdca, 0x7897ab07, 0x7c56b6b0, 0x71159069, 0x75d48dde, - 0x6b93dddb, 0x6f52c06c, 0x6211e6b5, 0x66d0fb02, 0x5e9f46bf, 0x5a5e5b08, - 0x571d7dd1, 0x53dc6066, 0x4d9b3063, 0x495a2dd4, 0x44190b0d, 0x40d816ba, - 0xaca5c697, 0xa864db20, 0xa527fdf9, 0xa1e6e04e, 0xbfa1b04b, 0xbb60adfc, - 0xb6238b25, 0xb2e29692, 0x8aad2b2f, 0x8e6c3698, 0x832f1041, 0x87ee0df6, - 0x99a95df3, 0x9d684044, 0x902b669d, 0x94ea7b2a, 0xe0b41de7, 0xe4750050, - 0xe9362689, 0xedf73b3e, 0xf3b06b3b, 0xf771768c, 0xfa325055, 0xfef34de2, - 0xc6bcf05f, 0xc27dede8, 0xcf3ecb31, 0xcbffd686, 0xd5b88683, 0xd1799b34, - 0xdc3abded, 0xd8fba05a, 0x690ce0ee, 0x6dcdfd59, 0x608edb80, 0x644fc637, - 0x7a089632, 0x7ec98b85, 0x738aad5c, 0x774bb0eb, 0x4f040d56, 0x4bc510e1, - 0x46863638, 0x42472b8f, 0x5c007b8a, 0x58c1663d, 0x558240e4, 0x51435d53, - 0x251d3b9e, 0x21dc2629, 0x2c9f00f0, 0x285e1d47, 0x36194d42, 0x32d850f5, - 0x3f9b762c, 0x3b5a6b9b, 0x0315d626, 0x07d4cb91, 0x0a97ed48, 0x0e56f0ff, - 0x1011a0fa, 0x14d0bd4d, 0x19939b94, 0x1d528623, 0xf12f560e, 0xf5ee4bb9, - 0xf8ad6d60, 0xfc6c70d7, 0xe22b20d2, 0xe6ea3d65, 0xeba91bbc, 0xef68060b, - 0xd727bbb6, 0xd3e6a601, 0xdea580d8, 0xda649d6f, 0xc423cd6a, 0xc0e2d0dd, - 0xcda1f604, 0xc960ebb3, 0xbd3e8d7e, 0xb9ff90c9, 0xb4bcb610, 0xb07daba7, - 0xae3afba2, 0xaafbe615, 0xa7b8c0cc, 0xa379dd7b, 0x9b3660c6, 0x9ff77d71, - 0x92b45ba8, 0x9675461f, 0x8832161a, 0x8cf30bad, 0x81b02d74, 0x857130c3, - 0x5d8a9099, 0x594b8d2e, 0x5408abf7, 0x50c9b640, 0x4e8ee645, 0x4a4ffbf2, - 0x470cdd2b, 0x43cdc09c, 0x7b827d21, 0x7f436096, 0x7200464f, 0x76c15bf8, - 0x68860bfd, 0x6c47164a, 0x61043093, 0x65c52d24, 0x119b4be9, 0x155a565e, - 0x18197087, 0x1cd86d30, 0x029f3d35, 0x065e2082, 0x0b1d065b, 0x0fdc1bec, - 0x3793a651, 0x3352bbe6, 0x3e119d3f, 0x3ad08088, 0x2497d08d, 0x2056cd3a, - 0x2d15ebe3, 0x29d4f654, 0xc5a92679, 0xc1683bce, 0xcc2b1d17, 0xc8ea00a0, - 0xd6ad50a5, 0xd26c4d12, 0xdf2f6bcb, 0xdbee767c, 0xe3a1cbc1, 0xe760d676, - 0xea23f0af, 0xeee2ed18, 0xf0a5bd1d, 0xf464a0aa, 0xf9278673, 0xfde69bc4, - 0x89b8fd09, 0x8d79e0be, 0x803ac667, 0x84fbdbd0, 0x9abc8bd5, 0x9e7d9662, - 0x933eb0bb, 0x97ffad0c, 0xafb010b1, 0xab710d06, 0xa6322bdf, 0xa2f33668, - 0xbcb4666d, 0xb8757bda, 0xb5365d03, 0xb1f740b4 -}; - template int findChar( const TIterator dataBegin, const TIterator dataEnd, @@ -693,6 +645,52 @@ bool ByteVector::isEmpty() const unsigned int ByteVector::checksum() const { + static const unsigned int crcTable[256] = { + 0x00000000, 0x04c11db7, 0x09823b6e, 0x0d4326d9, 0x130476dc, 0x17c56b6b, + 0x1a864db2, 0x1e475005, 0x2608edb8, 0x22c9f00f, 0x2f8ad6d6, 0x2b4bcb61, + 0x350c9b64, 0x31cd86d3, 0x3c8ea00a, 0x384fbdbd, 0x4c11db70, 0x48d0c6c7, + 0x4593e01e, 0x4152fda9, 0x5f15adac, 0x5bd4b01b, 0x569796c2, 0x52568b75, + 0x6a1936c8, 0x6ed82b7f, 0x639b0da6, 0x675a1011, 0x791d4014, 0x7ddc5da3, + 0x709f7b7a, 0x745e66cd, 0x9823b6e0, 0x9ce2ab57, 0x91a18d8e, 0x95609039, + 0x8b27c03c, 0x8fe6dd8b, 0x82a5fb52, 0x8664e6e5, 0xbe2b5b58, 0xbaea46ef, + 0xb7a96036, 0xb3687d81, 0xad2f2d84, 0xa9ee3033, 0xa4ad16ea, 0xa06c0b5d, + 0xd4326d90, 0xd0f37027, 0xddb056fe, 0xd9714b49, 0xc7361b4c, 0xc3f706fb, + 0xceb42022, 0xca753d95, 0xf23a8028, 0xf6fb9d9f, 0xfbb8bb46, 0xff79a6f1, + 0xe13ef6f4, 0xe5ffeb43, 0xe8bccd9a, 0xec7dd02d, 0x34867077, 0x30476dc0, + 0x3d044b19, 0x39c556ae, 0x278206ab, 0x23431b1c, 0x2e003dc5, 0x2ac12072, + 0x128e9dcf, 0x164f8078, 0x1b0ca6a1, 0x1fcdbb16, 0x018aeb13, 0x054bf6a4, + 0x0808d07d, 0x0cc9cdca, 0x7897ab07, 0x7c56b6b0, 0x71159069, 0x75d48dde, + 0x6b93dddb, 0x6f52c06c, 0x6211e6b5, 0x66d0fb02, 0x5e9f46bf, 0x5a5e5b08, + 0x571d7dd1, 0x53dc6066, 0x4d9b3063, 0x495a2dd4, 0x44190b0d, 0x40d816ba, + 0xaca5c697, 0xa864db20, 0xa527fdf9, 0xa1e6e04e, 0xbfa1b04b, 0xbb60adfc, + 0xb6238b25, 0xb2e29692, 0x8aad2b2f, 0x8e6c3698, 0x832f1041, 0x87ee0df6, + 0x99a95df3, 0x9d684044, 0x902b669d, 0x94ea7b2a, 0xe0b41de7, 0xe4750050, + 0xe9362689, 0xedf73b3e, 0xf3b06b3b, 0xf771768c, 0xfa325055, 0xfef34de2, + 0xc6bcf05f, 0xc27dede8, 0xcf3ecb31, 0xcbffd686, 0xd5b88683, 0xd1799b34, + 0xdc3abded, 0xd8fba05a, 0x690ce0ee, 0x6dcdfd59, 0x608edb80, 0x644fc637, + 0x7a089632, 0x7ec98b85, 0x738aad5c, 0x774bb0eb, 0x4f040d56, 0x4bc510e1, + 0x46863638, 0x42472b8f, 0x5c007b8a, 0x58c1663d, 0x558240e4, 0x51435d53, + 0x251d3b9e, 0x21dc2629, 0x2c9f00f0, 0x285e1d47, 0x36194d42, 0x32d850f5, + 0x3f9b762c, 0x3b5a6b9b, 0x0315d626, 0x07d4cb91, 0x0a97ed48, 0x0e56f0ff, + 0x1011a0fa, 0x14d0bd4d, 0x19939b94, 0x1d528623, 0xf12f560e, 0xf5ee4bb9, + 0xf8ad6d60, 0xfc6c70d7, 0xe22b20d2, 0xe6ea3d65, 0xeba91bbc, 0xef68060b, + 0xd727bbb6, 0xd3e6a601, 0xdea580d8, 0xda649d6f, 0xc423cd6a, 0xc0e2d0dd, + 0xcda1f604, 0xc960ebb3, 0xbd3e8d7e, 0xb9ff90c9, 0xb4bcb610, 0xb07daba7, + 0xae3afba2, 0xaafbe615, 0xa7b8c0cc, 0xa379dd7b, 0x9b3660c6, 0x9ff77d71, + 0x92b45ba8, 0x9675461f, 0x8832161a, 0x8cf30bad, 0x81b02d74, 0x857130c3, + 0x5d8a9099, 0x594b8d2e, 0x5408abf7, 0x50c9b640, 0x4e8ee645, 0x4a4ffbf2, + 0x470cdd2b, 0x43cdc09c, 0x7b827d21, 0x7f436096, 0x7200464f, 0x76c15bf8, + 0x68860bfd, 0x6c47164a, 0x61043093, 0x65c52d24, 0x119b4be9, 0x155a565e, + 0x18197087, 0x1cd86d30, 0x029f3d35, 0x065e2082, 0x0b1d065b, 0x0fdc1bec, + 0x3793a651, 0x3352bbe6, 0x3e119d3f, 0x3ad08088, 0x2497d08d, 0x2056cd3a, + 0x2d15ebe3, 0x29d4f654, 0xc5a92679, 0xc1683bce, 0xcc2b1d17, 0xc8ea00a0, + 0xd6ad50a5, 0xd26c4d12, 0xdf2f6bcb, 0xdbee767c, 0xe3a1cbc1, 0xe760d676, + 0xea23f0af, 0xeee2ed18, 0xf0a5bd1d, 0xf464a0aa, 0xf9278673, 0xfde69bc4, + 0x89b8fd09, 0x8d79e0be, 0x803ac667, 0x84fbdbd0, 0x9abc8bd5, 0x9e7d9662, + 0x933eb0bb, 0x97ffad0c, 0xafb010b1, 0xab710d06, 0xa6322bdf, 0xa2f33668, + 0xbcb4666d, 0xb8757bda, 0xb5365d03, 0xb1f740b4 + }; + unsigned int sum = 0; for(ByteVector::ConstIterator it = begin(); it != end(); ++it) sum = (sum << 8) ^ crcTable[((sum >> 24) & 0xff) ^ static_cast(*it)]; @@ -859,6 +857,8 @@ void ByteVector::swap(ByteVector &v) ByteVector ByteVector::toHex() const { + static const char hexTable[17] = "0123456789abcdef"; + ByteVector encoded(size() * 2); char *p = encoded.data(); @@ -943,7 +943,7 @@ ByteVector ByteVector::fromBase64(const ByteVector & input) } src += 4; len -= 4; - } + } // Only return output if we processed all bytes if(len == 0) { @@ -956,7 +956,7 @@ ByteVector ByteVector::fromBase64(const ByteVector & input) ByteVector ByteVector::toBase64() const { static const char alphabet[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; - if (size()) { + if(!isEmpty()) { unsigned int len = size(); ByteVector output(4 * ((len - 1) / 3 + 1)); // note roundup From e99910dd74cf21dc2bc8efc10c1c816d7b45002d Mon Sep 17 00:00:00 2001 From: Tsuda Kageyu Date: Thu, 3 Dec 2015 10:06:04 +0900 Subject: [PATCH 31/33] Revert some ABI breaking changes. --- taglib/ape/apetag.cpp | 26 ++++++++++++++++++-------- taglib/ape/apetag.h | 2 +- taglib/mpeg/id3v1/id3v1tag.cpp | 18 +++++++++++++----- taglib/mpeg/id3v1/id3v1tag.h | 2 +- taglib/mpeg/id3v2/id3v2tag.cpp | 34 +++++++++++++++++----------------- taglib/mpeg/id3v2/id3v2tag.h | 2 +- 6 files changed, 51 insertions(+), 33 deletions(-) diff --git a/taglib/ape/apetag.cpp b/taglib/ape/apetag.cpp index 16e56c1f..4b020413 100644 --- a/taglib/ape/apetag.cpp +++ b/taglib/ape/apetag.cpp @@ -46,6 +46,13 @@ using namespace APE; class APE::Tag::TagPrivate { public: + TagPrivate() : + file(0), + footerLocation(0) {} + + File *file; + long footerLocation; + Footer footer; ItemListMap itemListMap; }; @@ -64,7 +71,10 @@ APE::Tag::Tag(TagLib::File *file, long footerLocation) : TagLib::Tag(), d(new TagPrivate()) { - read(file, footerLocation); + d->file = file; + d->footerLocation = footerLocation; + + read(); } APE::Tag::~Tag() @@ -325,19 +335,19 @@ bool APE::Tag::isEmpty() const // protected methods //////////////////////////////////////////////////////////////////////////////// -void APE::Tag::read(TagLib::File *file, long footerLocation) +void APE::Tag::read() { - if(file && file->isValid()) { + if(d->file && d->file->isValid()) { - file->seek(footerLocation); - d->footer.setData(file->readBlock(Footer::size())); + d->file->seek(d->footerLocation); + d->footer.setData(d->file->readBlock(Footer::size())); if(d->footer.tagSize() <= Footer::size() || - d->footer.tagSize() > static_cast(file->length())) + d->footer.tagSize() > static_cast(d->file->length())) return; - file->seek(footerLocation + Footer::size() - d->footer.tagSize()); - parse(file->readBlock(d->footer.tagSize() - Footer::size())); + d->file->seek(d->footerLocation + Footer::size() - d->footer.tagSize()); + parse(d->file->readBlock(d->footer.tagSize() - Footer::size())); } } diff --git a/taglib/ape/apetag.h b/taglib/ape/apetag.h index b76419ee..f4d4fba6 100644 --- a/taglib/ape/apetag.h +++ b/taglib/ape/apetag.h @@ -188,7 +188,7 @@ namespace TagLib { /*! * Reads from the file specified in the constructor. */ - void read(TagLib::File *file, long footerLocation); + void read(); /*! * Parses the body of the tag in \a data. diff --git a/taglib/mpeg/id3v1/id3v1tag.cpp b/taglib/mpeg/id3v1/id3v1tag.cpp index 9b724159..ca930411 100644 --- a/taglib/mpeg/id3v1/id3v1tag.cpp +++ b/taglib/mpeg/id3v1/id3v1tag.cpp @@ -42,9 +42,14 @@ class ID3v1::Tag::TagPrivate { public: TagPrivate() : + file(0), + tagOffset(0), track(0), genre(255) {} + File *file; + long tagOffset; + String title; String artist; String album; @@ -89,7 +94,10 @@ ID3v1::Tag::Tag(File *file, long tagOffset) : TagLib::Tag(), d(new TagPrivate()) { - read(file, tagOffset); + d->file = file; + d->tagOffset = tagOffset; + + read(); } ID3v1::Tag::~Tag() @@ -211,12 +219,12 @@ void ID3v1::Tag::setStringHandler(const StringHandler *handler) // protected methods //////////////////////////////////////////////////////////////////////////////// -void ID3v1::Tag::read(File *file, long tagOffset) +void ID3v1::Tag::read() { - if(file && file->isValid()) { - file->seek(tagOffset); + if(d->file && d->file->isValid()) { + d->file->seek(d->tagOffset); // read the tag -- always 128 bytes - const ByteVector data = file->readBlock(128); + const ByteVector data = d->file->readBlock(128); // some initial sanity checking if(data.size() == 128 && data.startsWith("TAG")) diff --git a/taglib/mpeg/id3v1/id3v1tag.h b/taglib/mpeg/id3v1/id3v1tag.h index 9cff408f..b61f06af 100644 --- a/taglib/mpeg/id3v1/id3v1tag.h +++ b/taglib/mpeg/id3v1/id3v1tag.h @@ -183,7 +183,7 @@ namespace TagLib { /*! * Reads from the file specified in the constructor. */ - void read(File *file, long tagOffset); + void read(); /*! * Pareses the body of the tag in \a data. */ diff --git a/taglib/mpeg/id3v2/id3v2tag.cpp b/taglib/mpeg/id3v2/id3v2tag.cpp index b826ecaa..0f0b1a18 100644 --- a/taglib/mpeg/id3v2/id3v2tag.cpp +++ b/taglib/mpeg/id3v2/id3v2tag.cpp @@ -64,7 +64,8 @@ class ID3v2::Tag::TagPrivate { public: TagPrivate() : - fileLength(0), + file(0), + tagOffset(0), extendedHeader(0), footer(0) { @@ -77,9 +78,11 @@ public: delete footer; } - long fileLength; const FrameFactory *factory; + File *file; + long tagOffset; + Header header; ExtendedHeader *extendedHeader; Footer *footer; @@ -121,8 +124,10 @@ ID3v2::Tag::Tag(File *file, long tagOffset, const FrameFactory *factory) : d(new TagPrivate()) { d->factory = factory; + d->file = file; + d->tagOffset = tagOffset; - read(file, tagOffset); + read(); } ID3v2::Tag::~Tag() @@ -620,7 +625,7 @@ ByteVector ID3v2::Tag::render(int version) const else { // Padding won't increase beyond 1% of the file size or 1MB. - long threshold = d->fileLength / 100; + long threshold = d->file ? d->file->length() / 100 : 0; threshold = std::max(threshold, MinPaddingSize); threshold = std::min(threshold, MaxPaddingSize); @@ -634,9 +639,6 @@ ByteVector ID3v2::Tag::render(int version) const d->header.setMajorVersion(version); d->header.setTagSize(tagData.size() - Header::size()); - if(d->fileLength > 0) - d->fileLength += (d->header.tagSize() - originalSize); - // TODO: This should eventually include d->footer->render(). const ByteVector headerData = d->header.render(); std::copy(headerData.begin(), headerData.end(), tagData.begin()); @@ -661,24 +663,22 @@ void ID3v2::Tag::setLatin1StringHandler(const Latin1StringHandler *handler) // protected members //////////////////////////////////////////////////////////////////////////////// -void ID3v2::Tag::read(TagLib::File *file, long offset) +void ID3v2::Tag::read() { - if(!file) + if(!d->file) return; - if(!file->isOpen()) + if(!d->file->isOpen()) return; - d->fileLength = file->length(); - - file->seek(offset); - d->header.setData(file->readBlock(Header::size())); + d->file->seek(d->tagOffset); + d->header.setData(d->file->readBlock(Header::size())); // If the tag size is 0, then this is an invalid tag (tags must contain at // least one frame) if(d->header.tagSize() != 0) - parse(file->readBlock(d->header.tagSize())); + parse(d->file->readBlock(d->header.tagSize())); // Look for duplicate ID3v2 tags and treat them as an extra blank of this one. // It leads to overwriting them with zero when saving the tag. @@ -690,9 +690,9 @@ void ID3v2::Tag::read(TagLib::File *file, long offset) while(true) { - file->seek(offset + d->header.completeTagSize() + extraSize); + d->file->seek(d->tagOffset + d->header.completeTagSize() + extraSize); - const ByteVector data = file->readBlock(Header::size()); + const ByteVector data = d->file->readBlock(Header::size()); if(data.size() < Header::size() || !data.startsWith(Header::fileIdentifier())) break; diff --git a/taglib/mpeg/id3v2/id3v2tag.h b/taglib/mpeg/id3v2/id3v2tag.h index dcd55a0c..4367181f 100644 --- a/taglib/mpeg/id3v2/id3v2tag.h +++ b/taglib/mpeg/id3v2/id3v2tag.h @@ -382,7 +382,7 @@ namespace TagLib { * the Header, the body of the tag (which contains the ExtendedHeader and * frames) and Footer. */ - void read(TagLib::File *file, long offset); + void read(); /*! * This is called by read to parse the body of the tag. It determines if an From a1ac23530ee4e7077135f2ec3a6ff32bd603fefa Mon Sep 17 00:00:00 2001 From: Tsuda Kageyu Date: Thu, 3 Dec 2015 12:34:54 +0900 Subject: [PATCH 32/33] Simpler conversion from bits to bytes. --- taglib/mpeg/id3v2/frames/relativevolumeframe.cpp | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/taglib/mpeg/id3v2/frames/relativevolumeframe.cpp b/taglib/mpeg/id3v2/frames/relativevolumeframe.cpp index 44033cbc..a907f6b9 100644 --- a/taglib/mpeg/id3v2/frames/relativevolumeframe.cpp +++ b/taglib/mpeg/id3v2/frames/relativevolumeframe.cpp @@ -31,11 +31,6 @@ using namespace TagLib; using namespace ID3v2; -static inline int bitsToBytes(int i) -{ - return i % 8 == 0 ? i / 8 : (i - i % 8) / 8 + 1; -} - struct ChannelData { ChannelData() : channelType(RelativeVolumeFrame::Other), volumeAdjustment(0) {} @@ -185,7 +180,6 @@ void RelativeVolumeFrame::parseFields(const ByteVector &data) while(pos <= (int)data.size() - 4) { - ChannelType type = ChannelType(data[pos]); pos += 1; @@ -197,7 +191,7 @@ void RelativeVolumeFrame::parseFields(const ByteVector &data) channel.peakVolume.bitsRepresentingPeak = data[pos]; pos += 1; - int bytes = bitsToBytes(channel.peakVolume.bitsRepresentingPeak); + const int bytes = (channel.peakVolume.bitsRepresentingPeak + 7) / 8; channel.peakVolume.peakVolume = data.mid(pos, bytes); pos += bytes; } From 24f220224d9ee3f4d49b338975031ed3dc759aed Mon Sep 17 00:00:00 2001 From: Tsuda Kageyu Date: Thu, 3 Dec 2015 13:05:18 +0900 Subject: [PATCH 33/33] Move a test to the proper place. The test is actually for XiphComment, not Vorbis::File. --- tests/test_ogg.cpp | 34 ---------------------------------- tests/test_xiphcomment.cpp | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 34 deletions(-) diff --git a/tests/test_ogg.cpp b/tests/test_ogg.cpp index 2469aa15..6e527f0d 100644 --- a/tests/test_ogg.cpp +++ b/tests/test_ogg.cpp @@ -22,7 +22,6 @@ class TestOGG : public CppUnit::TestFixture CPPUNIT_TEST(testDictInterface2); CPPUNIT_TEST(testAudioProperties); CPPUNIT_TEST(testPageChecksum); - CPPUNIT_TEST(testPicture); CPPUNIT_TEST_SUITE_END(); public: @@ -173,39 +172,6 @@ public: } - void testPicture() - { - ScopedFileCopy copy("empty", ".ogg"); - string newname = copy.fileName(); - - Vorbis::File *f = new Vorbis::File(newname.c_str()); - FLAC::Picture *newpic = new FLAC::Picture(); - newpic->setType(FLAC::Picture::BackCover); - newpic->setWidth(5); - newpic->setHeight(6); - newpic->setColorDepth(16); - newpic->setNumColors(7); - newpic->setMimeType("image/jpeg"); - newpic->setDescription("new image"); - newpic->setData("JPEG data"); - f->tag()->addPicture(newpic); - f->save(); - delete f; - - f = new Vorbis::File(newname.c_str()); - List lst = f->tag()->pictureList(); - CPPUNIT_ASSERT_EQUAL((unsigned int)1, lst.size()); - CPPUNIT_ASSERT_EQUAL(int(5), lst[0]->width()); - CPPUNIT_ASSERT_EQUAL(int(6), lst[0]->height()); - CPPUNIT_ASSERT_EQUAL(int(16), lst[0]->colorDepth()); - CPPUNIT_ASSERT_EQUAL(int(7), lst[0]->numColors()); - CPPUNIT_ASSERT_EQUAL(String("image/jpeg"), lst[0]->mimeType()); - CPPUNIT_ASSERT_EQUAL(String("new image"), lst[0]->description()); - CPPUNIT_ASSERT_EQUAL(ByteVector("JPEG data"), lst[0]->data()); - - delete f; - } - }; CPPUNIT_TEST_SUITE_REGISTRATION(TestOGG); diff --git a/tests/test_xiphcomment.cpp b/tests/test_xiphcomment.cpp index 621179fe..475e906e 100644 --- a/tests/test_xiphcomment.cpp +++ b/tests/test_xiphcomment.cpp @@ -20,6 +20,7 @@ class TestXiphComment : public CppUnit::TestFixture CPPUNIT_TEST(testInvalidKeys); CPPUNIT_TEST(testClearComment); CPPUNIT_TEST(testRemoveFields); + CPPUNIT_TEST(testPicture); CPPUNIT_TEST_SUITE_END(); public: @@ -119,6 +120,39 @@ public: CPPUNIT_ASSERT_EQUAL(String("Xiph.Org libVorbis I 20050304"), f.tag()->vendorID()); } + void testPicture() + { + ScopedFileCopy copy("empty", ".ogg"); + string newname = copy.fileName(); + + { + Vorbis::File f(newname.c_str()); + FLAC::Picture *newpic = new FLAC::Picture(); + newpic->setType(FLAC::Picture::BackCover); + newpic->setWidth(5); + newpic->setHeight(6); + newpic->setColorDepth(16); + newpic->setNumColors(7); + newpic->setMimeType("image/jpeg"); + newpic->setDescription("new image"); + newpic->setData("JPEG data"); + f.tag()->addPicture(newpic); + f.save(); + } + { + Vorbis::File f(newname.c_str()); + List lst = f.tag()->pictureList(); + CPPUNIT_ASSERT_EQUAL((unsigned int)1, lst.size()); + CPPUNIT_ASSERT_EQUAL((int)5, lst[0]->width()); + CPPUNIT_ASSERT_EQUAL((int)6, lst[0]->height()); + CPPUNIT_ASSERT_EQUAL((int)16, lst[0]->colorDepth()); + CPPUNIT_ASSERT_EQUAL((int)7, lst[0]->numColors()); + CPPUNIT_ASSERT_EQUAL(String("image/jpeg"), lst[0]->mimeType()); + CPPUNIT_ASSERT_EQUAL(String("new image"), lst[0]->description()); + CPPUNIT_ASSERT_EQUAL(ByteVector("JPEG data"), lst[0]->data()); + } + } + }; CPPUNIT_TEST_SUITE_REGISTRATION(TestXiphComment);