mirror of
https://github.com/taglib/taglib.git
synced 2025-06-03 00:58:12 -04:00
Suppress MSVC warnings about narrowing conversions.
This commit is contained in:
parent
ee7fa78011
commit
f5ce498182
@ -95,7 +95,7 @@ unsigned int RIFF::File::riffSize() const
|
||||
|
||||
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
|
||||
@ -269,7 +269,7 @@ void RIFF::File::removeChunk(unsigned int i)
|
||||
|
||||
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);
|
||||
}
|
||||
|
@ -63,7 +63,7 @@ int findChar(
|
||||
|
||||
for(TIterator it = dataBegin + offset; it < dataEnd; it += byteAlign) {
|
||||
if(*it == c)
|
||||
return (it - dataBegin);
|
||||
return static_cast<int>(it - dataBegin);
|
||||
}
|
||||
|
||||
return -1;
|
||||
@ -105,7 +105,7 @@ int findVector(
|
||||
++itPattern;
|
||||
|
||||
if(itPattern == patternEnd)
|
||||
return (it - dataBegin);
|
||||
return static_cast<int>(it - dataBegin);
|
||||
}
|
||||
}
|
||||
|
||||
@ -125,7 +125,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<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;
|
||||
@ -300,7 +300,7 @@ ByteVector ByteVector::null;
|
||||
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);
|
||||
}
|
||||
@ -375,7 +375,7 @@ ByteVector::ByteVector(const char *data, unsigned int length) :
|
||||
}
|
||||
|
||||
ByteVector::ByteVector(const char *data) :
|
||||
d(new ByteVectorPrivate(data, ::strlen(data)))
|
||||
d(new ByteVectorPrivate(data, static_cast<unsigned int>(::strlen(data))))
|
||||
{
|
||||
}
|
||||
|
||||
@ -493,14 +493,14 @@ ByteVector &ByteVector::replace(const ByteVector &pattern, const ByteVector &wit
|
||||
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();
|
||||
@ -963,7 +963,7 @@ ByteVector ByteVector::fromBase64(const ByteVector & input)
|
||||
|
||||
// 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();
|
||||
|
@ -50,11 +50,10 @@ namespace TagLib
|
||||
|
||||
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);
|
||||
|
@ -261,7 +261,7 @@ void FileStream::insert(const ByteVector &data, unsigned long start, unsigned lo
|
||||
// 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;
|
||||
|
||||
@ -304,10 +304,10 @@ void FileStream::removeBlock(unsigned long start, unsigned long length)
|
||||
|
||||
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()
|
||||
|
@ -196,7 +196,7 @@ List<T> &List<T>::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>
|
||||
|
@ -152,7 +152,7 @@ Map<Key, T> &Map<Key,T>::erase(const Key &key)
|
||||
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>
|
||||
|
@ -54,7 +54,8 @@ namespace
|
||||
|
||||
#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
|
||||
|
||||
@ -86,7 +87,8 @@ namespace
|
||||
|
||||
#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
|
||||
|
||||
@ -410,12 +412,12 @@ String::ConstIterator String::end() const
|
||||
|
||||
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
|
||||
@ -479,7 +481,7 @@ String String::upper() const
|
||||
|
||||
unsigned int String::size() const
|
||||
{
|
||||
return d->data.size();
|
||||
return static_cast<unsigned int>(d->data.size());
|
||||
}
|
||||
|
||||
unsigned int String::length() const
|
||||
@ -518,7 +520,7 @@ ByteVector String::data(Type t) 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;
|
||||
}
|
||||
@ -604,7 +606,7 @@ String String::stripWhiteSpace() const
|
||||
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
|
||||
|
Loading…
x
Reference in New Issue
Block a user