当前位置: 首页>>代码示例>>C++>>正文


C++ wstring::insert方法代码示例

本文整理汇总了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);
}
开发者ID:CodeMat,项目名称:ContinuousTests,代码行数:15,代码来源:FunctionProfiler_Info_Runtime.cpp

示例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
}
开发者ID:Alasaad,项目名称:Desurium,代码行数:35,代码来源:UtilOs.cpp

示例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;
}
开发者ID:AstroProfundis,项目名称:pcap_dnsproxy,代码行数:59,代码来源:Service.cpp

示例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;
}
开发者ID:Guimashi,项目名称:pcap_dnsproxy,代码行数:58,代码来源:Main.cpp

示例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;
	}
}
开发者ID:funagi,项目名称:rainmeter,代码行数:12,代码来源:StringUtil.cpp

示例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;
}
开发者ID:Sithisackt,项目名称:kodi,代码行数:10,代码来源:WIN32Util.cpp

示例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();
    }
}
开发者ID:DamianReloaded,项目名称:OwlSL,代码行数:10,代码来源:text.cpp

示例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;
}
开发者ID:node-migrator-bot,项目名称:appjs,代码行数:53,代码来源:launch.cpp

示例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();
}
开发者ID:nbolton,项目名称:vimrid,代码行数:22,代码来源:dataHandlerDateTimeBase.cpp

示例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;
	}
}
开发者ID:funagi,项目名称:rainmeter,代码行数:15,代码来源:StringUtil.cpp

示例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!");
}
开发者ID:killbug2004,项目名称:WSProf,代码行数:50,代码来源:RecipientsHandler.cpp

示例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();
}
开发者ID:BackupTheBerlios,项目名称:mimplugins-svn,代码行数:15,代码来源:formatting.cpp

示例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;
    }
开发者ID:456z,项目名称:gosu,代码行数:17,代码来源:TextInput.cpp

示例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
}
开发者ID:harmy,项目名称:Desurium,代码行数:21,代码来源:UtilOs.cpp

示例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
}
开发者ID:Alasaad,项目名称:Desurium,代码行数:22,代码来源:UtilOs.cpp


注:本文中的std::wstring::insert方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。