/**************************************************************************** ** Copyright (c) 2021, Fougue Ltd. ** All rights reserved. ** See license at https://github.com/fougue/mayo/blob/master/LICENSE.txt ****************************************************************************/ #pragma once #include "../base/filepath_conv.h" #include #include namespace Mayo { // Returns a FilePath object constructed from input inline FilePath filepathFrom(const QByteArray& bytes) { return filepathFrom(std::string_view{ bytes.constData() }); } inline FilePath filepathFrom(const QString& str) { return reinterpret_cast(str.utf16()); } inline FilePath filepathFrom(const QFileInfo& fi) { return filepathFrom(fi.filePath()); } // FilePath -> QByteArray template<> struct FilePathConv { static auto to(const FilePath& fp) { return QByteArray::fromStdString(fp.u8string()); } }; // FilePath -> QString template<> struct FilePathConv { static auto to(const FilePath& fp) { return QString::fromStdString(fp.u8string()); } }; // FilePath -> QFileInfo template<> struct FilePathConv { static auto to(const FilePath& fp) { return QFileInfo(FilePathConv::to(fp)); } }; } // namespace Mayo