随笔分类 -  C++

实用C++库,C++常用功能组件,以及一些对c++的理解......
摘要:C++中的explicit关键字只能用于修饰只有一个参数的类构造函数, 它的作用是表明该构造函数是显示的, 而非隐式的, 跟它相对应的另一个关键字是implicit, 意思是隐藏的,类构造函数默认情况下即声明为implicit(隐式).explicit关键字只需用于类内的单参数构造函数前面。由于无参 阅读全文
posted @ 2022-03-01 08:52 龙马8586 阅读(184) 评论(0) 推荐(0) 编辑
摘要:int Ansi_To_Unicode(string strSrc, wstring& strRet){ wchar_t wBuff[102400] = { 0 }; CHAR sBuff[102400] = { 0 }; int iRet = MultiByteToWideChar(CP_ACP, 阅读全文
posted @ 2020-11-04 22:37 龙马8586 阅读(1024) 评论(0) 推荐(0) 编辑
摘要:int Utf8_To_Unicode(string strSrc, wstring& strRet){ wchar_t wBuff[102400] = { 0 }; int iRet = MultiByteToWideChar(CP_UTF8, 0, strSrc.c_str(), -1, wBu 阅读全文
posted @ 2020-11-04 22:30 龙马8586 阅读(734) 评论(0) 推荐(0) 编辑
摘要:void MySplit(const string& s, vector<string>& v, const string& c){ v.clear(); string::size_type pos1 = 0, pos2 = s.find(c); while (string::npos != pos 阅读全文
posted @ 2020-11-02 21:30 龙马8586 阅读(1285) 评论(0) 推荐(0) 编辑
摘要:template <class Type>Type StringToNum(const string& str){ istringstream iss(str); Type num; iss >> num; return num;} template <class Type>string NumTo 阅读全文
posted @ 2020-11-02 21:24 龙马8586 阅读(245) 评论(0) 推荐(0) 编辑
摘要://求最大值和最小值#define MY_MAX( x, y ) ( ((x) > (y)) ? (x) : (y) ) #define MY_MIN( x, y ) ( ((x) < (y)) ? (x) : (y) ) //得到一个field在结构体(struct)中的偏移量//#define 阅读全文
posted @ 2020-10-31 22:05 龙马8586 阅读(228) 评论(0) 推荐(0) 编辑
摘要:std::string GetCurrentExeDir(){ char szPath[1024] = { 0 };#ifdef WIN32 GetModuleFileName(NULL, szPath, 1024); char* p = strrchr(szPath, '\\');#else re 阅读全文
posted @ 2020-10-28 21:39 龙马8586 阅读(313) 评论(0) 推荐(0) 编辑
摘要:tcp 应用服务器有时候会有多个网卡多个不同网段服务器ip地址,我们需要建一个socket server端绑定一个端口来接受多个网段相同端口的socket客户端连接 此时就需要tcp应用服务器满足此功能,以下方法创建socket服务器可满足该需求 举个例子,假设一个主机有inter1,inter2, 阅读全文
posted @ 2020-10-26 21:48 龙马8586 阅读(1369) 评论(0) 推荐(0) 编辑
摘要:#include<windows.h>#include <time.h> int GetYearBegin(UINT iTmpStamp, UINT& iStamp){ time_t tick = static_cast<time_t>(iTmpStamp); struct tm t_tm; loc 阅读全文
posted @ 2020-10-25 21:59 龙马8586 阅读(140) 评论(0) 推荐(0) 编辑
摘要:#include<windows.h>#include <time.h> int GetWeekBegin(UINT iTmpStamp, UINT& iStamp){ time_t tick = static_cast<time_t>(iTmpStamp); struct tm t_tm; loc 阅读全文
posted @ 2020-10-24 21:54 龙马8586 阅读(425) 评论(0) 推荐(0) 编辑
摘要:BOOL GetDirFiles(const char* pszDir, char* pszFileType, std::vector<std::string>& vtFileList, BOOL bRecursion){ LOGE_TRUE_RETURN_FALSE(pszDir == NULL 阅读全文
posted @ 2020-10-22 21:14 龙马8586 阅读(410) 评论(0) 推荐(0) 编辑
摘要:int cCommFun::ReadFile(string& strPath, char* pDest, int& iLen){ if (pDest == NULL || iLen < 1) { return FALSE; } //文件信息写入内存 std::ifstream file; file. 阅读全文
posted @ 2020-10-20 21:44 龙马8586 阅读(896) 评论(0) 推荐(0) 编辑
摘要:int GetFileInfo(string& strPath, int& iCreateTime, int& iModifyTime, int& iAccessTime, int& iFileLen){ struct _stat tmpInfo; if (_stat(strPath.c_str() 阅读全文
posted @ 2020-10-20 21:40 龙马8586 阅读(3362) 评论(0) 推荐(0) 编辑
摘要:int WriteFile(string& strPath, char* pBuf, int iLen){ //数据写入文件 if (pBuf == NULL) { return FALSE; } if (_access(strPath.c_str(), 0x00) == 0) { _unlink( 阅读全文
posted @ 2020-10-19 22:06 龙马8586 阅读(606) 评论(0) 推荐(0) 编辑
摘要://单例类定义#define CLASS_INSTANCE_DEF(className) \public: \ static className* GetInstance() \ { \ static className m_Instance; \ return &m_Instance; \ } \ 阅读全文
posted @ 2020-10-18 14:24 龙马8586 阅读(128) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示