95 lines
2.7 KiB
C
95 lines
2.7 KiB
C
![]() |
#ifndef SHARED_TOOL_H_
|
|||
|
#define SHARED_TOOL_H_
|
|||
|
|
|||
|
#include <string>
|
|||
|
#include <vector>
|
|||
|
#include "base/time/time.h"
|
|||
|
#include "base/base_types.h"
|
|||
|
|
|||
|
namespace shared
|
|||
|
{
|
|||
|
namespace tools
|
|||
|
{
|
|||
|
// ϵͳ<CFB5><CDB3><EFBFBD><EFBFBD>
|
|||
|
int GetOSVersion();
|
|||
|
std::string GetOSVersionString();
|
|||
|
bool IsWow64();
|
|||
|
|
|||
|
// <20>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
std::string FormatTime(nbase::Time::TimeStruct t);
|
|||
|
std::wstring FormatBytes(double bytes);
|
|||
|
std::wstring FormatBps(double bytes);
|
|||
|
void SplitString(const std::string &str, const std::string &seperator, std::vector<std::string> &array);
|
|||
|
void SplitString(const std::wstring &str, const std::wstring &seperator, std::vector<std::wstring> &array);
|
|||
|
std::string StringReverse(const std::string &input);
|
|||
|
|
|||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><DEB7><EFBFBD>ʾ<EFBFBD>ı<EFBFBD><C4B1><EFBFBD><EFBFBD>ַ<EFBFBD>
|
|||
|
std::string FilterUCS4(const std::string& str, bool replace_spaces = true);
|
|||
|
|
|||
|
// <20><>ʽ<EFBFBD><CABD>SQL<51><4C><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ת<EFBFBD>嵥<EFBFBD><E5B5A5><EFBFBD>ţ<EFBFBD><C5A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ִ<EFBFBD><D6B4>SQL<51><4C><EFBFBD><EFBFBD><EFBFBD>׳<EFBFBD><D7B3>쳣
|
|||
|
UTF8String FormatSQLText(const UTF8String &sql_text);
|
|||
|
|
|||
|
// <20><><EFBFBD><EFBFBD><EFBFBD>ܷ<DCB7><F1B7A2B6><EFBFBD>
|
|||
|
bool IsChinaPhoneNumber(const std::string &str);
|
|||
|
bool IsAuthCode(const std::string &str);
|
|||
|
|
|||
|
// <20>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
std::wstring GetSpecialFolder(int id);
|
|||
|
std::wstring GetResourcePath(void);
|
|||
|
void MakeExtendPath(std::wstring &path);
|
|||
|
void ClearFile(const wchar_t *path, long file_length_limit);
|
|||
|
bool FilePathIsExist(const std::string &utf8_filepath_in, bool is_directory);
|
|||
|
|
|||
|
// <20><><EFBFBD>õݹ<C3B5><DDB9>ķ<EFBFBD>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8>Ŀ<EFBFBD>µ<EFBFBD><C2B5>ļ<EFBFBD>
|
|||
|
bool FindFile(const std::wstring &dir,const std::wstring &file_desc,std::wstring &file_path);
|
|||
|
std::wstring EnsureValidFileName(const std::wstring &file_name, const std::wstring &find = L"\\/:*?\"<>|", const std::wstring &replace = L"_");
|
|||
|
|
|||
|
// <20><>ѧ<EFBFBD><D1A7><EFBFBD><EFBFBD>
|
|||
|
int CalcAvg(const std::vector<int> &vec, bool is_revise = true);
|
|||
|
int CalcStDev(const std::vector<int> &vec);
|
|||
|
|
|||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ
|
|||
|
void SafeOpenUrl(const std::wstring &url, int show_cmd);
|
|||
|
void SafeOpenUrlEx(const std::string &url, int show_cmd);
|
|||
|
|
|||
|
bool RestartComputer();
|
|||
|
bool RunAppWithRedirection(const std::wstring &app_path, const std::wstring &app_cmd, std::string &output);
|
|||
|
|
|||
|
// <20><><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ⱥ<EFBFBD><C8BA><EFBFBD>
|
|||
|
std::string GenerateTimeStamp();
|
|||
|
|
|||
|
// Register Server
|
|||
|
BOOL DllRegisterServer(LPCTSTR lpszFileName);
|
|||
|
BOOL DllUnregisterServer(LPCTSTR lpszFileName);
|
|||
|
|
|||
|
// <20><><EFBFBD><EFBFBD>ͨ<EFBFBD><CDA8>message
|
|||
|
void RegisterShowWndForgroudMessage();
|
|||
|
UINT GetShowWndForgroudMessageID();
|
|||
|
|
|||
|
// <20><>ȡͼƬ<CDBC><C6AC><EFBFBD>Ͷ<EFBFBD>Ӧ<EFBFBD><D3A6>CLSID
|
|||
|
bool GetImageCLSID(const wchar_t* format, CLSID* pCLSID);
|
|||
|
|
|||
|
// <20><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC>µ<EFBFBD><C2B5>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD>㣩
|
|||
|
struct FileItem
|
|||
|
{
|
|||
|
std::wstring file_;
|
|||
|
long size_;
|
|||
|
};
|
|||
|
|
|||
|
typedef std::vector<std::wstring> StringVector;
|
|||
|
typedef std::vector<FileItem> FileItemVector;
|
|||
|
|
|||
|
class File
|
|||
|
{
|
|||
|
public:
|
|||
|
//dir<69><72><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ"\\"
|
|||
|
static void GetFolder(const std::wstring &dir, StringVector &out, bool full_path = false);
|
|||
|
//dir<69><72><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ"\\"
|
|||
|
static void GetFile(const std::wstring &dir, std::vector<FileItem> &out, bool full_path = false);
|
|||
|
};
|
|||
|
|
|||
|
}//namespace tools
|
|||
|
}//namespace shared
|
|||
|
|
|||
|
#endif //SHARED_TOOL_H_
|