Change the size type of containers from uint to size_t

This commit is contained in:
Tsuda Kageyu
2013-03-23 13:42:46 +09:00
parent 83b6fdef72
commit 56c85a2d68
80 changed files with 760 additions and 775 deletions

View File

@ -177,19 +177,19 @@ void APE::Footer::parse(const ByteVector &data)
// Read the version number
d->version = data.mid(8, 4).toUInt(false);
d->version = data.mid(8, 4).toUInt32(false);
// Read the tag size
d->tagSize = data.mid(12, 4).toUInt(false);
d->tagSize = data.mid(12, 4).toUInt32(false);
// Read the item count
d->itemCount = data.mid(16, 4).toUInt(false);
d->itemCount = data.mid(16, 4).toUInt32(false);
// Read the flags
std::bitset<32> flags(TAGLIB_CONSTRUCT_BITSET(data.mid(20, 4).toUInt(false)));
std::bitset<32> flags(TAGLIB_CONSTRUCT_BITSET(data.mid(20, 4).toUInt32(false)));
d->headerPresent = flags[31];
d->footerPresent = !flags[30];
@ -208,15 +208,15 @@ ByteVector APE::Footer::render(bool isHeader) const
// add the version number -- we always render a 2.000 tag regardless of what
// the tag originally was.
v.append(ByteVector::fromUInt(2000, false));
v.append(ByteVector::fromUInt32(2000, false));
// add the tag size
v.append(ByteVector::fromUInt(d->tagSize, false));
v.append(ByteVector::fromUInt32(d->tagSize, false));
// add the item count
v.append(ByteVector::fromUInt(d->itemCount, false));
v.append(ByteVector::fromUInt32(d->itemCount, false));
// render and add the flags
@ -226,11 +226,11 @@ ByteVector APE::Footer::render(bool isHeader) const
flags[30] = false; // footer is always present
flags[29] = isHeader;
v.append(ByteVector::fromUInt(flags.to_ulong(), false));
v.append(ByteVector::fromUInt32(flags.to_ulong(), false));
// add the reserved 64bit
v.append(ByteVector::fromLongLong(0));
v.append(ByteVector::fromUInt64(0));
return v;
}

View File

@ -159,7 +159,7 @@ void APE::Item::appendValues(const StringList &values)
int APE::Item::size() const
{
// SFB: Why is d->key.size() used when size() returns the length in UniChars and not UTF-8?
int result = 8 + d->key.size() /* d->key.data(String::UTF8).size() */ + 1;
size_t result = 8 + d->key.size() /* d->key.data(String::UTF8).size() */ + 1;
switch (d->type) {
case Text:
if(d->text.size()) {
@ -177,7 +177,7 @@ int APE::Item::size() const
result += d->value.size();
break;
}
return result;
return static_cast<int>(result);
}
StringList APE::Item::values() const
@ -216,8 +216,8 @@ void APE::Item::parse(const ByteVector &data)
return;
}
uint valueLength = data.mid(0, 4).toUInt(false);
uint flags = data.mid(4, 4).toUInt(false);
uint valueLength = data.mid(0, 4).toUInt32(false);
uint flags = data.mid(4, 4).toUInt32(false);
d->key = String(data.mid(8), String::UTF8);
@ -253,8 +253,8 @@ ByteVector APE::Item::render() const
else
value.append(d->value);
data.append(ByteVector::fromUInt(value.size(), false));
data.append(ByteVector::fromUInt(flags, false));
data.append(ByteVector::fromUInt32(value.size(), false));
data.append(ByteVector::fromUInt32(flags, false));
data.append(d->key.data(String::UTF8));
data.append(ByteVector('\0'));
data.append(value);

View File

@ -128,7 +128,7 @@ void APE::Properties::read()
ByteVector commonHeader=d->file->readBlock(6);
if(!commonHeader.startsWith("MAC "))
return;
d->version = commonHeader.mid(4).toUInt(false);
d->version = commonHeader.mid(4).toUInt32(false);
if(d->version >= 3980) {
analyzeCurrent();
@ -182,7 +182,7 @@ void APE::Properties::analyzeCurrent()
// Read the descriptor
d->file->seek(2, File::Current);
ByteVector descriptor = d->file->readBlock(44);
uint descriptorBytes = descriptor.mid(0,4).toUInt(false);
uint descriptorBytes = descriptor.mid(0,4).toUInt32(false);
if ((descriptorBytes - 52) > 0)
d->file->seek(descriptorBytes - 52, File::Current);
@ -191,14 +191,14 @@ void APE::Properties::analyzeCurrent()
ByteVector header = d->file->readBlock(24);
// Get the APE info
d->channels = header.mid(18, 2).toShort(false);
d->sampleRate = header.mid(20, 4).toUInt(false);
d->bitsPerSample = header.mid(16, 2).toShort(false);
d->channels = header.mid(18, 2).toInt16(false);
d->sampleRate = header.mid(20, 4).toUInt32(false);
d->bitsPerSample = header.mid(16, 2).toInt16(false);
//d->compressionLevel =
uint totalFrames = header.mid(12, 4).toUInt(false);
uint blocksPerFrame = header.mid(4, 4).toUInt(false);
uint finalFrameBlocks = header.mid(8, 4).toUInt(false);
uint totalFrames = header.mid(12, 4).toUInt32(false);
uint blocksPerFrame = header.mid(4, 4).toUInt32(false);
uint finalFrameBlocks = header.mid(8, 4).toUInt32(false);
d->sampleFrames = totalFrames > 0 ? (totalFrames - 1) * blocksPerFrame + finalFrameBlocks : 0;
d->length = d->sampleRate > 0 ? d->sampleFrames / d->sampleRate : 0;
d->bitrate = d->length > 0 ? static_cast<int>(d->streamLength * 8L / d->length / 1000) : 0;
@ -207,13 +207,13 @@ void APE::Properties::analyzeCurrent()
void APE::Properties::analyzeOld()
{
ByteVector header = d->file->readBlock(26);
uint totalFrames = header.mid(18, 4).toUInt(false);
uint totalFrames = header.mid(18, 4).toUInt32(false);
// Fail on 0 length APE files (catches non-finalized APE files)
if(totalFrames == 0)
return;
short compressionLevel = header.mid(0, 2).toShort(false);
short compressionLevel = header.mid(0, 2).toInt16(false);
uint blocksPerFrame;
if(d->version >= 3950)
blocksPerFrame = 73728 * 4;
@ -221,9 +221,9 @@ void APE::Properties::analyzeOld()
blocksPerFrame = 73728;
else
blocksPerFrame = 9216;
d->channels = header.mid(4, 2).toShort(false);
d->sampleRate = header.mid(6, 4).toUInt(false);
uint finalFrameBlocks = header.mid(22, 4).toUInt(false);
d->channels = header.mid(4, 2).toInt16(false);
d->sampleRate = header.mid(6, 4).toUInt32(false);
uint finalFrameBlocks = header.mid(22, 4).toUInt32(false);
uint totalBlocks = totalFrames > 0 ? (totalFrames - 1) * blocksPerFrame + finalFrameBlocks : 0;
d->length = totalBlocks / d->sampleRate;
d->bitrate = d->length > 0 ? static_cast<int>(d->streamLength * 8L / d->length / 1000) : 0;

View File

@ -360,7 +360,7 @@ ByteVector APE::Tag::render() const
}
d->footer.setItemCount(itemCount);
d->footer.setTagSize(data.size() + Footer::size());
d->footer.setTagSize(static_cast<uint>(data.size() + Footer::size()));
d->footer.setHeaderPresent(true);
return d->footer.renderHeader() + data + d->footer.renderFooter();