2025-06-23 10:41:33 +08:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <QStringList>
|
|
|
|
#include <json.hpp>
|
|
|
|
|
|
|
|
#define TRY try
|
|
|
|
|
|
|
|
#define CATCH(x) catch (json::exception& e){\
|
|
|
|
CommonHelper::handleError(x, e.what());\
|
|
|
|
return true;}\
|
|
|
|
catch (std::exception& e) {\
|
|
|
|
CommonHelper::handleError(x, e.what());\
|
|
|
|
return true;}\
|
2025-06-23 18:01:09 +08:00
|
|
|
catch (...) {CommonHelper::handleError(x, CommonHelper::utf8ToString("系统未知错误"));\
|
2025-06-23 10:41:33 +08:00
|
|
|
return true;}
|
|
|
|
|
|
|
|
class CommonHelper
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CommonHelper();
|
|
|
|
~CommonHelper();
|
|
|
|
|
|
|
|
static bool compareQStringlist(QStringList& a, QStringList& b);
|
|
|
|
static bool convertExcelboolValue(const QString& src, int& dst);
|
|
|
|
static QString convertPropertyValue(const int src);
|
|
|
|
|
|
|
|
static std::string stringToUtf8(const std::string& str);
|
|
|
|
static QString stringToQstring(const std::string& str);
|
|
|
|
static std::string utf8ToStdString(const char* str);
|
|
|
|
static std::string utf8ToStdString(const std::string& str);
|
|
|
|
static const char* utf8ToString(const char* str);
|
|
|
|
static QString utf8ToQString(const char* str);
|
|
|
|
static QString utf8ToQString(std::string&& str);
|
|
|
|
static QString jsonToQString(nlohmann::json& j);
|
|
|
|
static const char* jsonToString(nlohmann::json& j);
|
|
|
|
static std::string qstringToUtf8(const QString& str);
|
|
|
|
static std::string qstringToStdString(const QString& str);
|
|
|
|
static const char* qstringToString(const QString& str);
|
|
|
|
|
|
|
|
static bool intTobool(int b);
|
|
|
|
static void convertExcelInt(const QString& src, int& dst);
|
|
|
|
static QString convertFolderTypeToString(const int type);
|
|
|
|
static QString convertAttributeTypeTpString(const int type);
|
|
|
|
static QString convertInterfaceTypeToStr(const int type);
|
|
|
|
|
|
|
|
static void handleError(nlohmann::json& parameter, const char* error);
|
|
|
|
static void message(const QString& message, int type);
|
|
|
|
|
2025-06-23 18:01:09 +08:00
|
|
|
static bool checkDir(QString fullPath); //检查文件夹是否存在,不存在的话,新建文件夹
|
2025-06-23 10:41:33 +08:00
|
|
|
static void deleteFilesInFolder(const QString& folderPath);
|
|
|
|
};
|