本文整理汇总了C++中std::wstring::erase方法的典型用法代码示例。如果您正苦于以下问题:C++ wstring::erase方法的具体用法?C++ wstring::erase怎么用?C++ wstring::erase使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类std::wstring
的用法示例。
在下文中一共展示了wstring::erase方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetFromLetras
/*
** GetFromLetras
**
** Download lyrics from Letras.
**
*/
bool CLyrics::GetFromLetras(const std::wstring& artist, const std::wstring& title, std::wstring& data)
{
bool ret = false;
std::wstring url = L"http://letras.terra.com.br/winamp.php?musica=" + title;
url += L"&artista=";
url += artist;
data = CInternet::DownloadUrl(url, CP_ACP);
if (!data.empty())
{
std::wstring::size_type pos = data.find(L"\"letra\"");
pos = data.find(L"<p>", pos);
if (pos != std::wstring::npos)
{
pos += 3;
data.erase(0, pos);
pos = data.find(L"</p>");
data.resize(pos);
CInternet::DecodeReferences(data);
while ((pos = data.find(L"<br/>"), pos) != std::wstring::npos)
{
data.erase(pos, 5);
}
ret = true;
}
}
return ret;
}
示例2: if
void MediaBridgeSession::NetStream::doPlay(std::wstring& url,RTMPMediaStream::Listener* listener)
{
//Log
Log("-Play stream [%ls]\n",url.c_str());
//Remove extra data from FMS
if (url.find(L"*flv:")==0)
//Erase it
url.erase(0,5);
else if (url.find(L"flv:")==0)
//Erase it
url.erase(0,4);
//Check token
if (!sess->ConsumeOutputToken(url))
{
//Send error
fireOnNetStreamStatus(RTMP::Netstream::Play::StreamNotFound,L"Token invalid");
//Exit
return;
}
//Send reseted status
fireOnNetStreamStatus(RTMP::Netstream::Play::Reset,L"Playback reset");
//Send play status
fireOnNetStreamStatus(RTMP::Netstream::Play::Start,L"Playback started");
//Add listener
AddMediaListener(listener);
//Attach
Attach(sess);
}
示例3: getParameterFromTag
std::wstring Database::getParameterFromTag(std::wstring temp)
{
size_t pos;
const size_t nExist = std::wstring::npos;
pos = temp.find('"');
if ( pos != nExist)
{
temp.erase(0 , pos+1);
pos = temp.find(L'"');
if ( pos != nExist)
{
temp.erase(pos);
return temp;
}
else
{
std::wcout << L"Fehler 1, getParameterFromTag()" << std::endl;
}
}
else
{
std::wcout << L"Fehler 2, getParameterFromTag()" << std::endl;
}
return L"";
}
示例4: trim_string
/**
* Trims the front/back of the string of whitespace
*/
static void trim_string(std::wstring& str)
{
str.erase(str.begin(), std::find_if(str.begin(), str.end(), [](int ch) {
return !std::isspace(ch);
}));
str.erase(std::find_if(str.rbegin(), str.rend(), [](int ch) {
return !std::isspace(ch);
}).base(), str.end());
}
示例5: wtrim
void TestUtils::wtrim(std::wstring& str, const wchar_t* szTrim)
{
std::string::size_type pos = str.find_last_not_of(szTrim);
if(pos != std::string::npos) {
str.erase(pos + 1);
pos = str.find_first_not_of(szTrim);
if(pos != std::string::npos) str.erase(0, pos);
}
else str.erase(str.begin(), str.end());
}
示例6: ltrim
void StringUtil::ltrim(std::wstring& str) {
if (str.empty())
return;
std::wstring::size_type pos = str.find_last_not_of(L" ");
if (pos != std::wstring::npos)
str.erase(pos+1);
pos = str.find_last_not_of(L"\t");
if (pos != std::wstring::npos)
str.erase(pos+1);
}
示例7: ParseUri
void CtriPOSOpenSSLHMACSampleDlg::ParseUri(std::wstring uri, std::string &scheme, std::string &host, std::string &port, std::string &path, std::string &query)
{
size_t findIndex = uri.find(L"://", 0);
if (findIndex != std::string::npos)
{
scheme.assign(ToMultiByte(uri.substr(0, findIndex).c_str()));
findIndex += 3;
uri.erase(0, findIndex);
}
findIndex = uri.find(L"/", 0);
if (findIndex != std::string::npos)
{
host.assign(ToMultiByte(uri.substr(0, findIndex).c_str()));
uri.erase(0, findIndex);
if (!host.empty())
{
findIndex = host.find(":", 0);
if (findIndex != std::string::npos)
{
port = host.substr(findIndex + 1);
host.erase(findIndex);
}
}
}
findIndex = uri.find(L"?", 0);
if (findIndex == std::string::npos)
{
path.assign(ToMultiByte(uri.c_str()));
}
else
{
path.assign(ToMultiByte(uri.substr(0, findIndex).c_str()));
findIndex++;
query.assign(ToMultiByte(uri.substr(findIndex).c_str()));
}
}
示例8: unquote
void StringUtil::unquote(std::wstring& str) {
std::wstring::iterator it;
atrim(str);
if (str.empty())
return;
it = str.begin();
if ((*it == '\'') || *it == '"')
str.erase(it);
it = str.end() - 1;
if ((*it == '\'') || *it == '"')
str.erase(it);
}
示例9: deleteBackward
void deleteBackward()
{
if (selectionStart != caretPos) {
unsigned min = std::min(caretPos, selectionStart);
unsigned max = std::max(caretPos, selectionStart);
text.erase(text.begin() + min, text.begin() + max);
selectionStart = caretPos = min;
}
else if (caretPos > 0) {
unsigned oldCaret = caretPos;
caretPos -= 1;
text.erase(text.begin() + caretPos, text.begin() + oldCaret);
selectionStart = caretPos;
}
}
示例10: RemoveInvalidChars
bool Cx_TextUtil::RemoveInvalidChars(std::wstring& text, LPCWSTR targets)
{
std::vector<long> arrIndex;
long i = GetSize(text);
while (--i >= 0)
{
WCHAR ch = text[i];
if (targets && IsSpaceChar(ch, targets)
|| !targets && ((ch >= 0x0001 && ch <= 0x0008)
|| (ch >= 0x000b && ch <= 0x000c)
|| (ch >= 0x000e && ch <= 0x001f)
|| (ch == 0xDBC0)) )
{
arrIndex.push_back(i);
}
}
long nCount = GetSize(arrIndex);
for (i = 0; i < nCount; i++)
{
text.erase(arrIndex[i]);
}
return nCount > 0;
}
示例11:
bool MiscUtils::Val2WStr(const _variant_t& var, std::wstring& str)
{
bool bDone = true;
switch(var.vt)
{
case VT_BSTR:
case VT_LPSTR:
case VT_LPWSTR:
try
{
str.assign((LPCWSTR)(_bstr_t)var);
}
catch (...)
{
bDone = false;
AfxTrace(_T("Val2WStr failed\n"));
}
break;
case VT_EMPTY:
str.erase();
break;
default:
bDone = false;
break;
}
return bDone;
}
示例12: deleteForward
void deleteForward()
{
if (selectionStart != caretPos) {
unsigned min = std::min(caretPos, selectionStart);
unsigned max = std::max(caretPos, selectionStart);
text.erase(text.begin() + min, text.begin() + max);
selectionStart = caretPos = min;
}
else if (caretPos < text.length()) {
unsigned oldCaret = caretPos;
caretPos += 1;
text.erase(text.begin() + oldCaret, text.begin() + caretPos);
selectionStart = caretPos = oldCaret;
}
}
示例13: filterSymbol
void LateSymbolInfo::filterSymbol(Database::Address address, std::wstring &module, std::wstring &procname, std::wstring &sourcefile, unsigned &sourceline)
{
if (debugSymbols3)
{
ULONG moduleindex;
if (debugSymbols3->GetModuleByOffset(address, 0, &moduleindex, NULL) == S_OK)
if (debugSymbols3->GetModuleNameStringWide(DEBUG_MODNAME_MODULE, moduleindex, 0, buffer, _countof(buffer), NULL) == S_OK)
module = buffer;
if (debugSymbols3->GetNameByOffsetWide(address, buffer, _countof(buffer), NULL, NULL) == S_OK)
{
if (module.compare(buffer) != 0)
{
procname = buffer;
// Remove redundant "Module!" prefix
size_t modlength = module.length();
if (procname.length() > modlength+1 && module.compare(0, modlength, procname, 0, modlength)==0 && procname[modlength] == '!')
procname.erase(0, modlength+1);
}
}
ULONG line;
if (debugSymbols3->GetLineByOffsetWide(address, &line, buffer, _countof(buffer), NULL, NULL) == S_OK)
{
sourcefile = buffer;
sourceline = line;
}
}
}
示例14: ResourcesDirReadFromRegistry
bool CSalsitaExtensionHelper::ResourcesDirReadFromRegistry(HKEY hKey, const wchar_t *subKey, const wchar_t *valueName, std::wstring &result)
{
bool ret = false;
HKEY hkConfig;
result.erase();
if (RegOpenKeyExW(hKey, subKey, 0, KEY_READ, &hkConfig) == ERROR_SUCCESS)
{
DWORD valueType, valueLen = 0;
if (RegQueryValueExW(hkConfig, valueName, NULL, &valueType, NULL, &valueLen) == ERROR_SUCCESS && valueType == REG_SZ)
{
BYTE *buf = new BYTE[valueLen];
if (RegQueryValueExW(hkConfig, valueName, NULL, &valueType, buf, &valueLen) == ERROR_SUCCESS)
{
result.assign((const wchar_t *)buf);
ResourcesDirNormalize(result);
ret = true;
}
delete buf;
}
RegCloseKey(hkConfig);
}
return ret;
}
示例15: As_Removed_Suffix
std::wstring As_Removed_Suffix(std::wstring s) {
auto it = s.rfind(L".");
if (it != std::wstring::npos) {
s.erase(it, s.size());
}
return s;
}