feat : 3.9.7.29

This commit is contained in:
hugy committed 2023-10-17 20:54:52 +08:00
1 parent 9f2b0f9925
commit 2767576351
38 files changed
+18059

No files matched your search

+30
View File
@@ -0,0 +1,30 @@
#ifndef BASE_BASE_CONFIG_H_
#define BASE_BASE_CONFIG_H_
// Lib/Dll switch
#if !defined(BASE_EXPORTS) && !defined(BASE_IMPORTS) && !defined(BASE_STATIC)
#define BASE_STATIC
#endif
#if defined(_MSC_VER)
#ifndef COMPILER_MSVC
#define COMPILER_MSVC 1
#endif
#if defined(BASE_IMPORTS)
#define BASE_API __declspec(dllimport)
#elif defined(BASE_EXPORTS)
#define BASE_API __declspec(dllexport)
#else
#define BASE_API
#endif
#elif defined(__GNUC__)
#define COMPILER_GCC
#define BASE_API
#else
#error "Unknown or unsupported compiler"
#endif
#endif
+23
View File
@@ -0,0 +1,23 @@
#ifndef BASE_SINGLETON_H_
#define BASE_SINGLETON_H_
namespace base {
template <typename T>
class Singleton {
protected:
Singleton() {}
~Singleton() {}
Singleton(const Singleton&) = delete;
Singleton& operator=(const Singleton&) = delete;
Singleton(Singleton&&) = delete;
Singleton& operator=(Singleton&&) = delete;
public:
static T& GetInstance() {
static T instance{};
return instance;
}
};
} // namespace base
#endif
+24
View File
@@ -0,0 +1,24 @@
#ifndef BASE_THREAD_POOL_H_
#define BASE_THREAD_POOL_H_
#include "singleton.h"
#include <windows.h>
namespace base {
class ThreadPool :public Singleton<ThreadPool>{
public:
~ThreadPool();
bool Create(unsigned long min = 1, unsigned long max = 4);
bool AddWork(PTP_WORK_CALLBACK callback,PVOID opt);
private:
PTP_POOL pool_;
PTP_CLEANUP_GROUP cleanup_group_;
TP_CALLBACK_ENVIRON env_;
};
} // namespace wxhelper
#endif
+61
View File
@@ -0,0 +1,61 @@
#ifndef BASE_UTILS_H_
#define BASE_UTILS_H_
#include <windows.h>
#include <string>
#include <vector>
namespace base {
namespace utils {
std::wstring Utf8ToWstring(const std::string &str);
std::string WstringToUtf8(const std::wstring &str);
std::wstring AnsiToWstring(const std::string &input, INT64 locale = CP_ACP);
std::string WstringToAnsi(const std::wstring &input, INT64 locale = CP_ACP);
std::string WcharToUtf8(wchar_t *wstr);
std::string StringToHex(const std::string &str);
std::string HexToString(const std::string &hex_str);
std::string BytesToHex(const BYTE *bytes, const int length);
void HexToBytes(const std::string &hex, BYTE *bytes);
template <typename T1, typename T2>
std::vector<T1> split(T1 str, T2 letter) {
std::vector<T1> arr;
size_t pos;
while ((pos = str.find_first_of(letter)) != T1::npos) {
T1 str1 = str.substr(0, pos);
arr.push_back(str1);
str = str.substr(pos + 1, str.length() - pos - 1);
}
arr.push_back(str);
return arr;
}
template <typename T1, typename T2>
T1 replace(T1 source, T2 replaced, T1 replaceto) {
std::vector<T1> v_arr = split(source, replaced);
if (v_arr.size() < 2) return source;
T1 temp;
for (unsigned int i = 0; i < v_arr.size() - 1; i++) {
temp += v_arr[i];
temp += replaceto;
}
temp += v_arr[v_arr.size() - 1];
return temp;
}
bool CreateConsole();
void CloseConsole();
void HideModule(HMODULE module);
} // namespace utils
} // namespace base
#endif
+5
View File
@@ -0,0 +1,5 @@
#ifndef BASE_WIN_HEADER_H_
#define BASE_WIN_HEADER_H_
#include <windows.h>
#endif