本文整理汇总了C++中std_string类的典型用法代码示例。如果您正苦于以下问题:C++ std_string类的具体用法?C++ std_string怎么用?C++ std_string使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了std_string类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: UpdateNativeImage
void UpdateNativeImage(bool bInstall)
{
const std_string strNGen = FindNGen();
if(strNGen.size() == 0) return;
const std_string strKeePassExe = GetKeePassExePath();
if(strKeePassExe.size() == 0) return;
std_string strParam = (bInstall ? _T("") : _T("un"));
strParam += _T("install \"");
strParam += strKeePassExe + _T("\"");
SHELLEXECUTEINFO sei;
ZeroMemory(&sei, sizeof(SHELLEXECUTEINFO));
sei.cbSize = sizeof(SHELLEXECUTEINFO);
sei.fMask = SEE_MASK_NOCLOSEPROCESS;
sei.lpVerb = _T("open");
sei.lpFile = strNGen.c_str();
sei.lpParameters = strParam.c_str();
sei.nShow = SW_HIDE;
ShellExecuteEx(&sei);
if(sei.hProcess != NULL)
{
WaitForSingleObject(sei.hProcess, 16000);
CloseHandle(sei.hProcess);
}
}
示例2: FindNGenRec
void FindNGenRec(const std_string& strPath, std_string& strNGenPath,
ULONGLONG& ullVersion)
{
const std_string strSearch = strPath + _T("*.*");
const std_string strNGen = _T("ngen.exe");
WIN32_FIND_DATA wfd;
ZeroMemory(&wfd, sizeof(WIN32_FIND_DATA));
HANDLE hFind = FindFirstFile(strSearch.c_str(), &wfd);
if(hFind == INVALID_HANDLE_VALUE) return;
while(true)
{
if((wfd.cFileName[0] == 0) || (_tcsicmp(wfd.cFileName, _T(".")) == 0) ||
(_tcsicmp(wfd.cFileName, _T("..")) == 0)) { }
else if((wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0)
FindNGenRec((strPath + wfd.cFileName) + _T("\\"), strNGenPath, ullVersion);
else if(_tcsicmp(wfd.cFileName, strNGen.c_str()) == 0)
{
const std_string strFullPath = strPath + strNGen;
const ULONGLONG ullThisVer = SiuGetFileVersion(strFullPath);
if(ullThisVer >= ullVersion)
{
strNGenPath = strFullPath;
ullVersion = ullThisVer;
}
}
if(FindNextFile(hFind, &wfd) == FALSE) break;
}
FindClose(hFind);
}
示例3: EnsureTerminatingSeparator
void EnsureTerminatingSeparator(std_string& strPath)
{
if(strPath.size() == 0) return;
if(strPath.c_str()[strPath.size() - 1] == _T('\\')) return;
strPath += _T("\\");
}
示例4: FindNGenRec
void FindNGenRec(const std_string& strPath, std_string& strNGenPath, FILETIME& ftCreation)
{
const std_string strSearch = strPath + _T("*.*");
const std_string strNGen = _T("ngen.exe");
WIN32_FIND_DATA wfd;
ZeroMemory(&wfd, sizeof(WIN32_FIND_DATA));
HANDLE hFind = FindFirstFile(strSearch.c_str(), &wfd);
if(hFind == INVALID_HANDLE_VALUE) return;
while(true)
{
if((wfd.cFileName[0] == 0) || (_tcsicmp(wfd.cFileName, _T(".")) == 0) ||
(_tcsicmp(wfd.cFileName, _T("..")) == 0)) { }
else if((wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0)
FindNGenRec((strPath + wfd.cFileName) + _T("\\"), strNGenPath, ftCreation);
else if(_tcsicmp(wfd.cFileName, strNGen.c_str()) == 0)
{
if((wfd.ftCreationTime.dwHighDateTime > ftCreation.dwHighDateTime) ||
((wfd.ftCreationTime.dwHighDateTime == ftCreation.dwHighDateTime) &&
(wfd.ftCreationTime.dwLowDateTime > ftCreation.dwLowDateTime)))
{
strNGenPath = strPath + wfd.cFileName;
ftCreation = wfd.ftCreationTime;
}
}
if(FindNextFile(hFind, &wfd) == FALSE) break;
}
FindClose(hFind);
}
示例5: CheckDotNetInstalled
void CheckDotNetInstalled()
{
OSVERSIONINFO osv;
ZeroMemory(&osv, sizeof(OSVERSIONINFO));
osv.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
GetVersionEx(&osv);
if(osv.dwMajorVersion >= 6) return; // .NET ships with Vista and higher
const std_string strNGen = FindNGen();
if(strNGen.size() == 0)
{
std_string strMsg = _T("KeePass 2.x requires the Microsoft .NET Framework >= 2.0, ");
strMsg += _T("however this framework currently doesn't seem to be installed ");
strMsg += _T("on your computer. Without this framework, KeePass will not run.\r\n\r\n");
strMsg += _T("The Microsoft .NET Framework is available as free download from the ");
strMsg += _T("Microsoft website.\r\n\r\n");
strMsg += _T("Do you want to visit the Microsoft website now?");
const int nRes = MessageBox(NULL, strMsg.c_str(), _T("KeePass Setup"),
MB_ICONQUESTION | MB_YESNO);
if(nRes == IDYES)
{
SHELLEXECUTEINFO sei;
ZeroMemory(&sei, sizeof(SHELLEXECUTEINFO));
sei.cbSize = sizeof(SHELLEXECUTEINFO);
sei.lpVerb = _T("open");
sei.lpFile = _T("http://msdn.microsoft.com/en-us/netframework/aa569263.aspx");
sei.nShow = SW_SHOW;
ShellExecuteEx(&sei);
}
}
}
示例6: _tWinMain
int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPTSTR lpCmdLine, int nCmdShow)
{
UNREFERENCED_PARAMETER(hInstance);
UNREFERENCED_PARAMETER(hPrevInstance);
UNREFERENCED_PARAMETER(lpCmdLine);
UNREFERENCED_PARAMETER(nCmdShow);
INITCOMMONCONTROLSEX icc;
ZeroMemory(&icc, sizeof(INITCOMMONCONTROLSEX));
icc.dwSize = sizeof(INITCOMMONCONTROLSEX);
icc.dwICC = ICC_STANDARD_CLASSES;
InitCommonControlsEx(&icc);
std_string strCmdLine = GetCommandLine();
boost::trim_if(strCmdLine, boost::is_any_of(g_lpPathTrimChars));
std::transform(strCmdLine.begin(), strCmdLine.end(), strCmdLine.begin(), tolower);
if((strCmdLine.size() >= g_strNGenInstall.size()) && (strCmdLine.substr(
strCmdLine.size() - g_strNGenInstall.size()) == g_strNGenInstall))
{
UpdateNativeImage(false);
Sleep(200);
UpdateNativeImage(true);
}
if((strCmdLine.size() >= g_strNGenUninstall.size()) && (strCmdLine.substr(
strCmdLine.size() - g_strNGenUninstall.size()) == g_strNGenUninstall))
{
UpdateNativeImage(false);
}
if((strCmdLine.size() >= g_strPreLoadRegister.size()) && (strCmdLine.substr(
strCmdLine.size() - g_strPreLoadRegister.size()) == g_strPreLoadRegister))
{
RegisterPreLoad(true);
}
if((strCmdLine.size() >= g_strPreLoadUnregister.size()) && (strCmdLine.substr(
strCmdLine.size() - g_strPreLoadUnregister.size()) == g_strPreLoadUnregister))
{
RegisterPreLoad(false);
}
if((strCmdLine.size() >= g_strNetCheck.size()) && (strCmdLine.substr(
strCmdLine.size() - g_strNetCheck.size()) == g_strNetCheck))
{
CheckDotNetInstalled();
}
return 0;
}
示例7: makeLine
void cFreeType::makeLine(sFreeTypeFontDesc const& desc, std_string const& str, cFreeTypeLine& line)
{
cFreeTypeFont* font = m_ftFontCash->get(desc.m_name);
if (!font)
{
assert(0 && _T("failed find font"));
return ;
}
font->setSize(desc.m_size);
line.setStr(str);
TCHAR const* c_str = str.c_str();
for (size_t i = 0; i < str.length(); ++i)
{
line.addGlyph(m_ftGlyphCash->getKey(desc, font->getFace(), c_str[i]));
}
}
示例8: memcpy
bool cSceneManager::createScene(std_string const& filename, int loadingType)
{
cSerializeBsd serialize;
cSerializeBsd::sData data;
if (!serialize.load(filename, data))
return false;
m_worldOctree->addScene(data.getOctreeOnce(), true);
m_terrain = data.getTerrainOnce();
m_terrain->initialize();
memcpy(&m_cullFigure, &data.m_cullFigure, sizeof (sCullFigure));
assert(m_terrain);
BUID buid;
std_string _filename;
std_string bmdName;
std_string passName = cFileHelper::getPassNameInFullPassT(filename.c_str());
if (LOADING_BACKGROUND == loadingType)
{
for (UINT i = 0; i < data.getRdSize(); ++i)
{
buid = data.m_rdList[i].m_buid;
cSerializeBmd::makeFileName(buid, bmdName);
_filename = passName + bmdName;
sModelLoadInfo info(buid, _filename);
info.m_pos = data.m_rdList[i].m_position;
info.m_radian = 0.0f;
info.m_isScene = true;
info.m_shareType = (uint)(ST_IB | ST_VB);
m_modelCache->addLoadingList(info);
m_entityMgr->createEntity<cEntityModel>(info.getBuid());
}
}
else if (LOADING_DIRECT == loadingType)
{
for (UINT i = 0; i < data.getRdSize(); ++i)
{
buid = data.m_rdList[i].m_buid;
cSerializeBmd::makeFileName(buid, bmdName);
_filename = passName + bmdName;
createEntity<cEntityModel>(_filename, buid, data.m_rdList[i].m_position, 1.0f, loadingType);
}
}
else if (LOADING_ACCESS == loadingType)
{
}
return true;
}
示例9: GetNodeName
void CXmlReader::GetNodeName(std_string &strName)
{
strName.clear();
if (m_pOpenElement)
{
const char* p = m_pOpenElement->Value();
if (p != NULL)
{
strName = UTF8ToTChar(p);
}
}
}
示例10: GetNodeContent
void CXmlReader::GetNodeContent(std_string &strText)
{
strText.clear();
if (m_pOpenElement)
{
const char* p = m_pOpenElement->GetText();
if (p != NULL)
{
strText = UTF8ToTChar(p);
}
}
}
示例11: SU_SplitSearchTerms
DWORD CPwManager::FindEx(const TCHAR *pszFindString, BOOL bCaseSensitive,
DWORD searchFlags, DWORD nStart)
{
if(((searchFlags & PWMS_REGEX) != 0) || (pszFindString == NULL) ||
(pszFindString[0] == 0))
return this->Find(pszFindString, bCaseSensitive, searchFlags, nStart, DWORD_MAX);
const std_string strText = pszFindString;
if(strText != g_strFindCachedString)
{
g_vFindCachedSplitted = SU_SplitSearchTerms(strText.c_str());
g_strFindCachedString = strText;
}
const std::vector<std_string>* pvTerms = &g_vFindCachedSplitted;
if(pvTerms->size() == 0) return nStart;
DWORD dwIndex = nStart;
while(dwIndex != DWORD_MAX)
{
bool bAllMatch = true;
for(size_t i = 0; i < pvTerms->size(); ++i)
{
const std_string& strTerm = (*pvTerms)[i];
const DWORD dwRes = this->Find(strTerm.c_str(), bCaseSensitive,
searchFlags, dwIndex, DWORD_MAX);
if(dwRes > dwIndex)
{
dwIndex = dwRes;
bAllMatch = false;
break;
}
}
if(bAllMatch) break;
}
return dwIndex;
}
示例12: GetNodeAttribute
void CXmlReader::GetNodeAttribute(LPCTSTR szKey, std_string &strValue)
{
strValue.clear();
if (m_pOpenElement)
{
const char* p = m_pOpenElement->Attribute(TCharToUTF8(szKey));
if (p != NULL)
{
strValue = UTF8ToTChar(p);
}
}
}
示例13: SiuGetFileVersion
ULONGLONG SiuGetFileVersion(const std_string& strFilePath)
{
DWORD dwDummy = 0;
const DWORD dwVerSize = GetFileVersionInfoSize(
strFilePath.c_str(), &dwDummy);
if(dwVerSize == 0) return 0;
boost::scoped_array<BYTE> vVerInfo(new BYTE[dwVerSize]);
if(vVerInfo.get() == NULL) return 0; // Out of memory
if(GetFileVersionInfo(strFilePath.c_str(), 0, dwVerSize,
vVerInfo.get()) == FALSE) return 0;
VS_FIXEDFILEINFO* pFileInfo = NULL;
UINT uFixedInfoLen = 0;
if(VerQueryValue(vVerInfo.get(), _T("\\"), (LPVOID*)&pFileInfo,
&uFixedInfoLen) == FALSE) return 0;
if(pFileInfo == NULL) return 0;
return ((static_cast<ULONGLONG>(pFileInfo->dwFileVersionMS) <<
32) | static_cast<ULONGLONG>(pFileInfo->dwFileVersionLS));
}
示例14: load
bool sCubeTexture::load(std_string const& filename)
{
std_string realPath;
if (!_getFileSystem()->findRealPath(filename, realPath))
{
return false;
}
if (!checkHResultReturn(D3DXCreateCubeTextureFromFile(cD3DSystem::getD3DDevice(), realPath.c_str(), &m_tex)))
return false;
trace(_T("load texture : %s\n"), filename.c_str());
return true;
}
示例15: RegisterPreLoad
void RegisterPreLoad(bool bRegister)
{
const std_string strPath = GetKeePassExePath();
if(strPath.size() == 0) return;
HKEY hKey = NULL;
if(RegOpenKeyEx(HKEY_LOCAL_MACHINE, _T("Software\\Microsoft\\Windows\\CurrentVersion\\Run"),
0, KEY_WRITE, &hKey) != ERROR_SUCCESS) return;
if(hKey == NULL) return;
const std_string strItemName = _T("KeePass 2 PreLoad");
std_string strItemValue = _T("\"");
strItemValue += strPath;
strItemValue += _T("\" --preload");
if(bRegister)
RegSetValueEx(hKey, strItemName.c_str(), 0, REG_SZ,
(const BYTE*)strItemValue.c_str(), static_cast<DWORD>((strItemValue.size() +
1) * sizeof(TCHAR)));
else
RegDeleteValue(hKey, strItemName.c_str());
RegCloseKey(hKey);
}