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


C++ STRING::c_str方法代码示例

本文整理汇总了C++中STRING::c_str方法的典型用法代码示例。如果您正苦于以下问题:C++ STRING::c_str方法的具体用法?C++ STRING::c_str怎么用?C++ STRING::c_str使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在STRING的用法示例。


在下文中一共展示了STRING::c_str方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: DeleteFilesFromDirectory

void OSInterface::DeleteFilesFromDirectory(const STRING& aRootDir,const STRING& aExtension)                    
	{
	STRING			patternOfString;
	WIN32_FIND_DATA fileInfo;
    patternOfString = aRootDir + _T("\\*.*") ;
	
	HANDLE hToFile = ::FindFirstFile(patternOfString.c_str(), &fileInfo);	
	
	if(hToFile != INVALID_HANDLE_VALUE)
		{
		do
			{
			if(fileInfo.cFileName[0] != '.')
				{
				
				STRING file = fileInfo.cFileName;
				
				STRING extOfString = file.substr(file.rfind(_T(".")) + 1);

				if(extOfString == aExtension)
					{
					::DeleteFile(file.c_str());
					}
				}		
			}while(::FindNextFile(hToFile , &fileInfo));

		::FindClose(hToFile);
	  	}
	}
开发者ID:cdaffara,项目名称:symbiandump-mw1,代码行数:29,代码来源:osinterface.cpp

示例2: if

/*
 * Constructor.
 */
CAnimation::CAnimation(const STRING file):
m_users(1) 
{
	extern STRING g_projectPath;

	renderFrame = &CAnimation::renderAnmFrame;

	if (!file.empty())
	{
		const STRING ext = getExtension(file);
	    
		if (_ftcsicmp(ext.c_str(), _T("anm")) == 0)
		{
			m_data.open(g_projectPath + MISC_PATH + file);
		}
		else if (_ftcsicmp(ext.c_str(), _T("gif")) == 0)
		{
			m_data.loadFromGif(resolve(g_projectPath + MISC_PATH + file));
			renderFrame = &CAnimation::renderFileFrame;
			m_data.filename = file;
		}
	}

	freeCanvases();
	m_canvases.resize(m_data.frameCount, NULL);
}
开发者ID:shao113,项目名称:trans3,代码行数:29,代码来源:CAnimation.cpp

示例3: sizeof

// 得到宝石属性信息
LPCTSTR	CObject_Item_Gem::GetGemArribInfo()
{
	
	static TCHAR szAttribInfo[1024];
	TCHAR	szInfo[512];

	memset(szAttribInfo, 0, sizeof(szAttribInfo));
	STRING strAttrib = _T("");

	STRING strTemp = "";
		
	if(m_theBaseDef)
	{
		for(int i = 0; i < 60; i++)
		{
			memset(szInfo, 0, sizeof(szInfo));
			if(-1 != m_theBaseDef->nAttr[i])
			{
				strTemp = NOCOLORMSGFUNC(g_szGemAttName[i]);
				_stprintf(szInfo, _T("%s+%d\n"), strTemp.c_str(), m_theBaseDef->nAttr[i]);
				//_stprintf(szInfo, _T("%s:%d\n"), g_szGemAttName[i], m_theBaseDef->nAttr[i]);
				strAttrib += szInfo;
			}
		}

		_stprintf(szAttribInfo, _T("%s"), strAttrib.c_str());
		return szAttribInfo;
	}

	return szAttribInfo;


}
开发者ID:brock7,项目名称:TianLong,代码行数:34,代码来源:Obj_Item_Gem.cpp

示例4: FreeMount

	/* ------------------------------------------------
	// 放生
	参数1	GUID m_uHighSection
	参数2	GUID m_uLowSection
	------------------------------------------------ */
	INT Mount::FreeMount(LuaPlus::LuaState* state)
	{
		LuaStack args(state);
		if (!(args[2].IsString()))
		{
			KLThrow("Mount::FreeMount[2] param parameter error");
		}
		STRING szHighSection = args[2].GetString();

		if (!(args[3].IsString()))
		{
			KLThrow("Mount::FreeMount[3] param parameter error");
		}
		STRING szLowSection = args[3].GetString();

		PET_GUID_t GUID;
		GUID.m_uHighSection = atol(szHighSection.c_str());
		GUID.m_uLowSection	= atol(szLowSection.c_str());

		const SDATA_PET* pPet = CDataPool::GetMe()->Pet_GetPet(GUID); 
		if (pPet && FALSE == pPet->m_GUID.IsNull())
		{
			//向服务器发送
			CGManipulatePet Msg;

			Msg.SetGUID(pPet->m_GUID);
			Msg.SetManipulateType( MANIPULATE_FREEHORSE );
			CNetManager::GetMe()->SendPacket(&Msg);
		}

		return 0;
	}
开发者ID:jjiezheng,项目名称:pap_full,代码行数:37,代码来源:GMGameInterface_Script_Mount.cpp

示例5: ReadWavBuffer

BOOL CSoundBufferFMod::ReadWavBuffer(const STRING &name)
{
	Release();

	char* lpAddress = NULL;
	DWORD dwSize = CGameProcedure::s_pResourceProvider->loadResource(name.c_str(), lpAddress, "General");
	if(dwSize > 0)
	{
		m_pFModSample = FSOUND_Sample_Load(FSOUND_FREE, 
				lpAddress, 
				FSOUND_HW3D | FSOUND_LOADMEMORY, 0, dwSize);
		CGameProcedure::s_pResourceProvider->unloadResource( lpAddress, dwSize );
	}
	
	if(!m_pFModSample) 
	{
		KLThrow("Invalid sound file:%s", name.c_str());
		return FALSE;
	}

	//缺省所有声音都是不循环的
    FSOUND_Sample_SetMode(m_pFModSample, FSOUND_LOOP_OFF);

	return TRUE;
}
开发者ID:gitrider,项目名称:wxsj2,代码行数:25,代码来源:GMSoundBuffer.cpp

示例6: DelRole_YesNo

	// 询问是否删除角色
	INT CGameProduce_Login::DelRole_YesNo(LuaPlus::LuaState* state)
	{

		LuaStack args(state);
		if (!(args[2].IsInteger()))
		{
			KLThrow("LUA:GetBuffIconNameByIndex param parameter error");
		}

		int iRoleIndex = args[2].GetInteger();
		CGameProcedure::s_pProcCharSel->m_iCurSelRoleDel = iRoleIndex;
		std::vector< STRING > strParamInfo;

		if(CGameProcedure::s_pProcCharSel->IsValidIndex(iRoleIndex))
		{
			// 
			std::string strInfo = ""; 
			// 通过索引得到角色的信息
			const DB_CHAR_BASE_INFO* pInfo = CGameProcedure::s_pProcCharSel->GetRoleInfo(iRoleIndex);
			if(pInfo)
			{
				//if(pInfo->m_Level < 9)
				{
					TCHAR szBuf[128];
					STRING strTemp = "";
					strTemp = NOPARAMMSGFUNC("GMGameInterface_Script_GameLogin_Info_Del_Role_YesNo");
					_stprintf(szBuf, strTemp.c_str(), pInfo->m_Level, pInfo->m_Name);
					//_stprintf(szBuf, _T("你确定要将 %d级 的角色#c00ff00 %s #cffffff删除吗?"), pInfo->m_Level, pInfo->m_Name);
					strParamInfo.push_back(szBuf);
					strParamInfo.push_back("1");

					((CEventSystem*)CGameProcedure::s_pEventSystem)->PushEvent( GE_GAMELOGIN_SYSTEM_INFO_YESNO, strParamInfo);
				}
				//else
				//{
				//	STRING strTemp = "";
				//	strTemp = NOCOLORMSGFUNC("CGameProduce_Login_Can_Not_Del_Level_Over_9");
				//	CGameProcedure::s_pEventSystem->PushEvent( GE_GAMELOGIN_SHOW_SYSTEM_INFO, strTemp.c_str());
				//}//
			}
			else
			{
				STRING strTemp = "";
				strTemp = NOCOLORMSGFUNC("GMGameInterface_Script_GameLogin_Info_Sel_Del_Role");
				CGameProcedure::s_pEventSystem->PushEvent( GE_GAMELOGIN_SHOW_SYSTEM_INFO, strTemp.c_str());
				//CGameProcedure::s_pEventSystem->PushEvent( GE_GAMELOGIN_SHOW_SYSTEM_INFO, "请选择一个要删除的角色.");
			}//
		}
		else
		{
			STRING strTemp = "";
			strTemp = NOCOLORMSGFUNC("GMGameInterface_Script_GameLogin_Info_Sel_Del_Role");
			CGameProcedure::s_pEventSystem->PushEvent( GE_GAMELOGIN_SHOW_SYSTEM_INFO, strTemp.c_str());
			//CGameProcedure::s_pEventSystem->PushEvent( GE_GAMELOGIN_SHOW_SYSTEM_INFO, "请选择一个要删除的角色.");
		}
		
		return 0;
	}
开发者ID:gitrider,项目名称:wxsj2,代码行数:59,代码来源:GMGameinterface_Script_GameProduceLogin.cpp

示例7: Execute

uint GCManualAttrResultHandler::Execute(GCManualAttrResult* pPacket,Player* pPlayer)
{
	__ENTER_FUNCTION
		
		ATTR_RESUlT res = pPacket->GetResult();
		switch(res)
		{
		case ATTR_RESUlT_SUCCESS:
			{
				CGameProcedure::s_pEventSystem->PushEvent( GE_MANUAL_ATTR_SUCCESS_EQUIP );

				STRING strTemp = "";
				strTemp = NOCOLORMSGFUNC("GCManualAttriResultHandler_Info_Addjust_Attr_Success");
				CGameProcedure::s_pEventSystem->PushEvent( GE_NEW_DEBUGMESSAGE, strTemp.c_str());
				//CGameProcedure::s_pEventSystem->PushEvent( GE_NEW_DEBUGMESSAGE, "调整属性成功." );
				break;
			}
		case ATTR_RESULT_NOT_ENOUGH_REMAIN_POINT:
			{

				STRING strTemp = "";
				strTemp = NOCOLORMSGFUNC("GCManualAttriResultHandler_Info_Addjust_Attr_Fail_No_Enough_point");
				CGameProcedure::s_pEventSystem->PushEvent( GE_NEW_DEBUGMESSAGE, strTemp.c_str());
				//CGameProcedure::s_pEventSystem->PushEvent( GE_NEW_DEBUGMESSAGE, "调整属性失败,没有足够的点数." );
				break;
			}
		case ATTR_RESULT_NO_SUCH_ATTR:
			{
				
				STRING strTemp = "";
				strTemp = NOCOLORMSGFUNC("GCManualAttriResultHandler_Info_Addjust_Attr_Fail_No_This_Attri");
				CGameProcedure::s_pEventSystem->PushEvent( GE_NEW_DEBUGMESSAGE, strTemp.c_str());
				//CGameProcedure::s_pEventSystem->PushEvent( GE_NEW_DEBUGMESSAGE, "调整属性失败, 没有这个属性." );
				break;
			}
		case ATTR_RESUlT_NO_POINT:
			{

				STRING strTemp = "";
				strTemp = NOCOLORMSGFUNC("GCManualAttriResultHandler_Info_Addjust_Attr_Fail_No_Enough_point");
				CGameProcedure::s_pEventSystem->PushEvent( GE_NEW_DEBUGMESSAGE, strTemp.c_str());
				//CGameProcedure::s_pEventSystem->PushEvent( GE_NEW_DEBUGMESSAGE, "调整属性失败,没有足够的点数." );
				break;
			}

		default:
			{
				break;
			}
		}

		
		return PACKET_EXE_CONTINUE;

	__LEAVE_FUNCTION	

		return PACKET_EXE_ERROR;
}
开发者ID:gitrider,项目名称:wxsj2,代码行数:58,代码来源:GCManualAttrResultHandler.cpp

示例8:

CKT::CVersion::CVersion(STRING version)
{
	int iPoint = version.find('.');
	STRING sTemp = version.substr(0, iPoint);
	m_byMajor = (BYTE)toInt(sTemp.c_str());

	sTemp = version.substr(iPoint + 1, version.length() - iPoint);
	m_byMinor = (BYTE)toInt(sTemp.c_str());
}
开发者ID:Chefkoch85,项目名称:D3D_2D_Engine,代码行数:9,代码来源:Version.cpp

示例9: SendGetInet

void HttpSocket::SendGetInet(const STRING &url, const STRING &host, const int &port, std::vector<char> *data)
{
	char d[4096];
	DWORD len;
	stringstream lss;
	INTERNET_BUFFERS BufferIn = {0};

	BufferIn.dwStructSize = sizeof( INTERNET_BUFFERS );

	HINTERNET hNet = InternetOpen(_T("peelClient"), INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, NULL);
	if(!hNet)
		throw SocketException(_T("Could not open internet"), GetError());
	
	HINTERNET hCon = InternetConnect(hNet, host.c_str(), port , 0, 0, INTERNET_SERVICE_HTTP, 0, 0);
	if(!hCon)
	{
		InternetCloseHandle(hNet);
		throw SocketException(_T("Could not connect to server"), GetError());
	}

	HINTERNET hReq = HttpOpenRequest(hCon, _T("GET"), url.c_str(), 0, 0, 0, INTERNET_FLAG_RELOAD, 0);
	if(!hReq)
	{
		InternetCloseHandle(hNet);
		InternetCloseHandle(hCon);
		throw SocketException(_T("Could not open request to server"), GetError());
	}

	if(!HttpSendRequest(hReq, NULL, NULL, NULL, NULL))
	{
		InternetCloseHandle(hNet);
		InternetCloseHandle(hCon);
		throw SocketException(_T("Could not send request to server"), GetError());
	}



	if(data != NULL)
	{
		lss.str("");

		while(1)
		{
			if(!InternetReadFile(hReq, d, 4095, &len))
				break;
			if(len==0) break;
			d[len]='\0';
            std::copy( d, d+len, (*data).begin());
		}
	}

	InternetCloseHandle(hNet);
	InternetCloseHandle(hCon);

}
开发者ID:mocap-ca,项目名称:peellib,代码行数:55,代码来源:HttpSocket.cpp

示例10: NotImplemented

void JustRenderIt::NotImplemented(bool halt, STRING msg)
{
  STRING str = msg + " Not implemented!";

  if(!halt)
    LOG_WARNING1(str.c_str());
  else
  {
    LOG_FATAL1(str.c_str());
  }
}
开发者ID:ranjiao,项目名称:JustRenderIt,代码行数:11,代码来源:Util.cpp

示例11: getArg

bool XmlTagEntity::getArg(STRING name, int &ivalue)
{
	STRING tmp;
	if(!getArg(name, tmp)) return false;
#ifdef _WIN32
	ivalue = _tstoi(tmp.c_str());
#else
	ivalue = atoi(tmp.c_str());
#endif
	return true;
}
开发者ID:mocap-ca,项目名称:peellib,代码行数:11,代码来源:XmlTagGet.cpp

示例12: LoadVariable

//从文件中读取变量
VOID CVariableSystem::LoadVariable(LPCTSTR szFileName, VARIABLE_MAP& mapBuf)
{
	KLAssert(szFileName);
	//	mapBuf.clear();

	//-----------------------------------------------------------
	//取得配置文件的大小
	HANDLE hFile = CreateFile(szFileName,
		GENERIC_READ,
		FILE_SHARE_READ | FILE_SHARE_WRITE,
		NULL,
		OPEN_EXISTING,
		FILE_ATTRIBUTE_NORMAL,
		NULL);

	if(INVALID_HANDLE_VALUE == hFile) return;

	DWORD dwHigh;
	DWORD dwFileSize = GetFileSize(hFile, &dwHigh);
	CloseHandle(hFile); hFile = NULL;
	if(0==dwFileSize) return;

	//-----------------------------------------------------------
	//分配足够的内存
	CHAR* pTempBuf = new CHAR[dwFileSize+32];
	if(!pTempBuf) return;

	//-----------------------------------------------------------
	//从配置文件中读取"Variable"节
	::GetPrivateProfileSection("Variable", pTempBuf, dwFileSize, szFileName);
	//分解
	std::vector< STRING > vRet;
	ConvertSectionInVector(pTempBuf, dwFileSize, vRet);

	delete[] pTempBuf; pTempBuf=NULL;

	//加入变量定义
	for(INT i=0; i<(INT)vRet.size(); i++)
	{
		STRING& strLine = vRet[i];

		STRING::size_type tEqu = strLine.find_first_of("= \t");
		if(tEqu == STRING::npos) continue;

		STRING strName = strLine.substr(0, tEqu);

		CHAR szTemp[1024];
		::GetPrivateProfileString("Variable", strName.c_str(), "", szTemp, 1024, szFileName);

		SetVariable(strName.c_str(), szTemp, FALSE);
	}

}
开发者ID:gitrider,项目名称:wxsj2,代码行数:54,代码来源:GMVariable.cpp

示例13: EditDlg_OnInitDialog

BOOL EditDlg_OnInitDialog(HWND hwnd, HWND hwndFocus, LPARAM lParam)
{
    COMBOBOXEXITEMW Item;
    ZeroMemory(&Item, sizeof(Item));
    Item.mask = CBEIF_TEXT;

    FONTNAMESET::iterator it, end = g_Names.end();
    for (it = g_Names.begin(); it != end; ++it)
    {
        Item.pszText = const_cast<LPWSTR>(it->c_str());
        Item.iItem = ComboBox_GetCount(GetDlgItem(hwnd, cmb2));
        SendDlgItemMessageW(hwnd, cmb2, CBEM_INSERTITEM, 0, (LPARAM)&Item);
    }
    SetDlgItemTextW(hwnd, edt1, g_strFontName.c_str());
    SetDlgItemTextW(hwnd, cmb2, g_strSubstitute.c_str());

    const INT Count = _countof(g_CharSetList);
    for (INT i = 0; i < Count; ++i)
    {
        Item.pszText = const_cast<LPWSTR>(g_CharSetList[i].DisplayName);
        Item.iItem = ComboBox_GetCount(GetDlgItem(hwnd, cmb3));
        SendDlgItemMessageW(hwnd, cmb3, CBEM_INSERTITEM, 0, (LPARAM)&Item);
        Item.iItem = ComboBox_GetCount(GetDlgItem(hwnd, cmb4));
        SendDlgItemMessageW(hwnd, cmb4, CBEM_INSERTITEM, 0, (LPARAM)&Item);
    }

    SendDlgItemMessageW(hwnd, cmb3, CB_SETCURSEL, 0, 0);
    SendDlgItemMessageW(hwnd, cmb4, CB_SETCURSEL, 0, 0);
    for (INT i = 0; i < Count; ++i)
    {
        if (g_CharSet1 == g_CharSetList[i].CharSet)
        {
            SendDlgItemMessageW(hwnd, cmb3, CB_SETCURSEL, i, 0);
        }
        if (g_CharSet2 == g_CharSetList[i].CharSet)
        {
            SendDlgItemMessageW(hwnd, cmb4, CB_SETCURSEL, i, 0);
        }
    }

    SIZE siz;
    HDC hDC = CreateCompatibleDC(NULL);
    SelectObject(hDC, GetStockObject(DEFAULT_GUI_FONT));
    GetTextExtentPoint32W(hDC, g_LongestName, lstrlenW(g_LongestName), &siz);
    DeleteDC(hDC);

    SendDlgItemMessageW(hwnd, cmb3, CB_SETHORIZONTALEXTENT, siz.cx + 16, 0);
    SendDlgItemMessageW(hwnd, cmb4, CB_SETHORIZONTALEXTENT, siz.cx + 16, 0);

    EnableWindow(GetDlgItem(hwnd, cmb3), FALSE);

    return TRUE;
}
开发者ID:Moteesh,项目名称:reactos,代码行数:53,代码来源:fontsub.cpp

示例14: args

	//宠物改名字
	INT	Pet::Change_Name(LuaPlus::LuaState* state)
	{
		LuaStack args(state);

		if ( !(args[2].IsInteger()) || !(args[3].IsString()) )
		{
			KLThrow("LUA:Pet Change_Name parameter error");
		}

		INT nPetNum = args[2].GetInteger();
		LPCTSTR szName = args[3].GetString();
		STRING szTemp="";

		SDATA_PET* My_Pet= CDataPool::GetMe()->Pet_GetPet(nPetNum);
		if( (!My_Pet) || ( !My_Pet->m_pModelData ) ) 
		{
			KLThrow("LUA:Pet Change_Name parameter error");
			return 0;
		}
		if(CGameProcedure::s_pUISystem->CheckStringFilter(szName, FT_NAME) == FALSE)
		{
			
			STRING strTemp = "";
			strTemp = NOCOLORMSGFUNC("GMGameInterface_Script_Talk_Info_InvalidContent");
			CEventSystem::GetMe()->PushEvent(GE_NEW_DEBUGMESSAGE,strTemp.c_str());
			return 0;

		}
		else if(CGameProcedure::s_pUISystem->CheckStringCode(szName,szTemp) == FALSE)
		{

			return 0;

		}
		else if(KLU_CheckStringValid(szName) == FALSE)
		{
			STRING strTemp = "";
			strTemp = NOCOLORMSGFUNC("ERRORSpecialString");
			CEventSystem::GetMe()->PushEvent(GE_NEW_DEBUGMESSAGE,strTemp.c_str());
			return 0;
		}
		//向服务器发送
		CGSetPetAttrib Msg;
		if(strcmp(szName, My_Pet->m_szName.c_str()) != 0)
		{
			Msg.SetGUID(My_Pet->m_GUID);
//			Msg.SetIndex(nPetNum);		
			Msg.SetName((CHAR*)szName);
			CNetManager::GetMe()->SendPacket(&Msg);
		}
		return 0;
	}
开发者ID:gitrider,项目名称:wxsj2,代码行数:53,代码来源:GMGameInterface_Script_Pet.cpp

示例15: resolvePakFile

// Resolve a file name
STRING resolvePakFile(const STRING path)
{
	if(path.find("Saved\\",0) ==0){ return path;}
	const STRING file = g_pakTempPath + path;
	resolve = resolveNonPakFile;
	if (!CFile::fileExists(file))
	{
		// Extract the file from the pak file or this executable.
		// (Assume the zip is open!)
		ZIPExtract(const_cast<char *>(path.c_str()), const_cast<char *>(file.c_str()));
	}
	resolve = resolvePakFile;
	return file;
}
开发者ID:LameAss-Studio,项目名称:trans3,代码行数:15,代码来源:paths.cpp


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