修复编码问题

This commit is contained in:
xx
2024-05-29 00:00:47 +08:00
parent a37c260780
commit 6d61223921
190 changed files with 155 additions and 3233 deletions

View File

@@ -1,4 +1,4 @@
#pragma once
#pragma once
#include <string>
#include "define.h"
#include "base/buffer.h"

View File

@@ -1,4 +1,4 @@
#pragma once
#pragma once
#include "typedef.h"
#include "exception.h"

View File

@@ -1,4 +1,4 @@
#pragma once
#pragma once
#include <map>
#include <string>
#include <mutex>

View File

@@ -1,4 +1,4 @@
#pragma once
#pragma once
#include <string>
#include <iostream>

View File

@@ -1,4 +1,4 @@
#pragma once
#pragma once
#include <string>
#include <exception>

View File

@@ -1,4 +1,4 @@
#pragma once
#pragma once
#include "define.h"
namespace ylib

View File

@@ -1,4 +1,4 @@
#pragma once
#pragma once
#include <string>
#include <iostream>

View File

@@ -1,4 +1,4 @@
#pragma once
#pragma once
/***************************************************[类型]***************************************************/
typedef int int32;

View File

@@ -1,4 +1,4 @@
#pragma once
#pragma once
#ifdef _WIN32
#include <vector>
#include <string>

View File

@@ -1,4 +1,4 @@
#pragma once
#pragma once
#include <vector>
#include <string>

View File

@@ -1,4 +1,4 @@
#pragma once
#pragma once
#include "base/error.h"
#include "mysql.h"
#include <any>

View File

@@ -1,4 +1,4 @@
#pragma once
#pragma once
#include "base/define.h"
#include "base/error.h"
#include "base/buffer.h"

View File

@@ -1,4 +1,4 @@
#pragma once
#pragma once
#include "define.h"
#include "util/file.h"
#include "util/thread.h"

View File

@@ -1,4 +1,4 @@
#pragma once
#pragma once
#include "http_define.h"
#include "util/cache.h"
#if USE_NET_HTTP_WEBSITE

View File

@@ -1,4 +1,4 @@
#pragma once
#pragma once
#include "http_define.h"
#include "http_reqpack.h"
#include "http_interface.h"

View File

@@ -1,4 +1,4 @@
#pragma once
#pragma once
#include "http_define.h"
#include "http_reqpack.h"
#include "http_interface.h"

View File

@@ -1,4 +1,4 @@
#pragma once
#pragma once
#include "http_define.h"
#if USE_NET_HTTP_WEBSITE
#include <functional>

View File

@@ -1,4 +1,4 @@
#pragma once
#pragma once
#include "http_define.h"
#if USE_NET_HTTP_CLIENT
namespace ylib

View File

@@ -1,4 +1,4 @@
#pragma once
#pragma once
#include "http_define.h"
#if USE_NET_HTTP_CLIENT
#include <functional>

View File

@@ -1,4 +1,4 @@
#pragma once
#pragma once
#include "http_define.h"
#if USE_NET_HTTP_WEBSITE
#include "http_request.h"

View File

@@ -1,4 +1,4 @@
#pragma once
#pragma once
#include "http_define.h"
#if USE_NET_HTTP_UTIL
#include <map>

View File

@@ -1,4 +1,4 @@
#pragma once
#pragma once
#include <vector>
#include <map>
#include <regex>

View File

@@ -1,4 +1,4 @@
#pragma once
#pragma once
#include "define.h"
#if USE_NET_HTTP_UTIL
#include <map>

View File

@@ -1,4 +1,4 @@
#pragma once
#pragma once
#include "define.h"
#if USE_NET_HTTP_WEBSITE
#include "net/http_interface.h"

View File

@@ -1,4 +1,4 @@
#pragma once
#pragma once
#include "define.h"
#if USE_NET_HTTP_WEBSITE
#include <regex>

View File

@@ -1,4 +1,4 @@
#pragma once
#pragma once
#include "http_define.h"
#if USE_NET_HTTP_WEBSITE
#include <functional>

View File

@@ -1,4 +1,4 @@
#pragma once
#pragma once
#include "http_define.h"
#if USE_NET_HTTP_WEBSITE
#include <map>

View File

@@ -1,4 +1,4 @@
#pragma once
#pragma once
#include "http_define.h"
#if USE_NET_HTTP_WEBSITE
#include "http_server.h"

View File

@@ -1,4 +1,4 @@
#pragma once
#pragma once
#include "http_define.h"
#if USE_NET_HTTP_WEBSITE
#include <string>

View File

@@ -1,4 +1,4 @@
#pragma once
#pragma once
#include "http_define.h"
#if USE_NET_HTTP_WEBSITE
#include <string>

View File

@@ -1,4 +1,4 @@
#pragma once
#pragma once
#include "http_define.h"
#if USE_NET_HTTP_WEBSITE
#include "http_interface.h"

View File

@@ -1,4 +1,4 @@
#pragma once
#pragma once
#include "http_define.h"
#if USE_NET_HTTP_WEBSITE
#include <string>

View File

@@ -1,4 +1,4 @@
#pragma once
#pragma once
#include "http_define.h"
#if USE_NET_HTTP_WEBSITE
#include "HPSocket/HPSocket.h"

View File

@@ -1,4 +1,4 @@
#pragma once
#pragma once
#include "http_define.h"
#if USE_NET_HTTP_WEBSITE
#include <map>

View File

@@ -1,4 +1,4 @@
#pragma once
#pragma once
#include "http_define.h"
#if USE_NET_HTTP_WEBSITE
#include <functional>

View File

@@ -1,4 +1,4 @@
#pragma once
#pragma once
#include "http_define.h"
#if USE_NET_HTTP_UTIL
#include <functional>

View File

@@ -1,4 +1,4 @@
#pragma once
#pragma once
#include "http_define.h"
#if USE_NET_HTTP_UTIL

View File

@@ -1,4 +1,4 @@
#pragma once
#pragma once
#include <mutex>
#include "base/define.h"
#include "util/system.h"

View File

@@ -1,4 +1,4 @@
#pragma once
#pragma once
#include <string>
#include "base/define.h"
#include "base/buffer.h"

View File

@@ -1,4 +1,4 @@
#pragma once
#pragma once
#include <string>
#include "base/define.h"
#include "base/buffer.h"

View File

@@ -1,4 +1,4 @@
#pragma once
#pragma once
#include "define.h"
#ifdef USE_NET_TCP_AGENT
#include <string.h>

View File

@@ -1,4 +1,4 @@
#pragma once
#pragma once
#include "define.h"
#ifdef USE_NET_TCP_CLIENT
#include <string>

View File

@@ -1,4 +1,4 @@
#pragma once
#pragma once
#include "define.h"
#ifdef USE_NET_TCP_CLIENT
#include <string.h>

View File

@@ -1,4 +1,4 @@
#pragma once
#pragma once
#include "net/tcp2tcp.h"
#include "util/map.hpp"
namespace ylib

View File

@@ -1,4 +1,4 @@
#pragma once
#pragma once
#include <functional>
#include "net/define.h"
#include "base/error.h"

View File

@@ -1,4 +1,4 @@
#pragma once
#pragma once
#include "net/define.h"
#ifdef USE_NET_TCP_SERVER
#include "HPSocket/HPSocket.h"

View File

@@ -1,4 +1,4 @@
#pragma once
#pragma once
#include <string>
#include "base/define.h"
#include "base/buffer.h"

View File

@@ -1,4 +1,4 @@
#pragma once
#pragma once
#include "net/define.h"
#if USE_NET_UDP_NODE
#include <functional>

View File

@@ -1,4 +1,4 @@
#pragma once
#pragma once
#include "net/define.h"
#if USE_NET_UDP_NODE
#include "HPSocket/HPSocket.h"

View File

@@ -1,4 +1,4 @@
#pragma once
#pragma once
#include "http_define.h"
#if USE_NET_HTTP_UTIL
#include <string>

View File

@@ -1,4 +1,4 @@
#pragma once
#pragma once
#include "base/define.h"
#include "base/buffer.h"
#include "util/map.hpp"

View File

@@ -1,4 +1,4 @@
#pragma once
#pragma once
#include "ybase/define.h"
#include "yutil/array.hpp"
#include <vector>

View File

@@ -1,4 +1,4 @@
#pragma once
#pragma once
#include <vector>
namespace ylib
{

View File

@@ -1,4 +1,4 @@
#pragma once
#pragma once
#include "base/define.h"
#include "base/error.h"

View File

@@ -1,4 +1,4 @@
#pragma once
#pragma once
#include <string>
#include "base/buffer.h"

View File

@@ -1,4 +1,4 @@
#pragma once
#pragma once
#include <mutex>
namespace ylib {
template<typename T>

View File

@@ -1,4 +1,4 @@
#pragma once
#pragma once
#include <string>
namespace ylib
{

View File

@@ -1,4 +1,4 @@
#pragma once
#pragma once
#ifdef _WIN32
#include <vector>
#include "util/system.h"

View File

@@ -1,4 +1,4 @@
#pragma once
#pragma once
#include <string>

View File

@@ -1,4 +1,4 @@
#pragma once
#pragma once
#include <string>
#include <vector>
#include <functional>

View File

@@ -1,4 +1,4 @@
#pragma once
#pragma once
#include "base/define.h"
#include "base/buffer.h"

View File

@@ -1,4 +1,4 @@
#pragma once
#pragma once
#include <string>
#include <vector>
#include "util/json.h"

View File

@@ -1,4 +1,4 @@
#pragma once
#pragma once
#include <mutex>
#include "yutil/time.h"
namespace ylib {

View File

@@ -1,4 +1,4 @@
#pragma once
#pragma once
#include <vector>
#include <string>
#include <iostream>

View File

@@ -1,4 +1,4 @@
#pragma once
#pragma once
#include <string>
#include <vector>
#include "util/json.h"

View File

@@ -1,4 +1,4 @@
#pragma once
#pragma once
#include <map>
#include <mutex>
#include <functional>

View File

@@ -1,2 +1,2 @@
#pragma once
#pragma once
#include "base/define.h"

View File

@@ -1,4 +1,4 @@
#pragma once
#pragma once
#include <stdio.h>
#include "base/define.h"

View File

@@ -1,4 +1,4 @@
#pragma once
#pragma once
#include "base/buffer.h"
#include "util/map.hpp"
namespace ylib

View File

@@ -1,4 +1,4 @@
#pragma once
#pragma once
#include <iostream>
#include <mutex>

View File

@@ -1,4 +1,4 @@
#pragma once
#pragma once
#include <string>
#include "base/define.h"
namespace ylib

View File

@@ -1,4 +1,4 @@
#pragma once
#pragma once
#include <functional>
#include <list>
#include <string>

View File

@@ -1,4 +1,4 @@
#pragma once
#pragma once
#include <queue>
#include <stdio.h>
#include <mutex>

View File

@@ -1,4 +1,4 @@
#pragma once
#pragma once
#include "sqlite3/sqlite3.h"
#include "base/define.h"
#include "base/error.h"

View File

@@ -1,4 +1,4 @@
#pragma once
#pragma once
#include <string>
#include <vector>
#include "base/define.h"

View File

@@ -1,4 +1,4 @@
#pragma once
#pragma once
#include <vector>
#include "base/define.h"
namespace ylib

View File

@@ -1,4 +1,4 @@
#pragma once
#pragma once
#include <functional>
#include <thread>
#include "json.h"

View File

@@ -1,4 +1,4 @@
#pragma once
#pragma once
#include <map>

View File

@@ -1,4 +1,4 @@
#pragma once
#pragma once
#include <iostream>
#include <functional>
#include <string>

View File

@@ -1,4 +1,4 @@
#pragma once
#pragma once
#include <vector>
#include <functional>
namespace ylib

View File

@@ -1,4 +1,4 @@
#pragma once
#pragma once
#ifdef _WIN32
#include <vector>

View File

@@ -16,7 +16,6 @@ if(MSVC)
set(MYSQL_CPPCONN_INCLUDE CACHE PATH "mysql-connector include")
include_directories(${MYSQL_CPPCONN_INCLUDE})
include_directories(${PROJECT_SOURCE_DIR}/3rdparty/HP-Socket/Windows/Include)
add_compile_options(/utf-8)
endif()
# Add the executable or library target

View File

@@ -1,4 +1,4 @@
#include "base/buffer.h"
#include "base/buffer.h"
#include <memory>
#include <exception>
#include <cstring>

View File

@@ -1,93 +0,0 @@
#pragma once
#include <string>
#include <vector>
#include "ybase/define.h"
namespace ylib
{
class mem_pool
{
public:
mem_pool(size_t initial_length = 1024);
~mem_pool();
void append(const uchar* data,size_t length);
void clear();
size_t length() const;
uchar* data() const;
void resize(size_t length);
void set(const uchar* data,size_t length);
bool empty() const;
private:
void renew(size_t length);
public:
// 内存数据指针
uchar* m_data = nullptr;
// 内存长度
size_t m_length = 0;
// 使用长度
size_t m_use_length = 0;
};
/**
* @brief BUFF字节流
*/
class buffer
{
public:
buffer(size_t initial_length = 1024);
buffer(char data, size_t len);
buffer(const char* data,size_t len);
buffer(const ylib::buffer& data);
buffer(const std::string& data);
buffer(std::initializer_list<uchar> char_list);
~buffer();
void set(const char* data, size_t length);
void set(const ylib::buffer& data);
void append(const std::string& data);
void append(const char* data, size_t length);
void append(const ylib::buffer& data);
void append(std::initializer_list<uchar> char_list);
template<typename T>
void append(const T& value) {
append((const char*)&value, sizeof(T));
}
void clear();
void resize(size_t length);
size_t find(const char* data, size_t len, size_t start_pos = 0) const;
size_t find(const ylib::buffer& data, size_t start_pos = 0) const;
std::vector<size_t> find_list(const ylib::buffer& value, size_t start = 0) const;
std::vector<ylib::buffer> split(const ylib::buffer& value, size_t start = 0) const;
std::string to_string() const;
bool empty() const;
ylib::buffer left(size_t len) const;
ylib::buffer right(size_t len) const;
ylib::buffer sub(size_t start,size_t len) const;
ylib::buffer sub(size_t start) const;
//ylib::buffer sub(size_t start,size_t len);
operator std::string() const;
ylib::buffer operator+(const ylib::buffer& other) const;
ylib::buffer& operator=(const std::string& data);
ylib::buffer& operator=(const ylib::buffer& data);
unsigned char& operator[](size_t index) const;
const char* data() const;
const size_t length() const;
const size_t size() const { return length(); };
ylib::buffer trim_end(char value);
ylib::buffer trim_begin(char value);
ylib::buffer trim(char value);
std::string to_hex();
size_t& cursor(){ return m_cursor; }
private:
ylib::mem_pool m_data;
size_t m_cursor = 0;
};
}

View File

@@ -1,4 +1,4 @@
#include "base/conversion.h"
#include "base/conversion.h"
#include "base/error.h"
#include <cmath>
#include <sstream>

View File

@@ -1,36 +0,0 @@
#pragma once
#include <string>
#include "define.h"
#include "ybase/buffer.h"
namespace ylib
{
int32 stoi(const std::string& value);
int32 stoi(char value);
uint64 stoull(const std::string& value);
int64 stoll(const std::string& value);
double stod(const std::string& value);
float stof(const std::string& value);
//保留小数点
std::string to_fixed(double num, uint32 x);
namespace bytes{
/*流转*/
void to_int(int32& dest, const char* src, bool reverse = false);
void to_uint(uint32& dest, const char* src, bool reverse = false);
void to_short(short& dest, const char* src, bool reverse = false);
void to_ushort(ushort& dest, const char* src, bool reverse = false);
void to_char(char* dest, short src, bool reverse = false);
void to_char(char* dest, int32 src, bool reverse = false);
void to_char(char* dest, int64 src, bool reverse = false);
ylib::buffer to_buffer(short src, bool reverse = false);
ylib::buffer to_buffer(int32 src, bool reverse = false);
ylib::buffer to_buffer(int64 src, bool reverse = false);
ylib::buffer to_buffer(uchar src);
// 反转
void reverse(void* dest, size_t length);
void to_uint64(uint64& dest, const char* src, bool reverse = false);
void to_int64(int64& dest, const char* src, bool reverse = false);
}
}

View File

@@ -1,150 +0,0 @@
#pragma once
#include "typedef.h"
#include "exception.h"
#include "error.h"
// 是否DEBUG调试内存申请情况
#define DEBUG_MEM 0
using namespace ylib;
// 斜杆
#ifdef _WIN32
#define SEPRATOR std::string("\\")
#else
#define SEPRATOR std::string("/")
#endif
// 遍历STL
#define for_iter(LOOP_VAR,LOOP_NUM) for(auto LOOP_VAR = LOOP_NUM.begin();LOOP_VAR != LOOP_NUM.end();LOOP_VAR++)
#define for_riter(LOOP_VAR,LOOP_NUM) for(auto LOOP_VAR = LOOP_NUM.rbegin();LOOP_VAR != LOOP_NUM.rend();LOOP_VAR++)
// 抛出异常
//#define THROW_FORMAT(DATA,...) throw std::exception(std::format(DATA,__VA_ARGS__).c_str())
#ifdef YLIB_STATIC
#define YLIB_API
#else
#define NEWOBJ_EXPORT_API __declspec(dllexport)
#ifdef EXPORT_DLL
#define C_DLL_HEADER extern "C" __declspec(dllexport)
#else
#define C_DLL_HEADER extern "C" __declspec(dllimport)
#endif
#define C_CALL __stdcall
#endif
#define ylib_max(a,b) (((a) > (b)) ? (a) : (b))
#define ylib_min(a,b) (((a) < (b)) ? (a) : (b))
/**
* @brief 定义命名空间 ylib
*/
namespace ylib {
/**
* @brief 定义一个矩形结构体
*
* 包含四个成员变量left, top, right, bottom用于表示矩形的位置和大小。
* 构造函数初始化了这四个变量的值为0。
*/
struct Rect{
Rect() { left = 0; top = 0; right = 0; bottom = 0; } // 默认构造函数初始化矩形的位置和大小为0
int left; // 矩形的左边界
int top; // 矩形的上边界
int right; // 矩形的右边界
int bottom; // 矩形的下边界
};
struct Geometry {
Geometry(){
width = 0;
height = 0;
x = 0;
y = 0;
}
int width;
int height;
int x;
int y;
};
/**
* @brief 定义一个键值对结构体模板
*
* 模板结构体,接受两个类型参数 K 和 V。
* 包含两个成员变量name 和 value分别用于存储键和值。
*/
template<typename K,typename V>
struct KeyValue{
K name; // 键
V value; // 值
};
/**
* @brief 定义一个带宽信息结构体
*/
struct BandInfo
{
BandInfo() { // 默认构造函数初始化带宽信息的所有成员变量为0
}
uint64 up_all = 0; // 上行总带宽
uint64 down_all = 0; // 下行总带宽
uint64 up_sec_byte = 0; // 上行第二字节带宽
uint64 down_sec_byte = 0; // 下行第二字节带宽
};
// 地址信息
struct AddressPort {
std::string address; // 存储地址的字符串成员
ushort port = 0; // 存储端口的整数成员
//inline std::string to_string() { return address + std::to_string(port); }
};
// 控制台文本颜色
enum ConsoleTextColor {
BLUE = 0x0001,
GREEN = 0x0002,
RED = 0x0004,
YELLOW = 0x0008,
DEFAULT = RED | GREEN | BLUE,
};
// 文件类型
enum FileType {
IS_FILE,
IS_DIRECTORY
};
// 磁盘容量
struct DiskCapacity
{
// 用户可用剩余容量(一般用这个)
uint64 freeBytesUser = 0;
// 可用剩余容量
uint64 freeBytes = 0;
// 用户可用剩余容量
uint64 totalBytes = 0;
};
// 网络接收类型
enum receive_model
{
// 默认模型
PUSH_DEFAULT,
// 封装PACK
PACK,
// 自定义读取流
PULL,
};
// 全路径
class FullPath
{
public:
std::string name;
std::string path;
public:
std::string to_string() { return path + SEPRATOR + name; }
};
} // end of namespace ylib

View File

@@ -1,4 +1,4 @@
#include "base/environment.h"
#include "base/environment.h"
namespace ylib
{
extern ylib::environment *env = new ylib::environment();

View File

@@ -1,52 +0,0 @@
#pragma once
#include <map>
#include <string>
#include <mutex>
#include "ybase/define.h"
#include "ybase/log4.h"
namespace ylib
{
class environment
{
public:
template<typename T>
T* to(const std::string& name)
{
std::unique_lock<std::mutex> auto_lock(m_mutex);
return (T*)m_map[name];
}
template<typename T>
void set(const std::string name,T* value)
{
std::unique_lock<std::mutex> auto_lock(m_mutex);
m_map[name] = value;
}
void del(const std::string& name)
{
std::unique_lock<std::mutex> auto_lock(m_mutex);
auto iter = m_map.find(name);
if (iter != m_map.end())
m_map.erase(iter);
}
private:
std::mutex m_mutex;
std::map<std::string,void*> m_map;
};
namespace network
{
namespace http
{
class center;
}
}
namespace mysql_plus
{
class pool;
}
}
namespace ylib
{
extern ylib::environment *env;
extern ylib::log4 *log;
}

View File

@@ -1,4 +1,4 @@
#include "base/error.h"
#include "base/error.h"
void ylib::error::print(const std::string& value)
{
std::string msg ="[ylib][error]:\t"+value;

View File

@@ -1,23 +0,0 @@
#pragma once
#include <string>
#include <iostream>
/**
* 基础错误类
*/
namespace ylib
{
class error_base
{
public:
const std::string& last_error();
public:
std::string m_lastErrorDesc;
};
namespace error{
void print(const std::string& value);
}
}

View File

@@ -1,4 +1,4 @@
#include "base/exception.h"
#include "base/exception.h"
ylib::exception::exception(const std::string &msg)
{

View File

@@ -1,28 +0,0 @@
#pragma once
#include <string>
#include <exception>
#include "ybase/define.h"
/**
* @brief 异常处理类
*/
namespace ylib
{
class exception:public std::exception
{
public:
exception(const std::string &msg);
~exception();
virtual char const* what() const
#ifdef __linux__
noexcept
#endif
override{return m_msg.c_str();}
private:
std::string m_msg;
};
}

View File

@@ -1,4 +1,4 @@
#include "base/log4.h"
#include <iostream>
#include <string.h>

View File

@@ -1,26 +0,0 @@
#pragma once
#include "define.h"
namespace ylib
{
/*
* @classLog4cplus 日志封装类
* @desc
* 1、程序默认开启如需更改请修改 public/environment.cpp 中的全局变量实现(注释new即可)
* 2、默认配置文件放置程序目录 res/log.properties, 示例文件参考res/log.properties
*/
class log4
{
public:
log4(const std::string& config_filepath);
~log4();
ylib::log4& info(const std::string& value,const std::string& name = "ALL");
ylib::log4& error(const std::string& value,const std::string& name = "ALL");
ylib::log4& fatal(const std::string& value,const std::string& name = "ALL");
ylib::log4& warn(const std::string& value,const std::string& name = "ALL");
ylib::log4& debug(const std::string& value,const std::string& name = "ALL");
private:
void* m_appender;
void* m_appender_console;
};
}

View File

@@ -1,33 +0,0 @@
#pragma once
#include <string>
#include <iostream>
/**
* 基础错误类
*/
namespace ylib
{
// 单例基类模板
template <typename T>
class singleton {
public:
// 获取单例对象的静态方法
static T* getInstance() {
static T instance; // C++11以后局部静态变量的初始化是线程安全的
return &instance;
}
protected:
// 默认构造函数
singleton() = default;
// 禁止拷贝构造函数和拷贝赋值操作
singleton(const singleton&) = delete;
singleton& operator=(const singleton&) = delete;
// 允许析构
virtual ~singleton() = default;
};
}

View File

@@ -1,14 +0,0 @@
#pragma once
/***************************************************[类型]***************************************************/
typedef int int32;
typedef unsigned int uint32;
typedef long long int64;
typedef unsigned long long uint64;
typedef unsigned long ulong;
typedef unsigned short ushort;
typedef int64 llong;
typedef uint64 ullong;
typedef unsigned char uchar;
typedef int64 timestamp;

View File

@@ -1,4 +1,4 @@
#include "db/mssql.h"
#include "db/mssql.h"
#ifdef _WIN32
#include "util/time.h"
#include <windows.h>

View File

@@ -1,4 +1,4 @@
#include "db/mysql.h"
#include "db/mysql.h"
#include "cppconn/driver.h"
#include "cppconn/connection.h"
#include "cppconn/statement.h"

View File

@@ -1,4 +1,4 @@
#include "db/sqler.h"
#include "db/sqler.h"
#include <numeric>
/// <summary>
/// 检查Any类型

Some files were not shown because too many files have changed in this diff Show More