forked from qt-creator/qt-creator
Add std::hash for FileName
Change-Id: Iaef49c826c0febf3a9cb1fdc97de9f92c261cf40 Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
This commit is contained in:
@@ -27,6 +27,8 @@
|
||||
|
||||
#include "utils_global.h"
|
||||
|
||||
#include "hostosinfo.h"
|
||||
|
||||
#include <QCoreApplication>
|
||||
#include <QXmlStreamWriter> // Mac.
|
||||
#include <QMetaType>
|
||||
@@ -233,4 +235,18 @@ QT_BEGIN_NAMESPACE
|
||||
QTCREATOR_UTILS_EXPORT uint qHash(const Utils::FileName &a);
|
||||
QT_END_NAMESPACE
|
||||
|
||||
namespace std {
|
||||
template<> struct hash<Utils::FileName>
|
||||
{
|
||||
using argument_type = Utils::FileName;
|
||||
using result_type = size_t;
|
||||
result_type operator()(const argument_type &fn) const
|
||||
{
|
||||
if (Utils::HostOsInfo::fileNameCaseSensitivity() == Qt::CaseInsensitive)
|
||||
return hash<string>()(fn.toString().toUpper().toStdString());
|
||||
return hash<string>()(fn.toString().toStdString());
|
||||
}
|
||||
};
|
||||
} // namespace std
|
||||
|
||||
Q_DECLARE_METATYPE(Utils::FileName)
|
||||
|
||||
Reference in New Issue
Block a user