unsigned int RIFF::File::chunkCount() const
{
- return d->chunks.size();
+ return static_cast<unsigned int>(d->chunks.size());
}
unsigned int RIFF::File::chunkDataSize(unsigned int i) const
void RIFF::File::removeChunk(const ByteVector &name)
{
- for(int i = d->chunks.size() - 1; i >= 0; --i) {
+ for(int i = static_cast<int>(d->chunks.size()) - 1; i >= 0; --i) {
if(d->chunks[i].name == name)
removeChunk(i);
}
for(TIterator it = dataBegin + offset; it < dataEnd; it += byteAlign) {
if(*it == c)
- return (it - dataBegin);
+ return static_cast<int>(it - dataBegin);
}
return -1;
++itPattern;
if(itPattern == patternEnd)
- return (it - dataBegin);
+ return static_cast<int>(it - dataBegin);
}
}
T sum = 0;
for(size_t i = 0; i < length; i++) {
const size_t shift = (mostSignificantByteFirst ? length - 1 - i : i) * 8;
- sum |= static_cast<T>(static_cast<unsigned char>(v[offset + i])) << shift;
+ sum |= static_cast<T>(static_cast<unsigned char>(v[static_cast<int>(offset + i)])) << shift;
}
return sum;
ByteVector ByteVector::fromCString(const char *s, unsigned int length)
{
if(length == 0xffffffff)
- return ByteVector(s, ::strlen(s));
+ return ByteVector(s, static_cast<unsigned int>(::strlen(s)));
else
return ByteVector(s, length);
}
}
ByteVector::ByteVector(const char *data) :
- d(new ByteVectorPrivate(data, ::strlen(data)))
+ d(new ByteVectorPrivate(data, static_cast<unsigned int>(::strlen(data))))
{
}
if(pattern.size() == 1 && with.size() == 1)
return replace(pattern[0], with[0]);
- const size_t withSize = with.size();
- const size_t patternSize = pattern.size();
- const ptrdiff_t diff = withSize - patternSize;
+ const unsigned int withSize = with.size();
+ const unsigned int patternSize = pattern.size();
+ const int diff = withSize - patternSize;
- size_t offset = 0;
+ unsigned int offset = 0;
while (true) {
offset = find(pattern, offset);
- if(offset == static_cast<size_t>(-1)) // Use npos in taglib2.
+ if(offset == static_cast<unsigned int>(-1))
break;
detach();
// Only return output if we processed all bytes
if(len == 0) {
- output.resize(dst - (unsigned char*) output.data());
+ output.resize(static_cast<unsigned int>(dst - (unsigned char*) output.data()));
return output;
}
return ByteVector();
void debugData(const ByteVector &v)
{
- for(size_t i = 0; i < v.size(); ++i)
- {
- std::string bits = std::bitset<8>(v[i]).to_string();
- String msg = Utils::formatString(
- "*** [%d] - char '%c' - int %d, 0x%02x, 0b%s\n",
+ for(unsigned int i = 0; i < v.size(); ++i) {
+ const std::string bits = std::bitset<8>(v[i]).to_string();
+ const String msg = Utils::formatString(
+ "*** [%u] - char '%c' - int %d, 0x%02x, 0b%s\n",
i, v[i], v[i], v[i], bits.c_str());
debugListener->printMessage(msg);
// to overwrite. Appropriately increment the readPosition.
seek(readPosition);
- const size_t bytesRead = readFile(d->file, aboutToOverwrite);
+ const unsigned int bytesRead = static_cast<unsigned int>(readFile(d->file, aboutToOverwrite));
aboutToOverwrite.resize(bytesRead);
readPosition += bufferLength;
ByteVector buffer(static_cast<unsigned int>(bufferLength));
- for(size_t bytesRead = -1; bytesRead != 0;)
+ for(unsigned int bytesRead = -1; bytesRead != 0;)
{
seek(readPosition);
- bytesRead = readFile(d->file, buffer);
+ bytesRead = static_cast<unsigned int>(readFile(d->file, buffer));
readPosition += bytesRead;
// Check to see if we just read the last block. We need to call clear()
template <class T>
unsigned int List<T>::size() const
{
- return d->list.size();
+ return static_cast<unsigned int>(d->list.size());
}
template <class T>
template <class Key, class T>
unsigned int Map<Key, T>::size() const
{
- return d->map.size();
+ return static_cast<unsigned int>(d->map.size());
}
template <class Key, class T>
#ifdef _WIN32
- len = ::WideCharToMultiByte(CP_UTF8, 0, src, srcLength, dst, dstLength, NULL, NULL);
+ len = ::WideCharToMultiByte(
+ CP_UTF8, 0, src, static_cast<int>(srcLength), dst, static_cast<int>(dstLength), NULL, NULL);
#else
#ifdef _WIN32
- len = ::MultiByteToWideChar(CP_UTF8, 0, src, srcLength, dst, dstLength);
+ len = ::MultiByteToWideChar(
+ CP_UTF8, 0, src, static_cast<int>(srcLength), dst, static_cast<int>(dstLength));
#else
int String::find(const String &s, int offset) const
{
- return d->data.find(s.d->data, offset);
+ return static_cast<int>(d->data.find(s.d->data, offset));
}
int String::rfind(const String &s, int offset) const
{
- return d->data.rfind(s.d->data, offset);
+ return static_cast<int>(d->data.rfind(s.d->data, offset));
}
StringList String::split(const String &separator) const
unsigned int String::size() const
{
- return d->data.size();
+ return static_cast<unsigned int>(d->data.size());
}
unsigned int String::length() const
const size_t len = UTF16toUTF8(
d->data.c_str(), d->data.size(), v.data(), v.size());
- v.resize(len);
+ v.resize(static_cast<unsigned int>(len));
return v;
}
return String();
const size_t pos2 = d->data.find_last_not_of(WhiteSpaceChars);
- return substr(pos1, pos2 - pos1 + 1);
+ return substr(static_cast<unsigned int>(pos1), static_cast<unsigned int>(pos2 - pos1 + 1));
}
bool String::isLatin1() const