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:
wmayer
2022-03-06 23:49:30 +01:00
parent 26ece78df4
commit 4a343ab31e
30 changed files with 211 additions and 155 deletions

View File

@@ -263,14 +263,19 @@ struct BaseExport Tools
* @param s String to convert.
* @return A std::string encoded as UTF-8.
*/
static inline std::string toStdString(const QString& s) { QByteArray tmp = s.toUtf8(); return std::string(tmp.constData(), tmp.size()); }
static inline std::string toStdString(const QString& s) {
QByteArray tmp = s.toUtf8();
return std::string(tmp.constData(), static_cast<size_t>(tmp.size()));
}
/**
* @brief fromStdString Convert a std::string encoded as UTF-8 into a QString.
* @param s std::string, expected to be UTF-8 encoded.
* @return String represented as a QString.
*/
static inline QString fromStdString(const std::string & s) { return QString::fromUtf8(s.c_str(), s.size()); }
static inline QString fromStdString(const std::string & s) {
return QString::fromUtf8(s.c_str(), static_cast<int>(s.size()));
}
};