2018-09-24 12:34:54 -04:00
|
|
|
#include "QStringUtils.h"
|
2019-05-18 20:38:48 -04:00
|
|
|
#include <QDir>
|
2018-09-24 12:34:54 -04:00
|
|
|
|
|
|
|
template <typename Type>
|
|
|
|
static Type CvtToNativePath(const QString& str);
|
|
|
|
|
|
|
|
template <typename Type>
|
|
|
|
static QString CvtToString(const Type& str);
|
|
|
|
|
|
|
|
template <>
|
2018-09-25 14:25:52 -04:00
|
|
|
std::string CvtToNativePath(const QString& str)
|
2018-09-24 12:34:54 -04:00
|
|
|
{
|
|
|
|
return str.toStdString();
|
|
|
|
}
|
|
|
|
|
|
|
|
template <>
|
2018-09-25 14:25:52 -04:00
|
|
|
std::wstring CvtToNativePath(const QString& str)
|
2018-09-24 12:34:54 -04:00
|
|
|
{
|
|
|
|
return str.toStdWString();
|
|
|
|
}
|
|
|
|
|
|
|
|
template <>
|
2018-09-25 14:25:52 -04:00
|
|
|
QString CvtToString(const std::string& str)
|
2018-09-24 12:34:54 -04:00
|
|
|
{
|
|
|
|
return QString::fromStdString(str);
|
|
|
|
}
|
|
|
|
|
|
|
|
template <>
|
2018-09-25 14:25:52 -04:00
|
|
|
QString CvtToString(const std::wstring& str)
|
2018-09-24 12:34:54 -04:00
|
|
|
{
|
|
|
|
return QString::fromStdWString(str);
|
|
|
|
}
|
|
|
|
|
2019-10-16 20:51:11 -04:00
|
|
|
fs::path QStringToPath(const QString& str)
|
2018-09-24 12:34:54 -04:00
|
|
|
{
|
2019-05-18 20:38:48 -04:00
|
|
|
auto nativeStr = QDir::toNativeSeparators(str);
|
2019-10-16 20:51:11 -04:00
|
|
|
auto result = CvtToNativePath<fs::path::string_type>(nativeStr);
|
|
|
|
return fs::path(result);
|
2018-09-24 12:34:54 -04:00
|
|
|
}
|
|
|
|
|
2019-10-16 20:51:11 -04:00
|
|
|
QString PathToQString(const fs::path& path)
|
2018-09-24 12:34:54 -04:00
|
|
|
{
|
|
|
|
return CvtToString(path.native());
|
|
|
|
}
|