本文整理汇总了C++中std::wstring::insert方法的典型用法代码示例。如果您正苦于以下问题:C++ wstring::insert方法的具体用法?C++ wstring::insert怎么用?C++ wstring::insert使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类std::wstring
的用法示例。
在下文中一共展示了wstring::insert方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetRuntimeFullMethodSignature
void CFunctionProfiler::GetRuntimeFullMethodSignature(FunctionID funcID, COR_PRF_FRAME_INFO func, std::wstring& methodName)
{
ClassID funcClass;
CComPtr<IMetaDataImport2> metaDataImport2;
mdToken funcToken;
GetClassIDForFunctionID(funcID, func, funcClass, funcToken, &metaDataImport2);
std::wstring className;
CFunctionProfiler::g_pProfiler->GetRuntimeClassSignature(funcClass, className);
CFunctionProfiler::g_pProfiler->GetRuntimeMethodSignature(funcID, NULL, metaDataImport2, methodName);
methodName.insert(0, L"::");
methodName.insert(0, className);
}
示例2: getAppDataPath
std::wstring getAppDataPath(std::wstring extra)
{
#ifdef NIX
#if defined(USE_XDG_DIRS)
std::string configPath = getenv("XDG_CONFIG_HOME");
configPath.append("/desura");
#elif defined(USE_SINGLE_HOME_DIR)
std::string configPath = getenv("HOME");
configPath.append("/.desura");
#elif defined(USE_PORTABLE_DIR)
std::string configPath = UTIL::STRING::toStr(getCurrentDir(L"config"));
#endif
if (extra.size() > 0)
extra.insert(0, DIRS_WSTR);
return UTIL::STRING::toWStr(configPath) + extra;
#else
wchar_t path[MAX_PATH];
getSystemPath(CSIDL_COMMON_APPDATA, path);
gcWString out(path);
out += DIRS_WSTR;
out += COMMONAPP_PATH_W;
if (extra.size() > 0)
{
out += DIRS_WSTR;
out += extra;
}
return out;
#endif
}
示例3: GetServiceInfo
//Get infomation of service
size_t __stdcall GetServiceInfo()
{
//Get service information
SC_HANDLE SCM = nullptr, Service = nullptr;
DWORD nResumeHandle = 0;
if((SCM = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS)) == nullptr)
return EXIT_FAILURE;
Service = OpenService(SCM, LOCALSERVERNAME, SERVICE_ALL_ACCESS);
if(Service == nullptr)
return EXIT_FAILURE;
LPQUERY_SERVICE_CONFIG ServicesInfo = (LPQUERY_SERVICE_CONFIG)LocalAlloc(LPTR, PACKET_MAXSIZE*4); //Max buffer of QueryServiceConfig() is 8KB/8192 Bytes.
if (ServicesInfo == nullptr)
return EXIT_FAILURE;
if (QueryServiceConfig(Service, ServicesInfo, PACKET_MAXSIZE*4, &nResumeHandle) == FALSE)
{
LocalFree(ServicesInfo);
return EXIT_FAILURE;
}
Path = ServicesInfo->lpBinaryPathName;
LocalFree(ServicesInfo);
//Path process
size_t Index = Path.rfind(_T("\\"));
static const WCHAR wBackslash[] = _T("\\");
Path.erase(Index + 1, Path.length());
for (Index = 0;Index < Path.length();Index++)
{
if (Path[Index] == _T('\\'))
{
Path.insert(Index, wBackslash);
Index++;
}
}
//Get path of error log file and delete the old one
ErrorLogPath.append(Path);
ErrorLogPath.append(_T("Error.log"));
DeleteFile(ErrorLogPath.c_str());
Parameter.PrintError = true;
//Winsock initialization
WSADATA WSAData = {0};
if (WSAStartup(MAKEWORD(2, 2), &WSAData) != 0 || LOBYTE(WSAData.wVersion) != 2 || HIBYTE(WSAData.wVersion) != 2)
{
PrintError(Winsock_Error, _T("Winsock initialization failed"), WSAGetLastError(), NULL);
WSACleanup();
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}
示例4: FileInit
//Get path of program from the main function parameter and Winsock initialization
inline size_t __fastcall FileInit(const PWSTR wPath)
{
/* Get path of program from server information.
//Prepare
SC_HANDLE SCM = nullptr, Service = nullptr;
DWORD nResumeHandle = 0;
if ((SCM = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS)) == nullptr)
return EXIT_FAILURE;
Service = OpenService(SCM, LOCAL_SERVICENAME, SERVICE_ALL_ACCESS);
if (Service == nullptr)
return EXIT_FAILURE;
LPQUERY_SERVICE_CONFIG ServicesInfo = (LPQUERY_SERVICE_CONFIG)LocalAlloc(LPTR, QUERY_SERVICE_CONFIG_BUFFER_MAXSIZE);
if (ServicesInfo == nullptr)
return EXIT_FAILURE;
if (QueryServiceConfig(Service, ServicesInfo, QUERY_SERVICE_CONFIG_BUFFER_MAXSIZE, &nResumeHandle) == FALSE)
{
LocalFree(ServicesInfo);
return EXIT_FAILURE;
}
Path = ServicesInfo->lpBinaryPathName;
LocalFree(ServicesInfo);
*/
//Path process.
Path = wPath;
Path.erase(Path.rfind(L"\\") + 1U);
for (size_t Index = 0;Index < Path.length();Index++)
{
if (Path[Index] == L'\\')
{
Path.insert(Index, L"\\");
Index++;
}
}
//Get path of error log file and delete the old one.
ErrorLogPath = Path;
ErrorLogPath.append(L"Error.log");
DeleteFileW(ErrorLogPath.c_str());
Parameter.PrintError = true;
//Winsock initialization
WSADATA WSAInitialization = {0};
if (WSAStartup(MAKEWORD(2, 2), &WSAInitialization) != 0 || LOBYTE(WSAInitialization.wVersion) != 2 || HIBYTE(WSAInitialization.wVersion) != 2)
{
PrintError(WINSOCK_ERROR, L"Winsock initialization error", WSAGetLastError(), nullptr, NULL);
WSACleanup();
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}
示例5: EscapeRegExp
/*
** Escapes reserved PCRE regex metacharacters.
*/
void EscapeRegExp(std::wstring& str)
{
size_t start = 0;
while ((start = str.find_first_of(L"\\^$|()[{.+*?", start)) != std::wstring::npos)
{
str.insert(start, L"\\");
start += 2;
}
}
示例6:
bool CWIN32Util::AddExtraLongPathPrefix(std::wstring& path)
{
const wchar_t* const str = path.c_str();
if (path.length() < 4 || str[0] != L'\\' || str[1] != L'\\' || str[3] != L'\\' || str[2] != L'?')
{
path.insert(0, L"\\\\?\\");
return true;
}
return false;
}
示例7: replace
void text::replace(std::wstring &str, const std::wstring &find, const std::wstring &replace)
{
std::wstring::size_type pos=0;
while((pos=str.find(find, pos))!=std::wstring::npos)
{
str.erase(pos, find.length());
str.insert(pos, replace);
pos+=replace.length();
}
}
示例8: Launch
size_t Launch(std::wstring FullPathToExe, std::wstring Parameters, size_t SecondsToWait) {
size_t iMyCounter = 0, iReturnVal = 0, iPos = 0;
DWORD dwExitCode = 0;
std::wstring sTempStr = L"";
/* Add a space to the beginning of the Parameters */
if (Parameters.size() != 0) {
if (Parameters[0] != L' ') {
Parameters.insert(0,L" ");
}
}
/* The first parameter needs to be the exe itself */
sTempStr = FullPathToExe;
iPos = sTempStr.find_last_of(L"\\");
sTempStr.erase(0, iPos +1);
Parameters = sTempStr.append(Parameters);
/* CreateProcessW can modify Parameters thus we allocate needed memory */
wchar_t * pwszParam = new wchar_t[Parameters.size() + 1];
if (pwszParam == 0)
return 1;
const wchar_t* pchrTemp = Parameters.c_str();
wcscpy_s(pwszParam, Parameters.size() + 1, pchrTemp);
/* CreateProcess API initialization */
STARTUPINFOW siStartupInfo;
PROCESS_INFORMATION piProcessInfo;
memset(&siStartupInfo, 0, sizeof(siStartupInfo));
memset(&piProcessInfo, 0, sizeof(piProcessInfo));
siStartupInfo.cb = sizeof(siStartupInfo);
if (CreateProcessW(const_cast<LPCWSTR>(FullPathToExe.c_str()),
pwszParam, 0, 0, false,
CREATE_NO_WINDOW, 0, 0,
&siStartupInfo, &piProcessInfo) != false)
/* Watch the process. */
dwExitCode = WaitForSingleObject(piProcessInfo.hProcess, (SecondsToWait * 1000));
else
/* CreateProcess failed */
iReturnVal = GetLastError();
/* Free memory */
delete[]pwszParam;
pwszParam = 0;
/* Release handles */
CloseHandle(piProcessInfo.hProcess);
CloseHandle(piProcessInfo.hThread);
return iReturnVal;
}
示例9: padLeft
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
//
//
// Add the specified char to the left of a string until
// its length reaches the desidered value
//
//
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
std::wstring dataHandlerDateTimeBase::padLeft(std::wstring source, std::wstring fillChar, size_t length)
{
PUNTOEXE_FUNCTION_START(L"dataHandlerDateTimeBase::padLeft");
while(source.size() < length)
{
source.insert(0, fillChar);
}
return source;
PUNTOEXE_FUNCTION_END();
}
示例10: EncodeUrl
/*
** Escapes reserved URL characters.
*/
void EncodeUrl(std::wstring& str)
{
size_t pos = 0;
while ((pos = str.find_first_of(L" !*'();:@&=+$,/?#[]", pos)) != std::wstring::npos)
{
WCHAR buffer[3];
_snwprintf_s(buffer, _countof(buffer), L"%.2X", str[pos]);
str[pos] = L'%';
str.insert(pos + 1, buffer);
pos += 3;
}
}
示例11: ReplaceRecipientInString
void RecipientsHandler::ReplaceRecipientInString( const std::wstring& recipient,
const int recipientNumber,
const RecipientMatch& recipientMatch,
std::wstring& recipients)
{
int currentRecipientNumber = 1; // exclude the first recipient - it should start searching from zero
std::string::size_type startOfSearchIndex = 0;
while(recipientNumber > currentRecipientNumber)
{
startOfSearchIndex = recipients.find_first_of(L",;", startOfSearchIndex);
currentRecipientNumber++;
}
std::string::size_type startReplaceIndex = recipients.find(recipient, startOfSearchIndex);
if(std::string::npos == startReplaceIndex)
return;
std::string::size_type endReplaceIndex = recipients.find_first_of(L",;", startReplaceIndex);
if(std::string::npos == endReplaceIndex)
endReplaceIndex = recipients.size();
recipients = recipients.erase(startReplaceIndex, endReplaceIndex - startReplaceIndex);
std::wstring emailAddress;
if (recipientMatch.GetMailSystem() == AbstractRecipient::NOTES_MAILSYSTEM &&
!recipientMatch.GetFullName().empty())
{
emailAddress = recipientMatch.GetFullName();
}
else if(!recipientMatch.GetInternetAddress().empty())
{
emailAddress = recipientMatch.GetInternetAddress();
}
else if(!recipientMatch.GetMailAddress().empty())
{
emailAddress = recipientMatch.GetMailAddress();
}
if(!emailAddress.empty())
{
std::wostringstream msg;
msg << "Replacing recipient [" << recipient.c_str() << "] with [" << emailAddress.c_str() << "]." << std::ends;
LOG_WS_INFO(msg.str().c_str());
recipients = recipients.insert(startReplaceIndex, emailAddress.c_str());
return;
}
LOG_WS_ERROR(L"Error: Cannot replace recipient with empty value!");
}
示例12: MultiByteToWideChar
extern "C" const WCHAR *EncodeWithNickname(const char *string, const WCHAR *szNick, UINT codePage)
{
static std::wstring msg;
wchar_t stringW[256];
int mark = 0;
MultiByteToWideChar(codePage, 0, string, -1, stringW, 256);
stringW[255] = 0;
msg.assign(stringW);
if((mark = msg.find(L"%nick%")) != msg.npos) {
msg.erase(mark, 6);
msg.insert(mark, szNick, lstrlenW(szNick));
}
return msg.c_str();
}
示例13: insertText
void insertText(const std::wstring& newText)
{
// Stop IME composition.
composition.clear();
// Delete (overwrite) previous selection.
if (caretPos != selectionStart) {
unsigned min = std::min(caretPos, selectionStart);
unsigned max = std::max(caretPos, selectionStart);
text.erase(text.begin() + min, text.begin() + max);
caretPos = selectionStart = min;
}
text.insert(text.begin() + caretPos, newText.begin(), newText.end());
caretPos += newText.size();
selectionStart = caretPos;
}
示例14: getAppInstallPath
std::wstring getAppInstallPath(std::wstring extra)
{
#ifdef NIX
#if defined(USE_XDG_DIRS)
std::string installPath = getenv("XDG_DATA_HOME");
installPath.append("/desura");
#elif defined(USE_SINGLE_HOME_DIR)
std::string installPath = getenv("HOME");
installPath.append("/.desura/games");
#elif defined(USE_PORTABLE_DIR)
std::string installPath = UTIL::STRING::toStr(getCurrentDir(L"games"));
#endif
if (extra.size() > 0)
extra.insert(0, DIRS_WSTR);
return UTIL::STRING::toWStr(installPath) + extra;
#else
#error NOT IMPLEMENTED
#endif
}
示例15: getCachePath
std::wstring getCachePath(std::wstring extra)
{
#ifdef NIX
#if defined(USE_XDG_DIRS)
std::string cachePath = getenv("XDG_CACHE_HOME");
cachePath.append("/desura");
#elif defined(USE_SINGLE_HOME_DIR)
std::string cachePath = getenv("HOME");
cachePath.append("/.desura/cache");
#elif defined(USE_PORTABLE_DIR)
std::string cachePath = UTIL::STRING::toStr(getCurrentDir(L"cache"));
#endif
if (extra.size() > 0)
extra.insert(0, DIRS_WSTR);
return UTIL::STRING::toWStr(cachePath) + extra;
#else
return L"";
// #error NOT IMPLEMENTED
#endif
}