first commit

This commit is contained in:
hehaoyang 2024-01-11 16:14:21 +08:00
commit f2fa0746a2
20 changed files with 1197 additions and 0 deletions

7
.gitignore vendored Normal file
View File

@ -0,0 +1,7 @@
debug/*
release/*
.qmake.stash
HxUtils.pro.*
Makefile*
*.Debug
*.Release

113
HxDisk.cpp Normal file
View File

@ -0,0 +1,113 @@
#include "HxDisk.h"
void HxDisk::mkpath(QString path)
{
QDir dir;
if (!dir.exists(path))
dir.mkpath(path);
}
void HxDisk::mkpath(QStringList names)
{
foreach (QString name, names) {
HxDisk::mkpath(name);
}
}
bool HxDisk::exist(QString rootPath)
{
foreach (const QStorageInfo &storage, QStorageInfo::mountedVolumes())
{
if (rootPath == storage.rootPath())
return true;
}
return false;
}
bool HxDisk::empty(QString path)
{
return QDir(path).removeRecursively();
}
QList<QStorageInfo> HxDisk::mounted_volumes()
{
QList<QStorageInfo> storageinfos;
foreach (const QStorageInfo &storage, QStorageInfo::mountedVolumes())
{
if (storage.isValid() &&
storage.isReady() &&
!storage.rootPath().isNull() &&
!storage.isReadOnly())
{
#ifndef Q_OS_WIN32
if (storage.rootPath() == "/")
continue;
if (storage.fileSystemType() != "ext4")
continue;
#endif
storageinfos.append(storage);
}
}
return storageinfos;
}
double HxDisk::total_size(QString rootPath)
{
foreach (const QStorageInfo &storage, QStorageInfo::mountedVolumes())
{
if (rootPath == storage.rootPath())
return static_cast<double>(storage.bytesTotal()) / 1024 / 1024 / 1024;
}
return 0;
}
double HxDisk::free_size(QString rootPath)
{
foreach (const QStorageInfo &storage, QStorageInfo::mountedVolumes())
{
if (rootPath == storage.rootPath())
return static_cast<double>(storage.bytesAvailable()) / 1024 / 1024 / 1024;
}
return 0;
}
int HxDisk::entry_info_list(QString path)
{
QDir dir(path);
if (!dir.exists())
return 0;
/* 设置过滤器 */
dir.setFilter(QDir::Files | QDir::Dirs | QDir::NoDotAndDotDot);
return dir.entryInfoList().count();
}
void HxDisk::remove(QString filepath)
{
QFileInfo fileinfo(filepath);
if (!fileinfo.exists())
return;
QFile::remove(fileinfo.filePath());
QDir dir(fileinfo.path());
while (entry_info_list(dir.path()) == 0)
{
dir.rmdir(dir.path());
/* 返回上一级目录 */
if (!dir.cdUp())
return;
}
}

65
HxDisk.h Normal file
View File

@ -0,0 +1,65 @@
#ifndef HXDISK_H
#define HXDISK_H
#include "HxTrace.h"
#include <QStorageInfo>
#include <QtGlobal>
class HxDisk
{
public:
/**
* @brief
* @param path
*/
static void mkpath(QString path);
static void mkpath(QStringList names);
/**
* @brief
* @param rootPath
* @return
*/
static bool exist(QString rootPath);
static bool empty(QString path);
/**
* @brief
* @return
*/
static QList<QStorageInfo> mounted_volumes();
/**
* @brief
* @param rootPath
* @return , : G
*/
static double total_size(QString rootPath);
/**
* @brief
* @param rootPath
* @return , : G
*/
static double free_size(QString rootPath);
/**
* @brief
* @param path
* @return
*/
static int entry_info_list(QString path);
/**
* @brief ,
* @param filepath
*/
static void remove(QString filepath);
};
#endif

26
HxLog.cpp Normal file
View File

@ -0,0 +1,26 @@
#include "HxLog.h"
#include <QFile>
#include <QDateTime>
QMutex HxLog::mutex;
void HxLog::append(QString title, QString message)
{
mutex.lock();
auto current_time = QDateTime::currentDateTime();
QFile file(QString("log/%1.log").arg(current_time.toString("yyyyMMdd")));
if (file.open(QIODevice::WriteOnly | QIODevice::Append))
{
auto data = QString("[%1] | [%2] | %3\r\n").arg(current_time.toString("yyyy-MM-dd HH:mm:ss"), title, message);
file.write(data.toLocal8Bit());
file.close();
}
mutex.unlock();
}

15
HxLog.h Normal file
View File

@ -0,0 +1,15 @@
#ifndef HXLOG_H
#define HXLOG_H
#include <QMutex>
class HxLog
{
public:
static void append(QString title, QString message);
private:
static QMutex mutex;
};
#endif // HXLOG_H

40
HxProcess.cpp Normal file
View File

@ -0,0 +1,40 @@
#include "HxProcess.h"
//QString HxProcess::start(QString command)
//{
// QString output;
// auto process = new QProcess();
// process->start("/bin/bash", QStringList() << "-c" << command);
// process->waitForFinished();
// output = QString(process->readAll());
// process->close();
// return output;
//}
QString HxProcess::start(QString command)
{
QString output;
auto array = command.split(" ");
QString program = array.at(0);
QStringList arguments;
for (int i = 1; i < array.count(); i++)
arguments << array.at(i);
QProcess process;
process.setProcessChannelMode(QProcess::MergedChannels);
process.start(program, arguments);
process.waitForFinished();
output = QString(process.readAll());
process.close();
return output;
}

19
HxProcess.h Normal file
View File

@ -0,0 +1,19 @@
#ifndef HXPROCESS_H
#define HXPROCESS_H
#include <QProcess>
#include <HxTrace.h>
class HxProcess
{
public:
/**
* @brief
* @param command
* @return
*/
static QString start(QString command);
};
#endif // HXPROCESS_H

93
HxSocket.cpp Normal file
View File

@ -0,0 +1,93 @@
#include "HxSocket.h"
#include "HxThread.h"
#include <QHostInfo>
HxSocket::HxSocket(quint16 port)
{
connect(&server, &QTcpServer::newConnection, this, &HxSocket::new_connection);
server.listen(QHostAddress::Any, port);
}
HxSocket::HxSocket(QString address, int port)
{
is_reconnect = true;
socket = new QTcpSocket();
connect(socket, &QTcpSocket::readyRead, this, &HxSocket::ready_read);
connect(socket, SIGNAL(disconnected()), this, SLOT(disconnected()), Qt::QueuedConnection);
connect(this, &HxSocket::reconnection_event, this, &HxSocket::reconnection);
/* 域名解析 */
QHostInfo info = QHostInfo::fromName(address);
this->port = port;
this->address = info.addresses().at(0).toString();
reconnection();
}
void HxSocket::new_connection()
{
if (socket != nullptr)
socket->abort();
socket = server.nextPendingConnection();
connect(socket, &QTcpSocket::readyRead, this, &HxSocket::ready_read);
connect(socket, SIGNAL(disconnected()), this, SLOT(disconnected()), Qt::QueuedConnection);
}
void HxSocket::write(QByteArray data)
{
if (socket == nullptr || socket->state() != QTcpSocket::ConnectedState)
return;
data.append('\n');
socket->write(data);
socket->flush();
}
void HxSocket::ready_read()
{
QByteArray msg = socket->readAll();
emit data_receive_event(msg.data());
}
void HxSocket::disconnected()
{
if (is_reconnect)
emit reconnection_event();
}
void HxSocket::reconnection()
{
/* 取消已有的连接 */
if (socket != nullptr)
socket->disconnectFromHost();
/* 连接服务器 */
socket->connectToHost(address, port);
/* 等待连接 */
if (!socket->waitForConnected(500))
{
/* 使用 QThread::msleep 延时,会使 Socket 出现接收不到事件信息 (槽无法响应) */
// auto time = QTime::currentTime().addMSecs(10000);
// while (QTime::currentTime() < time)
// {
// QCoreApplication::processEvents(QEventLoop::AllEvents, 100);
// QThread::msleep(100);
// }
HxThread::sleep(10000);
emit reconnection_event();
}
}

41
HxSocket.h Normal file
View File

@ -0,0 +1,41 @@
#ifndef HXSOCKET_H
#define HXSOCKET_H
#include <QTcpSocket>
#include <QTcpServer>
class HxSocket: public QObject
{
Q_OBJECT
public:
HxSocket(quint16 port);
HxSocket(QString address, int port);
signals:
void data_receive_event(QByteArray data);
void reconnection_event(void);
public slots:
void new_connection();
void write(QByteArray data);
void ready_read();
void disconnected();
/**
* @brief
*/
void reconnection();
private:
int port;
QString address;
bool is_reconnect = false;
QTcpServer server;
QTcpSocket *socket = nullptr;
};
#endif // HXSOCKET_H

38
HxSql.cpp Normal file
View File

@ -0,0 +1,38 @@
#include "HxSql.h"
#include "HxTrace.h"
#include <QDateTime>
#include <QSqlQuery>
#include <QVariant>
#include <QStorageInfo>
QSqlDatabase HxSql::open(QString filepath, QString connectionName)
{
QSqlDatabase database;
if (QSqlDatabase::contains(connectionName))
database = QSqlDatabase::database(connectionName);
else
database = QSqlDatabase::addDatabase("QSQLITE", connectionName);
database.setDatabaseName(filepath);
if (!database.open())
{
QString bk_filepath = filepath + QString(".[%1].bk").arg(QDateTime::currentDateTime().toString("yyyyMMddHHmmss"));
QFile::copy(filepath, bk_filepath);
QFile::remove(filepath);
HxTrace::debug_write_line("database", QString("file backup success. %1 => %2").arg(filepath).arg(bk_filepath));
database.open();
}
return database;
}
void HxSql::close(QString connectionName)
{
QSqlDatabase::removeDatabase(connectionName);
}

24
HxSql.h Normal file
View File

@ -0,0 +1,24 @@
#ifndef HXSQL_H
#define HXSQL_H
#include <QSqlDatabase>
class HxSql
{
public:
/**
* @brief
* @param filepath
* @param connectionName
* @return QSqlDatabase
*/
static QSqlDatabase open(QString filepath, QString connectionName);
/**
* @brief
* @param connectionName
*/
static void close(QString connectionName);
};
#endif // HXSQL_H

218
HxSystem.cpp Normal file
View File

@ -0,0 +1,218 @@
#include "HxSystem.h"
#include "HxProcess.h"
#include <QSettings>
#include <unistd.h>
static double m_memory_total = 0;
static double m_cpu_total = 0, m_cpu_use = 0;
static QMap<QString, QList<double>> m_disk_rw_speed;
QString HxSystem::get_cpu_model()
{
#ifdef Q_OS_LINUX
return HxProcess::start("cat /proc/cpuinfo | grep name | cut -f2 -d: | uniq -c").simplified().remove(0, 1);
#endif
#ifdef Q_OS_WIN
QSettings *CPU = new QSettings("HKEY_LOCAL_MACHINE\\HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0", QSettings::NativeFormat);
return CPU->value("ProcessorNameString").toString();
#endif
return "";
}
int HxSystem::get_logical_cpu_number(){return HxProcess::start("cat /proc/cpuinfo| grep \"processor\"| wc -l").toInt();}
bool HxSystem::get_cpu_temp(double *temp)
{
Q_UNUSED(temp);
#ifdef Q_OS_LINUX
auto result = HxProcess::start("cat /sys/class/thermal/thermal_zone0/temp");
auto data = result.simplified();
if(data.isNull())
return false;
*temp = data.toDouble() / 1000;
return true;
#endif
return false;
}
bool HxSystem::get_cpu_status(double *cpu_rate)
{
Q_UNUSED(cpu_rate);
Q_UNUSED(m_cpu_use);
Q_UNUSED(m_cpu_total);
#ifdef Q_OS_LINUX
auto result = HxProcess::start("cat /proc/stat");
auto list = result.split("\n")[0].simplified().split(" ");
if(list.size() > 3)
{
double use = list[1].toDouble() + list[2].toDouble() + list[3].toDouble();
double total = 0;
for(int i = 1; i < list.size(); i++)
total += list[i].toDouble();
if(total - m_cpu_total > 0)
{
*cpu_rate = (use - m_cpu_use) / (total - m_cpu_total) * 100.0;
m_cpu_total = total;
m_cpu_use = use;
return true;
}
}
#endif
return false;
}
bool HxSystem::get_memory_status(double *memory_use, double *memory_total, double *swap_use, double *swap_total)
{
auto result = HxProcess::start("free -m");
auto list = result.split("\n");
if(list.size() >= 3)
{
auto memory_list = list[1].simplified().split(" ");
auto swap_list = list[2].simplified().split(" ");
if(memory_list.size() >=7)
{
*memory_use = memory_list[2].toDouble();
*memory_total = memory_list[1].toDouble();
m_memory_total = *memory_total;
}
if(swap_list.size() >= 4)
{
*swap_use = swap_list[2].toDouble();
*swap_total = swap_list[1].toDouble();
}
return true;
}
return false;
}
bool HxSystem::get_program_status(double *cpu_usage, double *virtual_memory, double *resident_memory)
{
auto result = HxProcess::start(QString("ps u %1").arg(getpid()));
auto list = result.split("\n");
if(list.size() > 1)
{
auto info = list[1].simplified().split(" ");
*cpu_usage = info[2].toDouble();
*virtual_memory = info[4].toDouble() / 1024 / 1024;
*resident_memory = info[5].toDouble() / 1024;
return true;
}
return false;
}
bool HxSystem::get_harddisk_status(QString disk, QString *file_system, QString *size, QString *use, double *read_speed, double *write_speed)
{
auto result = HxProcess::start(QString("df -h %1").arg(disk));
auto list = result.split("\n");
if(list.size() > 1)
{
auto array = list[1].simplified().split(" ");
*file_system = array[0];
*size = array[1];
*use = array[4];
result = HxProcess::start(QString("iostat -k -d | grep %1").arg((*file_system).split("/").last()));
array = result.simplified().split(" ");
if(array.size() == 6)
{
if(m_disk_rw_speed.contains(*file_system))
{
auto rw_speed = m_disk_rw_speed.value(*file_system);
*read_speed = (array[4].toDouble() - rw_speed[0]);
*write_speed = (array[5].toDouble() - rw_speed[1]);
rw_speed[0] = array[4].toDouble();
rw_speed[1] = array[5].toDouble();
m_disk_rw_speed[*file_system] = rw_speed;
}
else
{
QList<double> values;
values.append(array[4].toDouble());
values.append(array[5].toDouble());
m_disk_rw_speed.insert(*file_system, values);
}
}
return true;
}
return false;
}
bool HxSystem::get_harddisk_temperature(QString file_system, QString *temperature)
{
auto result = HxProcess::start(QString("echo tvis | sudo -S hddtemp '%1'").arg(file_system));
*temperature = result.simplified().split(":").last();
if((*temperature).isEmpty())
return false;
return true;
}
bool HxSystem::get_harddisk_smart(QString file_system, QString *smart)
{
auto result = HxProcess::start(QString("echo tvis | sudo -S smartctl -i %1 | grep 'SMART support is'").arg(file_system));
if(result.indexOf("Unavailable") != -1)
{
*smart = QObject::tr("不支持");
}
else if(result.indexOf("Disabled") != -1)
{
*smart = QObject::tr("未启用");
}
else if(result.indexOf("Available") != -1)
{
result = HxProcess::start(QString("echo tvis | sudo smartctl -H %1 | grep 'SMART overall-health self-assessment test result'").arg(file_system));
if(result.indexOf("PASSED") != -1)
{
*smart = QObject::tr("良好");
}
else
{
*smart = QObject::tr("故障");
}
}
else
return false;
return true;
}

84
HxSystem.h Normal file
View File

@ -0,0 +1,84 @@
#ifndef HXSYSTEM_H
#define HXSYSTEM_H
#include <QObject>
class HxSystem
{
public:
/**
* @brief cpu型号
* @return cpu型号
*/
static QString get_cpu_model();
/**
* @brief CPU的个数
* @return CPU的个数
*/
static int get_logical_cpu_number();
/**
* @brief cpu温度
* @param temp cpu温度
* @return true: ; false ;
*/
static bool get_cpu_temp(double *temp);
/**
* @brief cpu状态
* @param cpu_rate cpu使用率
* @return true: ; false ;
*/
static bool get_cpu_status(double *cpu_rate);
/**
* @brief
* @param memory_use
* @param memory_total
* @param swap_use
* @param swap_total
* @return true: ; false ;
*/
static bool get_memory_status(double *memory_use, double *memory_total, double *swap_use, double *swap_total);
/**
* @brief
* @param cpu_usage CPU使用率
* @param virtual_memory 使
* @param resident_memory 使
* @return true: ; false ;
*/
static bool get_program_status(double *cpu_usage, double *virtual_memory, double *resident_memory);
/**
* @brief
* @param disk
* @param file_system ()
* @param size
* @param use
* @param read_speed
* @param write_speed
* @return true: ; false ;
*/
static bool get_harddisk_status(QString disk, QString *file_system, QString *size, QString *use, double *read_speed, double *write_speed);
/**
* @brief
* @param file_system ()
* @param temperature
* @return true: ; false ;
*/
static bool get_harddisk_temperature(QString file_system, QString *temperature);
/**
* @brief
* @param file_system ()
* @param smart
* @return true: ; false ;
*/
static bool get_harddisk_smart(QString file_system, QString *smart);
};
#endif // HXSYSTEM_H

7
HxTask.cpp Normal file
View File

@ -0,0 +1,7 @@
#include "HxTask.h"
#include <QMap>
#include <QMutex>
QMutex HxTask::mutex;
QMap<QUuid, bool> HxTask::dispatchers;

191
HxTask.h Normal file
View File

@ -0,0 +1,191 @@
#ifndef HXTASK_H
#define HXTASK_H
#include "HxTrace.h"
//#include "HxThread.h"
#include <QtConcurrent>
class HxTask
{
public:
/**
* @brief
* @param uuid
*/
static void stop(QUuid uuid)
{
if (dispatchers.contains(uuid))
{
dispatchers[uuid] = false;
}
}
/**
* @brief
* @param object
* @param fn
*/
template <typename Functor>
static QFuture<void> invoke(Functor functor)
{
return QtConcurrent::run(functor);
}
/**
* @brief
* @param object
* @param fn
*/
template <typename T, typename Class>
static void run(Class *object, T (Class::*fn)())
{
QtConcurrent::run(
[=](Class *_object, T (Class::*_fn)())
{
(_object->*_fn)();
},
object, fn);
}
/**
* @brief 线
* @param uuid
* @param object
* @param fn
* @param millisecond
*/
template <typename T, typename Class>
static void run(QUuid uuid, Class *object, T (Class::*fn)(), int millisecond)
{
dispatchers.insert(uuid, true);
QtConcurrent::run(
[=](QUuid _uuid, Class *_object, T (Class::*_fn)(), int _millisecond)
{
HxTrace::debug_write_line("HxTask", QString("Thread: %1, start").arg(_uuid.toString()));
while (dispatchers[_uuid])
{
(_object->*_fn)();
QThread::msleep(_millisecond);
}
HxTrace::debug_write_line("HxTask", QString("Thread: %1, stop").arg(_uuid.toString()));
dispatchers.remove(_uuid);
},
uuid, object, fn, millisecond);
}
/**
* @brief
* @param object
* @param fn1 1
* @param millisecond1 1
* @param fn2 2
* @param millisecond2 2
* @return
*/
template <typename T, typename Class>
static QUuid invoke(Class *object, T (Class::*fn1)(), int millisecond1, T (Class::*fn2)(), int millisecond2)
{
QUuid uuid = QUuid::createUuid();
HxTask::run(uuid, object, fn1, millisecond1);
HxTask::run(uuid, object, fn2, millisecond2);
return uuid;
}
/**
* @brief
* @param uuid
* @param object
* @param fn1 1
* @param millisecond1 1
* @param fn2 2
* @param millisecond2 2
* @return
*/
template <typename T, typename Class>
static void invoke(QUuid uuid, Class *object, T (Class::*fn1)(), int millisecond1, T (Class::*fn2)(), int millisecond2)
{
HxTask::run(uuid, object, fn1, millisecond1);
HxTask::run(uuid, object, fn2, millisecond2);
}
/**
* @brief
* @param object
* @param fn1 1
* @param millisecond1 1
* @param fn2 2
* @param millisecond2 2
* @param fn3 3
* @param millisecond3 3
* @return
*/
template <typename T, typename Class>
static QUuid invoke(Class *object, T (Class::*fn1)(), int millisecond1, T (Class::*fn2)(), int millisecond2, T (Class::*fn3)(), int millisecond3)
{
QUuid uuid = QUuid::createUuid();
HxTask::run(uuid, object, fn1, millisecond1);
HxTask::run(uuid, object, fn2, millisecond2);
HxTask::run(uuid, object, fn3, millisecond3);
return uuid;
}
/**
* @brief
* @param uuid
* @param object
* @param fn1 1
* @param millisecond1 1
* @param fn2 2
* @param millisecond2 2
* @param fn3 3
* @param millisecond3 3
* @return
*/
template <typename T, typename Class>
static void invoke(QUuid uuid, Class *object, T (Class::*fn1)(), int millisecond1, T (Class::*fn2)(), int millisecond2, T (Class::*fn3)(), int millisecond3)
{
HxTask::run(uuid, object, fn1, millisecond1);
HxTask::run(uuid, object, fn2, millisecond2);
HxTask::run(uuid, object, fn3, millisecond3);
}
private:
/**
* @brief mutex
*/
static QMutex mutex;
/**
* @brief dispatchers
*/
static QMap<QUuid, bool> dispatchers;
};
class HxParalle
{
public:
/**
* @brief
* @param object
* @param fn1 1
* @param fn2 2
*/
template <typename T, typename Class>
static void invoke(Class *object, T (Class::*fn1)(), T (Class::*fn2)())
{
HxTask::run(object, fn1);
HxTask::run(object, fn2);
}
};
#endif // HXTASK_H

40
HxThread.cpp Normal file
View File

@ -0,0 +1,40 @@
#include "HxThread.h"
HxThread::HxThread(int millisecond) { m_wait_time = millisecond; }
void HxThread::stop()
{
m_thread_status = false;
while (!m_stop_flags)
msleep(100);
}
void HxThread::sleep(int millisecond)
{
auto time = QTime::currentTime().addMSecs(millisecond);
while( QTime::currentTime() < time )
QCoreApplication::processEvents(QEventLoop::AllEvents, 100);
}
void HxThread::action() { }
void HxThread::continue_with(){}
void HxThread::run()
{
m_stop_flags = false;
m_thread_status = true;
while (m_thread_status)
{
action();
msleep(m_wait_time);
}
/* Execution at completion */
continue_with();
m_stop_flags = true;
}

60
HxThread.h Normal file
View File

@ -0,0 +1,60 @@
#ifndef HXTHREAD_H
#define HXTHREAD_H
#include <QObject>
#include <QThread>
#include <QtConcurrent>
class HxThread : public QThread
{
Q_OBJECT
public:
/**
* @brief 线
* @param millisecond
*/
HxThread(int millisecond);
/**
* @brief
*/
void stop();
static void sleep(int millisecond);
protected:
/**
* @brief 线
*/
virtual void action();
/**
* @brief 线
*/
virtual void continue_with();
/**
* @brief 线
*/
virtual void run();
protected:
/**
* @brief 线. true: ; false: ;
*/
bool m_thread_status = false;
private:
/**
* @brief 线,
* @
*/
int m_wait_time;
/**
* @brief 线
*/
bool m_stop_flags = true;
};
#endif // HXTHREAD_H

35
HxTrace.cpp Normal file
View File

@ -0,0 +1,35 @@
#include "HxTrace.h"
#include <QDateTime>
void HxTrace::debug_write_line(QString title, QString message)
{
#ifdef QT_DEBUG
qDebug("[%s] [%s] => %s",
qPrintable(QDateTime::currentDateTime().toString("yyyy/MM/dd HH:mm:ss")),
qPrintable(title),
qPrintable(message));
#endif
}
void HxTrace::debug_write_line(QString title, const char *format, ...)
{
#ifdef QT_DEBUG
char output[1024];
va_list arg_list;
va_start(arg_list, format);
// vsprintf(output, format, arg_list);
vsnprintf(output, 1024, format, arg_list);
va_end(arg_list);
qDebug("[%s] [%s] => %s",
qPrintable(QDateTime::currentDateTime().toString("yyyy/MM/dd HH:mm:ss")),
qPrintable(title),
output);
#endif
}

24
HxTrace.h Normal file
View File

@ -0,0 +1,24 @@
#ifndef HXTRACE_H
#define HXTRACE_H
#include <QObject>
class HxTrace
{
public:
/**
* @brief
* @param title
* @param message
*/
static void debug_write_line(QString title, QString message);
/**
* @brief
* @param title
* @param format
*/
static void debug_write_line(QString title, const char *format, ...);
};
#endif // HXTRACE_H

57
HxUtils.pro Normal file
View File

@ -0,0 +1,57 @@
QT -= gui
QT += concurrent
QT += sql
QT += network
TEMPLATE = lib
CONFIG += staticlib
CONFIG += c++11
CONFIG += debug_and_release
unix {
CONFIG(debug, debug|release){
TARGET = debug/HxUtils
} else {
TARGET = release/HxUtils
}
}
# The following define makes your compiler emit warnings if you use
# any Qt feature that has been marked deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS
# You can also make your code fail to compile if it uses deprecated APIs.
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
SOURCES += \
HxDisk.cpp \
HxLog.cpp \
HxProcess.cpp \
HxSocket.cpp \
HxSql.cpp \
HxSystem.cpp \
HxTask.cpp \
HxThread.cpp \
HxTrace.cpp
HEADERS += \
HxDisk.h \
HxLog.h \
HxProcess.h \
HxSocket.h \
HxSql.h \
HxSystem.h \
HxThread.h \
HxTask.h \
HxTrace.h
# Default rules for deployment.
unix {
target.path = $$[QT_INSTALL_PLUGINS]/generic
}
!isEmpty(target.path): INSTALLS += target