Base/App: fix warnings from code analysers:
* convert old-style-casts to explicit C++ casts where possible * make some implicit conversions explicit
This commit is contained in:
@@ -89,28 +89,28 @@ unsigned int StdInputStream::readBytes( XMLByte* const toFill, const unsigned i
|
||||
#else
|
||||
XMLFilePos StdInputStream::curPos() const
|
||||
{
|
||||
return stream.tellg();
|
||||
return static_cast<XMLFilePos>(stream.tellg());
|
||||
}
|
||||
|
||||
XMLSize_t StdInputStream::readBytes( XMLByte* const toFill, const XMLSize_t maxToRead )
|
||||
XMLSize_t StdInputStream::readBytes(XMLByte* const toFill, const XMLSize_t maxToRead)
|
||||
{
|
||||
//
|
||||
// Read up to the maximum bytes requested. We return the number
|
||||
// actually read.
|
||||
//
|
||||
|
||||
stream.read((char *)toFill,maxToRead);
|
||||
XMLSize_t len = stream.gcount();
|
||||
stream.read(reinterpret_cast<char *>(toFill), static_cast<std::streamsize>(maxToRead));
|
||||
std::streamsize len = stream.gcount();
|
||||
|
||||
QTextCodec *codec = QTextCodec::codecForName("UTF-8");
|
||||
const QString text = codec->toUnicode((char *)toFill, len, &state);
|
||||
const QString text = codec->toUnicode(reinterpret_cast<char *>(toFill), static_cast<int>(len), &state);
|
||||
if (state.invalidChars > 0) {
|
||||
// In case invalid characters were found decode back to 'utf-8' and replace
|
||||
// them with '?'
|
||||
// First, Qt replaces invalid characters with '\0' (see ConvertInvalidToNull)
|
||||
// but Xerces doesn't like this because it handles this as termination. Thus,
|
||||
// we have to go through the array and replace '\0' with '?'.
|
||||
XMLSize_t pos = 0;
|
||||
std::streamsize pos = 0;
|
||||
QByteArray ba = codec->fromUnicode(text);
|
||||
for (int i=0; i<ba.length(); i++, pos++) {
|
||||
if (pos < len && ba[i] == '\0')
|
||||
@@ -118,7 +118,7 @@ XMLSize_t StdInputStream::readBytes( XMLByte* const toFill, const XMLSize_t max
|
||||
}
|
||||
}
|
||||
|
||||
return len;
|
||||
return static_cast<XMLSize_t>(len);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user