并入zoost库。

This commit is contained in:
2026-03-29 19:02:44 +08:00
parent 4419d606a8
commit 1346521ad0
269 changed files with 114399 additions and 12 deletions

9
include/zoost/zoost.h Normal file
View File

@@ -0,0 +1,9 @@
#ifndef ZOOST_H
#define ZOOST_H
#include "zoost/zt.common.h"
#include "zoost/zt.define.hpp"
#include "zoost/zt.mem.h"
#include "zoost/zt.utils.h"
#endif // ZOOST_H

18
include/zoost/zt.common.h Normal file
View File

@@ -0,0 +1,18 @@
#ifndef ZOOST_COMMON_H
#define ZOOST_COMMON_H
#include <string>
class zoostCommon
{
public:
zoostCommon() = default;
public:
static void SetStdLibrayU8();
static void SetOutputU8();
static void ToU8(std::string& str);
static std::string ToU8Copy(const std::string& str);
};
#endif // ZOOST_COMMON_H

View File

@@ -0,0 +1,16 @@
#ifndef ZT_DEFINE_H
#define ZT_DEFINE_H
#if defined(_WIN32) || defined(_WIN64)
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include "zoost/zt.os_win.h"
#else
#include <unistd.h>
#endif
#include <filesystem>
namespace zoostFs = std::filesystem;
#endif

27
include/zoost/zt.mem.h Normal file
View File

@@ -0,0 +1,27 @@
#ifndef ZOOST_MEM_H
#define ZOOST_MEM_H
#include <mutex>
#include <vector>
class zoostMutBuffer
{
public:
zoostMutBuffer() = default;
zoostMutBuffer(const zoostMutBuffer&) = delete;
zoostMutBuffer& operator=(const zoostMutBuffer&) = delete;
public:
void Push(const char* data, int size);
int IndexOf(const char* data, int size, int start = 0);
const char* Data() const;
int GetSize() const;
void RemoveOf(int start, int size);
void Clear();
private:
std::vector<char> buffer_;
std::mutex mutex_;
};
#endif // ZOOST_MEM_H

44
include/zoost/zt.os_win.h Normal file
View File

@@ -0,0 +1,44 @@
#ifndef ZOOST_OS_WIN_H
#define ZOOST_OS_WIN_H
#include <functional>
#include <string>
class zoostWinService
{
public:
static std::string GetLastErrorMsg();
static bool WinInstallService();
static bool WinUninstallService();
static bool WinStartService();
static bool WinStopService();
static void WinServiceRun();
static void ExportEventMsg(const std::string& msg);
public:
// 服务名称。
static std::string serviceName_;
// 服务描述
static std::string dispName_;
// 程序路径
static std::string exePath_;
// 默认 5000 毫秒执行一次 exeFunc_。
static unsigned int timeoutVal;
// exeFunc_ 是周期执行的函数,必须设定,不能为空指针。
static std::function<void()> exeFunc_;
// stopFunc_ 必须设定,不能为空指针。
static std::function<void()> stopFunc_;
};
class zoostWinUtil
{
public:
zoostWinUtil() = default;
~zoostWinUtil() = default;
public:
static std::string U82Ansi(const std::string& str);
static std::string Ansi2U8(const std::string& str);
};
#endif // ZOOST_OS_WIN_H

51
include/zoost/zt.utils.h Normal file
View File

@@ -0,0 +1,51 @@
#ifndef ZOOST_UTILS_H
#define ZOOST_UTILS_H
#include <string>
struct zoostDateTime {
int year{};
int mon{};
int day{};
int hour{};
int min{};
int sec{};
int msec{};
};
class zoostPath
{
public:
zoostPath();
public:
bool CreateConfigDir(const std::string& appName);
bool GetConfigDir(const std::string& appName, std::string& dir);
bool GetBinaryPath(std::string& path);
bool GetBinaryDir(std::string& dir);
bool GetHome(std::string& path);
bool GetConfigFile(const std::string& appName, const std::string& fileName, std::string& path);
void SetConfigDirName(const std::string& name);
void SetConfigDir(const std::string& path);
std::string GetParentPath(const std::string& path);
std::string GetErrorMsg() const;
private:
std::string configDir_{};
std::string configDirName_{".config"};
std::string errMsg_;
};
class zoostUtils
{
public:
static zoostDateTime CurrentTime();
static void SetConfigDir(const std::string& path);
public:
static std::string gConfigDir;
};
#endif // ZOOST_UTILS_H