16,473
社区成员
发帖
与我相关
我的任务
分享
struct info_msg
{
LPCTSTR name;
CONNID connID;
LPCTSTR evt;
int contentLength;
LPCTSTR content;
static info_msg* Construct(CONNID dwConnID, LPCTSTR lpszEvent, int iContentLength = 0, LPCTSTR lpszContent = nullptr, LPCTSTR lpszName = nullptr);
static void Destruct(info_msg* pMsg);
private:
info_msg(CONNID dwConnID, LPCTSTR lpszEvent, int iContentLength = 0, LPCTSTR lpszContent = nullptr, LPCTSTR lpszName = nullptr);
~info_msg();
};
info_msg* info_msg::Construct(CONNID dwConnID, LPCTSTR lpszEvent, int iContentLength, LPCTSTR lpszContent, LPCTSTR lpszName)
{
return new info_msg(dwConnID, lpszEvent, iContentLength, lpszContent, lpszName);
}
void info_msg::Destruct(info_msg* pMsg)
{
delete pMsg;
}
info_msg::info_msg(CONNID dwConnID, LPCTSTR lpszEvent, int iContentLength, LPCTSTR lpszContent, LPCTSTR lpszName)
: connID(dwConnID), evt(lpszEvent), contentLength(iContentLength), content(lpszContent), name(nullptr)
{
if(lpszName)
{
int len = lstrlen(lpszName);
if(len > 0)
{
name = new TCHAR[len + 1];
memcpy((LPSTR)name, lpszName, (len + 1) * sizeof(TCHAR));
}
}
}
info_msg::~info_msg()
{
if(name)
delete[] name;
if(contentLength > 0)
delete[] content;
}