本文整理汇总了C++中CStdString::Insert方法的典型用法代码示例。如果您正苦于以下问题:C++ CStdString::Insert方法的具体用法?C++ CStdString::Insert怎么用?C++ CStdString::Insert使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CStdString
的用法示例。
在下文中一共展示了CStdString::Insert方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: InsertToken
void CScraperParser::InsertToken(CStdString& strOutput, int buf, const char* token)
{
char temp[4];
sprintf(temp,"\\%i",buf);
int i2=0;
while ((i2 = strOutput.Find(temp,i2)) != -1)
{
strOutput.Insert(i2,token);
i2 += strlen(token);
strOutput.Insert(i2+strlen(temp),token);
i2 += strlen(temp);
}
}
示例2: ShowStatus
void CServer::ShowStatus(_int64 eventDate, LPCTSTR msg, int nType)
{
USES_CONVERSION;
TIME_ZONE_INFORMATION tzInfo;
BOOL res=GetTimeZoneInformation(&tzInfo);
_int64 offset = tzInfo.Bias+((res==TIME_ZONE_ID_DAYLIGHT)?tzInfo.DaylightBias:tzInfo.StandardBias);
offset*=60*10000000;
eventDate-=offset;
LPCSTR str=T2CA(msg);
char *pBuffer=new char[strlen(str) + 1 + 8];
*pBuffer=nType;
memcpy(pBuffer + 1, &eventDate, 8);
memcpy(pBuffer + 1 + 8, str, strlen(str));
if (m_pAdminInterface)
m_pAdminInterface->SendCommand(2, 4, pBuffer, strlen(str) + 1 + 8);
delete [] pBuffer;
//Log string
if (m_pFileLogger)
{
FILETIME fFileTime;
SYSTEMTIME sFileTime;
fFileTime.dwHighDateTime = (DWORD)(eventDate>>32);
fFileTime.dwLowDateTime = (DWORD)(eventDate %0xFFFFFFFF);
FileTimeToSystemTime(&fFileTime, &sFileTime);
char text[80];
if (!GetDateFormat(
LOCALE_USER_DEFAULT, // locale for which date is to be formatted
DATE_SHORTDATE, // flags specifying function options
&sFileTime, // date to be formatted
0, // date format string
text, // buffer for storing formatted string
80 // size of buffer
))
return;
CStdString text2=" ";
text2+=text;
if (!GetTimeFormat(
LOCALE_USER_DEFAULT, // locale for which date is to be formatted
TIME_FORCE24HOURFORMAT, // flags specifying function options
&sFileTime, // date to be formatted
0, // date format string
text, // buffer for storing formatted string
80 // size of buffer
))
return;
text2+=" ";
text2+=text;
CStdString str = msg;
int pos=str.Find("-");
if (pos!=-1)
{
str.Insert(pos, text2 + " ");
}
m_pFileLogger->Log(str);
}
}
示例3: ShowStatus
void CServer::ShowStatus(DWORD eventDateHigh, DWORD eventDateLow, LPCTSTR msg, int nType)
{
auto utf8 = ConvToNetwork(msg);
if (utf8.empty())
return;
char *pBuffer = new char[utf8.size() + 1 + 8];
*pBuffer = nType;
memcpy(pBuffer + 1, &eventDateHigh, 4);
memcpy(pBuffer + 5, &eventDateLow, 4);
memcpy(pBuffer + 1 + 8, utf8.c_str(), utf8.size());
if (m_pAdminInterface)
m_pAdminInterface->SendCommand(2, 4, pBuffer, utf8.size() + 1 + 8);
delete [] pBuffer;
//Log string
if (m_pFileLogger) {
FILETIME fFileTime;
SYSTEMTIME sFileTime;
fFileTime.dwHighDateTime = eventDateHigh;
fFileTime.dwLowDateTime = eventDateLow;
if (!FileTimeToSystemTime(&fFileTime, &sFileTime)) {
return;
}
TCHAR text[80];
if (!GetDateFormat(
LOCALE_USER_DEFAULT, // locale for which date is to be formatted
DATE_SHORTDATE, // flags specifying function options
&sFileTime, // date to be formatted
0, // date format string
text, // buffer for storing formatted string
80 // size of buffer
))
return;
CStdString text2 = _T(" ");
text2 += text;
if (!GetTimeFormat(
LOCALE_USER_DEFAULT, // locale for which date is to be formatted
TIME_FORCE24HOURFORMAT, // flags specifying function options
&sFileTime, // date to be formatted
0, // date format string
text, // buffer for storing formatted string
80 // size of buffer
))
return;
text2 += _T(" ");
text2 += text;
CStdString str = msg;
int pos = str.Find(_T("-"));
if (pos!=-1)
{
str.Insert(pos, text2 + _T(" "));
}
m_pFileLogger->Log(str);
}
}
示例4: Clean
void CScraperParser::Clean(CStdString& strDirty)
{
int i=0;
CStdString strBuffer;
while ((i=strDirty.Find("!!!CLEAN!!!",i)) != -1)
{
int i2;
if ((i2=strDirty.Find("!!!CLEAN!!!",i+11)) != -1)
{
strBuffer = strDirty.substr(i+11,i2-i-11);
CStdString strConverted(strBuffer);
HTML::CHTMLUtil::RemoveTags(strConverted);
RemoveWhiteSpace(strConverted);
strDirty.erase(i,i2-i+11);
strDirty.Insert(i,strConverted);
i += strConverted.size();
}
else
break;
}
i=0;
while ((i=strDirty.Find("!!!TRIM!!!",i)) != -1)
{
int i2;
if ((i2=strDirty.Find("!!!TRIM!!!",i+10)) != -1)
{
strBuffer = strDirty.substr(i+10,i2-i-10);
RemoveWhiteSpace(strBuffer);
strDirty.erase(i,i2-i+10);
strDirty.Insert(i,strBuffer);
i += strBuffer.size();
}
else
break;
}
i=0;
while ((i=strDirty.Find("!!!FIXCHARS!!!",i)) != -1)
{
int i2;
if ((i2=strDirty.Find("!!!FIXCHARS!!!",i+14)) != -1)
{
strBuffer = strDirty.substr(i+14,i2-i-14);
CStdStringW wbuffer;
g_charsetConverter.toW(strBuffer,wbuffer,GetSearchStringEncoding());
CStdStringW wConverted;
HTML::CHTMLUtil::ConvertHTMLToW(wbuffer,wConverted);
g_charsetConverter.fromW(wConverted,strBuffer,GetSearchStringEncoding());
RemoveWhiteSpace(strBuffer);
strDirty.erase(i,i2-i+14);
strDirty.Insert(i,strBuffer);
i += strBuffer.size();
}
else
break;
}
i=0;
while ((i=strDirty.Find("!!!ENCODE!!!",i)) != -1)
{
int i2;
if ((i2=strDirty.Find("!!!ENCODE!!!",i+12)) != -1)
{
strBuffer = strDirty.substr(i+12,i2-i-12);
CURL::Encode(strBuffer);
strDirty.erase(i,i2-i+12);
strDirty.Insert(i,strBuffer);
i += strBuffer.size();
}
else
break;
}
}