本文整理汇总了C++中std::wstring::clear方法的典型用法代码示例。如果您正苦于以下问题:C++ wstring::clear方法的具体用法?C++ wstring::clear怎么用?C++ wstring::clear使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类std::wstring
的用法示例。
在下文中一共展示了wstring::clear方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getPlayerName
void getPlayerName(std::wstring &identity) {
unsigned long mask, base, offset, current, shortGUID, testGUID;
mask = getInt32(nameStorePtr + nameMaskOffset);
base = getInt32(nameStorePtr + nameBaseOffset);
shortGUID = g_playerGUID & 0xffffffff; // Only half the guid is used to check for a hit
if (mask == 0xffffffff) {
identity.clear();
return;
}
offset = 12 * (mask & shortGUID); // select the appropriate linked list
current=getInt32(base + offset + 8); // ptr to lower half of GUID of first element
offset = getInt32(base + offset); // this plus 4 is the offset for the next element
if ((current == 0) || (current & 0x1)) {
identity.clear();
return;
}
testGUID=getInt32(current);
while (testGUID != shortGUID) {
current=getInt32(current + offset + 4);
if ((current == 0) || (current & 0x1)) {
identity.clear();
return;
}
testGUID=getInt32(current);
}
getWString(current + nameStringOffset, identity);
}
示例2: EvaluateNext
HRESULT EEDEnumPointer::EvaluateNext(
const EvalOptions& options,
EvalResult& result,
std::wstring& name,
std::wstring& fullName )
{
if ( mCountDone >= GetCount() )
return E_FAIL;
HRESULT hr = S_OK;
RefPtr<IEEDParsedExpr> parsedExpr;
name.clear();
fullName.clear();
fullName.append( L"*(" );
fullName.append( mParentExprText );
fullName.append( 1, L')' );
hr = ParseText( fullName.c_str(), mTypeEnv, mStrTable, parsedExpr.Ref() );
if ( FAILED( hr ) )
return hr;
hr = parsedExpr->Bind( options, mBinder );
if ( FAILED( hr ) )
return hr;
hr = parsedExpr->Evaluate( options, mBinder, result );
if ( FAILED( hr ) )
return hr;
mCountDone++;
return S_OK;
}
示例3: strlen
/*
@brief マルチバイト文字列をUNICODEに変換する
@param[in] src ソース文字列(char *)
@param[in] dst 出力文字列(wstring)
@return 変換した文字数
*/
size_t strutil::char2wstring(const char* src, std::wstring& dst)
{
#ifdef WIN32
dst.clear();
size_t len = strlen(src);
if(len == 0) return 0;
wchar_t* unic = new wchar_t[len + 1];
setlocale(LC_ALL, LOCALE_JP);
size_t num;
mbstowcs_s(&num, unic, len + 1, src, len + 1);
dst = unic;
delete[] unic;
return num;
#else
dst.clear();
size_t len = strlen(src);
if(len == 0) return 0;
wchar_t* unic = new wchar_t[len + 1];
setlocale(LC_ALL, LOCALE_JP);
size_t num = mbstowcs(unic, src, len+1);
if (num == (size_t)-1) {
dst.clear();
}
else {
dst = unic;
}
delete[] unic;
return num;
#endif
}
示例4: Reset
void Reset()
{
wMenuMask = 0;
iInsertPosition = 0;
iMenuCmdBegin = -1;
strTargetURL.clear();
strSelectedText.clear();
strLinkHrefURL.clear();
strLinkText.clear();
}
示例5: Utf8toWStr
bool Utf8toWStr(const std::string& utf8str, std::wstring& wstr)
{
wstr.clear();
try
{
utf8::utf8to16(utf8str.c_str(), utf8str.c_str()+utf8str.size(), std::back_inserter(wstr));
}
catch(std::exception const&)
{
wstr.clear();
return false;
}
return true;
}
示例6: decode
/*static*/
void WStringCodec::decode(DBusMessageIter& iter, std::wstring& str)
{
str.clear();
DBusMessageIter _iter;
simppl_dbus_message_iter_recurse(&iter, &_iter, DBUS_TYPE_ARRAY);
int count =
#if DBUS_MAJOR_VERSION == 1 && DBUS_MINOR_VERSION < 9
dbus_message_iter_get_array_len(&_iter) / sizeof(uint32_t);
#else
dbus_message_iter_get_element_count(&iter);
#endif
if (count > 0)
str.reserve(count);
while(dbus_message_iter_get_arg_type(&_iter) != 0)
{
uint32_t t;
Codec<uint32_t>::decode(_iter, t);
str.push_back((wchar_t)t);
}
// advance to next element
dbus_message_iter_next(&iter);
}
示例7: s
bool COfficeFileFormatChecker::isPdfFormatFile (unsigned char* pBuffer,int dwBytes, std::wstring & documentID)
{
if (pBuffer == NULL) return false;
documentID.clear();
if (dwBytes < 1)
return false;
pBuffer[dwBytes - 1] = '\0';
char* pFirst = strstr( (char*)pBuffer, "%PDF-" );
if( NULL != pFirst )
{
pFirst = strstr( (char*)pBuffer, "%DocumentID " );
if( NULL != pFirst )
{
pFirst += 12;
char* pLast = strstr( pFirst, " ");
if( NULL != pLast )
{
std::string s(pFirst, pLast - pFirst);
documentID = NSFile::CUtf8Converter::GetUnicodeStringFromUTF8((BYTE*)s.c_str(), s.length());
}
}
return true;
}
return false;
}
示例8: GetClipboardData
bool touchmind::shell::Clipboard::_PasteTEXT(HWND hWnd, std::wstring &text) {
if (!OpenClipboard(hWnd)) {
text.clear();
return false;
}
HGLOBAL hg = GetClipboardData(CF_UNICODETEXT);
if (hg == nullptr) {
text.clear();
return false;
}
wchar_t *strClip = static_cast<wchar_t *>(GlobalLock(hg));
text.assign(strClip);
GlobalUnlock(hg);
CloseClipboard();
return true;
}
示例9: RegEnumKeyExX
// RegEnumKeyEx
// returns ERROR_NO_MORE_ITEMS or ERROR_SUCCESS
// if maxNameSize == 0, then we will compute it for you. Use it between calls on the same key for performance
inline LONG RegEnumKeyExX(HKEY hKey, DWORD dwIndex, std::wstring& outName, DWORD& maxNameSize)
{
FILETIME temp;
LONG ret;
std::vector<wchar_t> buf;
DWORD size;
outName.clear();
// get maximum subkey name length.
if(!maxNameSize)
{
if(ERROR_SUCCESS != (ret = RegQueryInfoKeyW(hKey, 0, 0, 0, 0, &maxNameSize, 0, 0, 0, 0, 0, 0)))
{
return ret;
}
maxNameSize += 2;// for safety
}
buf.resize(maxNameSize);
// make the call
size = static_cast<DWORD>(buf.size());
ret = RegEnumKeyExW(hKey, dwIndex, buf.data(), &size, 0, 0, 0, &temp);
if(ret == ERROR_SUCCESS)
{
outName = buf.data();
}
return ret;
}
示例10: GetRole
HRESULT AccessibleObject::GetRole(std::wstring& role, long child_id,
IAccessible* acc) {
DWORD role_id = 0;
HRESULT hr = GetRole(role_id, child_id, acc);
if (hr != S_OK)
return hr;
UINT role_length = GetRoleText(role_id, nullptr, 0);
LPTSTR buffer = (LPTSTR)malloc((role_length + 1) * sizeof(TCHAR));
if (buffer != nullptr) {
GetRoleText(role_id, buffer, role_length + 1);
if (buffer) {
role = buffer;
} else {
role.clear();
}
free(buffer);
} else {
return E_OUTOFMEMORY;
}
return S_OK;
}
示例11: trylock
static int trylock() {
if ((lm->uiVersion == 1) || (lm->uiVersion == 2)) {
if (lm->dwcount != last_count) {
last_count = lm->dwcount;
last_tick = GetTickCount();
errno_t err = 0;
wchar_t buff[2048];
if (lm->name[0]) {
err = wcscpy_s(buff, 256, lm->name);
if (! err)
wsPluginName.assign(buff);
}
if (!err && lm->description[0]) {
err = wcscpy_s(buff, 2048, lm->description);
if (! err)
wsDescription.assign(buff);
}
if (err) {
wsPluginName.assign(L"Link");
wsDescription.clear();
return false;
}
return true;
}
}
return false;
}
示例12: GetTextFromHtmlFragment
void GetTextFromHtmlFragment(std::wstring& text, LPCTSTR startFragment, LPCTSTR endFragment)
{
ASSERT(startFragment != NULL);
ASSERT(endFragment != NULL);
text.clear();
BOOL bInTag = FALSE;
for (LPCTSTR pos = startFragment; pos < endFragment; pos++)
{
if (*pos == 0)
break;
switch (*pos)
{
case '<':
bInTag = TRUE;
break;
case '>':
bInTag = FALSE;
break;
default:
if (!bInTag)
text += *pos;
}
}
if (!text.empty())
{
ReplaceHtmlEntities(text);
trim(text, _T(" \t\n\r"));
}
}
示例13: SetSize
void SetSize(int w, int h)
{
m_image->Resize(w, h);
m_col=w/m_fontsize*2;
m_row=h/m_fontsize;
m_text.clear();
}
示例14: GetVideoInfoURL
HRESULT URLParser::GetVideoInfoURL(URLParser::VIDEO_URL_PARSER eVideoURLParser, std::wstring& wstrURL, std::wstring& wstrVideoURL)
{
HRESULT hr = E_FAIL;
int iVdoIDStart = -1;
int iVdoIDEnd = -1;
std::wstring wstrVideoID;
if(std::wstring::npos != (iVdoIDStart = wstrURL.find(L"v=")))
{
iVdoIDStart += wcslen(L"v=");
iVdoIDEnd = wstrURL.find(L"&", iVdoIDStart);
if(std::wstring::npos != iVdoIDEnd)
{
// pick start to end
wstrVideoID = wstrURL.substr(iVdoIDStart, (iVdoIDEnd - iVdoIDStart));
}
else
{
// pick the entire string
wstrVideoID = wstrURL.substr(iVdoIDStart, (wstrURL.length() - iVdoIDStart));
}
}
if(0 != wstrVideoID.length())
{
wstrVideoURL.clear();
wstrVideoURL.assign(PRE_VIDEO_ID_URL_STRING);
wstrVideoURL.append(wstrVideoID);
wstrVideoURL.append(POST_VIDEO_ID_URL_STRING);
hr = S_OK;
}
return hr;
}
示例15: GNS_to_wstring
void GNS_to_wstring(int region, const char *word, std::wstring &output)
{
int len = strlen(word);
uchar ch;
unsigned short unicode;
output.clear();
for (int i = 0; i < len; i++)
{
ch = (uchar) word[i];
if (ch < 128)
unicode = ch;
else
{
if (region == 1)
unicode = region1[ch-128];
else if (region == 2)
unicode = region2[ch-128];
else if (region == 3)
unicode = region3[ch-128];
else // TODO: other 3 regions
unicode = region3[ch-128];
if (unicode == 0x0000)
unicode = '?';
}
output += unicode;
}
}