本文整理汇总了C++中std_string::clear方法的典型用法代码示例。如果您正苦于以下问题:C++ std_string::clear方法的具体用法?C++ std_string::clear怎么用?C++ std_string::clear使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类std_string
的用法示例。
在下文中一共展示了std_string::clear方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetNodeName
void CXmlReader::GetNodeName(std_string &strName)
{
strName.clear();
if (m_pOpenElement)
{
const char* p = m_pOpenElement->Value();
if (p != NULL)
{
strName = UTF8ToTChar(p);
}
}
}
示例2: GetNodeContent
void CXmlReader::GetNodeContent(std_string &strText)
{
strText.clear();
if (m_pOpenElement)
{
const char* p = m_pOpenElement->GetText();
if (p != NULL)
{
strText = UTF8ToTChar(p);
}
}
}
示例3: GetNodeAttribute
void CXmlReader::GetNodeAttribute(LPCTSTR szKey, std_string &strValue)
{
strValue.clear();
if (m_pOpenElement)
{
const char* p = m_pOpenElement->Attribute(TCharToUTF8(szKey));
if (p != NULL)
{
strValue = UTF8ToTChar(p);
}
}
}
示例4: DownloadInfoFile
HRESULT CUpdateCheckEx::DownloadInfoFile(BYTE** ppbData, std_string& strError)
{
if(ppbData == NULL) { ASSERT(FALSE); return E_POINTER; }
*ppbData = NULL;
/* TCHAR tszFile[MAX_PATH + 34];
ZeroMemory(tszFile, sizeof(TCHAR) * (MAX_PATH + 34));
URLDownloadToCacheFile(NULL, PWM_URL_VERSION, tszFile, URLOSTRM_GETNEWESTVERSION,
0, NULL);
if(_tcslen(tszFile) != 0)
{
FILE* fp = NULL;
_tfopen_s(&fp, tszFile, _T("rb"));
if(fp != NULL)
{
fseek(fp, 0, SEEK_END);
const DWORD uFileSize = static_cast<DWORD>(ftell(fp));
fseek(fp, 0, SEEK_SET);
if(uFileSize != 0)
{
BYTE* pDataBuf = new BYTE[uFileSize + 2];
fread(pDataBuf, 1, uFileSize, fp);
fclose(fp);
pDataBuf[uFileSize] = 0;
pDataBuf[uFileSize + 1] = 0;
*ppbData = pDataBuf;
}
else
{
strError = TRL("Cache error (cannot open cached file).");
return E_ACCESSDENIED;
}
}
else
{
strError = TRL("Cache error (cannot open cached file).");
return E_ACCESSDENIED;
}
}
else
{
strError = TRL("Connect failed, cannot check for updates.");
return E_ACCESSDENIED;
} */
CKpInternetStream s(PWM_URL_VERSION, false);
s.SetConnectOptions(5000, 1);
s.SetTransferOptions(5000);
std::vector<BYTE> vData;
HRESULT r = s.ReadToEnd(vData);
s.Close();
if(FAILED(r) || (vData.size() == 0))
{
strError = TRL("Connect failed, cannot check for updates.");
return r;
}
*ppbData = new BYTE[vData.size() + 2];
(*ppbData)[vData.size()] = 0;
(*ppbData)[vData.size() + 1] = 0;
memcpy(*ppbData, &vData[0], vData.size());
strError.clear();
return S_OK;
}