123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120 |
- #pragma once
- #include <iomanip>
- #include <sstream>
- #include <string>
- #include <vector>
- #include "Log.h"
- using namespace std;
- template<class F>
- struct Final_action
- {
- F clean;
- Final_action(F f) :clean(f)
- {
- }
- ~Final_action()
- {
- clean();
- }
- };
- template<class F>
- Final_action<F> finally(F f)
- {
- return Final_action<F>(f);
- }
- //int * p = new int[7];
- //auto act1 = finally([&]
- //{
- // delete[]p;
- // p = NULL;
- //}
- //);
- bool IsLeap(int year);
- bool IsWeekEnd(int year, int month, int day);
- char* PBQ_TrimLeftA(char *pTarget);
- char* PBQ_TrimRightA(char *pTarget);
- char* PBQ_TrimLeftMA(char *pTarget, char* pChars);
- char* PBQ_TrimRightMA(char *pTarget, char* pChars);
- void Full2Half(wchar_t* str);
- bool split(const string& src, string delimit,vector<string> &v, string null_subst="");
- bool split(const wstring& src, wstring delimit, vector<wstring> &v, wstring null_subst=L"");
- vector<string> splitEx(const string& src, string separate_character);
- int GB2312_2_UTF8(char* buf, int buf_len, const char* src, int src_len);
- void Gb2312_2_Unicode(unsigned short* dst, const char* src);
- void Unicode_2_UTF8(char* dst, unsigned short* src);
- string ConvertUTF8toGB2312(const char *pData, size_t size);
- char* ConvertGB2312toUTF8(const char *pData);
- wstring UTF8ToUnicode(const char* szU8);
- inline bool IsChinese(unsigned char c) { return ((c>=0xa1)&&(c<=0xfe)); }
- int CalcWord(const char *ps, const size_t length);
- void Int64DateToStr(const __int64& llDate, string& out);
- void Int64DateToYMDStr(const __int64& llDate, string& out);
- void Int64DateToHMStr(const __int64& llDate, string& out);
- unsigned char ToHex(unsigned char x);
- unsigned char FromHex(unsigned char x);
- string UrlEncode(const std::string& str);
- string UrlDecode(const std::string& str);
- void DeleteDirectory(const CString strPath);
- void RecursiveDirectory(CString cstrDir); // 递归创建目录
- void toUpper(char *szDestination, const char *szSource);
- CString GetExcelDriverInfo();
- __int64 StringToInt64(const char *szSourse);
- string GetRequestByKey(const string& strKey,const string& strReuest); // 解析URL中的参数
- void GetKeysByUrl(const string & strUrl, vector<string> & vctKey);
- __int64 GetCharNumber(char* szText, size_t n); // 获取字符串所有的数据
- bool RegexStdMatch(string src, string regular); // std 正则表达式校验
- bool RegexStdMatch(wstring src, wstring regular);
- string replace_all(string& str, const string& old_value, const string& new_value);
- template<typename T>
- string tostring(T t, int bit = 4) //括号内可以是字符串(ascii)、整数、浮点数、bool等
- {
- std::string result;
- stringstream ss;
- ss << fixed << setprecision(bit) << t;
- ss >> result;
- CStringA strTemp = result.c_str();
- int nIndex = strTemp.Find(".");
- if (nIndex != -1)
- {
- strTemp.TrimRight("0");
- if (nIndex == strTemp.GetLength() - 1)
- {
- strTemp.TrimRight(".");
- }
- }
- if (strTemp == "-0")
- strTemp = "0";
- return string(strTemp);
- }
- CStringW CStrA2W(const CStringA &cstrSrcA);
- CStringA CStrW2A(const CStringW &cstrSrcW);
- string strW2A(const wstring &wstr);
- wstring strA2W(const string &wstr);
- string strWtoUTF8(const wstring &src) ;
- wstring strUTF8toW(const string& src) ;
- void sync_system_time(ULONGLONG time);
|