本文整理汇总了C++中tstring::rfind方法的典型用法代码示例。如果您正苦于以下问题:C++ tstring::rfind方法的具体用法?C++ tstring::rfind怎么用?C++ tstring::rfind使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tstring
的用法示例。
在下文中一共展示了tstring::rfind方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ExtractFileName
tstring ExtractFileName(const tstring& path)
{
size_t pos1 = path.rfind('\\');
size_t pos2 = path.rfind('/');
pos1 = min(pos1, pos2);
if (pos1 != tstring::npos)
{
return path.substr(pos1 + 1);
}
return path;
}
示例2: SetNick
void CFulEditCtrl::SetNick(const tstring& aNick) {
if(isSet(STRIP_ISP)) {
tstring::size_type pos = aNick.find(_T("["));
if( pos != tstring::npos ) {
tstring::size_type rpos = aNick.rfind(_T("]"));
if( rpos == aNick.length() -1 && rpos > 0 ) // this user has a stupid fucking nick bah ugly hate it
rpos = aNick.rfind(_T("]"), rpos-1);
if(rpos != tstring::npos)
nick = aNick.substr(rpos+1);
}
} else {
nick = aNick;
}
}
示例3: GetFileDirectory
tstring FileUtil::GetFileDirectory(const tstring &filename)
{
tstring directory;
const size_t last_slash_idx = filename.rfind(_T('\\'));
if (tstring::npos != last_slash_idx)
{
directory = filename.substr(0, last_slash_idx);
}
return directory;
}
示例4: remove_double_dirs
/// Removes all "../" references from the absolute path fn
/// If string contains f/d/e/../a replace it with f/d/a/
static void remove_double_dirs(tstring &fn) {
tstring search;
search.push_back(DIR_SEPARATOR);
search.push_back('.');
search.push_back('.');
search.push_back(DIR_SEPARATOR);
while (true) {
size_t loc = fn.find(search);
if (loc == tstring::npos)
break;
// See if there is another dir separator before the /../ we just
// found.
size_t before = fn.rfind(DIR_SEPARATOR, loc-1);
if (before == tstring::npos)
break;
// Now delete all between before+1 and loc+3
fn.erase(fn.begin()+before+1, fn.begin()+loc+4);
}
}
示例5: get_string_suffix
tstring get_string_suffix(const tstring& str, const tstring& separator) {
const tstring::size_type last_separator_pos = str.rfind(separator);
if (last_separator_pos == tstring::npos)
return str;
return str.substr(last_separator_pos + separator.size(), tstring::npos);
}
示例6: get_string_prefix
tstring get_string_prefix(const tstring& str, const tstring& separator) {
const tstring::size_type last_separator_pos = str.rfind(separator);
if (last_separator_pos == string::npos)
return str;
return str.substr(0, last_separator_pos);
}
示例7: name
/// Create array of names
BSTR* scripts = new BSTR[files.size()];
*names = scripts;
*count = static_cast<ULONG>(files.size());
for(ULONG i = 0; i < files.size(); ++i)
{
tstring name(files.front());
files.pop_front();
scripts[i] = ::SysAllocString(T2OLE(name.c_str()));
}
CATCH_LOG_COM
}
tstring CScriptsEnumerator::GetArchiveName(const WIN32_FIND_DATA* fileData)
{
TRY_CATCH
if(!fileData)
return _T("");
tstring fileName(fileData->cFileName);
tstring::size_type pos = fileName.rfind(_T("."));
if(tstring::npos == pos)
return _T("");
tstring name = fileName.substr(0, pos);
fileName.erase(0, pos + 1);
if(LowerCase(fileName) != tstring(SCRIPT_FILES_EXT))
return _T("");
return name;
CATCH_THROW()
}
示例8: ParseParameter
/////////////////////////////////////////////////////////////////////
//
// Function:
//
// Description:
//
/////////////////////////////////////////////////////////////////////
tstring CACreateProjectInitFile::ParseParameter(tstring& strSetupExeName, tstring& strParameter)
{
tstring strParameterName;
tstring strEncodedValue;
tstring strParameterValue;
tstring strError;
size_t iParameterStart = 0;
size_t iParameterEnd = 0;
strParameterName = strParameter + _T("_");
strError = _T("Searching for parameter '");
strError += strParameterName;
strError += _T("'");
LogMessage(
INSTALLMESSAGE_INFO,
NULL,
NULL,
NULL,
NULL,
strError.c_str()
);
iParameterStart = strSetupExeName.rfind(strParameterName);
if (iParameterStart != tstring::npos) {
iParameterStart += strParameterName.size();
iParameterEnd = strSetupExeName.find(_T("_"), iParameterStart);
if (iParameterEnd == tstring::npos) {
iParameterEnd = strSetupExeName.find(_T("."), iParameterStart);
if (iParameterEnd == tstring::npos) {
return tstring(_T(""));
}
}
strEncodedValue = strSetupExeName.substr(iParameterStart, iParameterEnd - iParameterStart);
strError = _T("Found encoded value '");
strError += strEncodedValue;
strError += _T("'");
LogMessage(
INSTALLMESSAGE_INFO,
NULL,
NULL,
NULL,
NULL,
strError.c_str()
);
// WCG didn't want to have to encode their setup cookie value. So all parameters but the setup cookie
// are base64 encoded.
//
if (strParameterName == _T("asc_")) {
strParameterValue = strEncodedValue;
} else {
CW2A pszASCIIEncodedValue( strEncodedValue.c_str() );
CA2W pszUnicodeDecodedValue( r_base64_decode(pszASCIIEncodedValue, strlen(pszASCIIEncodedValue)).c_str() );
strError = _T("Decoded value '");
strError += pszUnicodeDecodedValue;
strError += _T("'");
LogMessage(
INSTALLMESSAGE_INFO,
NULL,
NULL,
NULL,
NULL,
strError.c_str()
);
strParameterValue = pszUnicodeDecodedValue;
}
}
strError = _T("Returning value '");
strError += strParameterValue;
strError += _T("'");
LogMessage(
INSTALLMESSAGE_INFO,
NULL,
NULL,
NULL,
NULL,
strError.c_str()
);
return strParameterValue;
//.........这里部分代码省略.........
示例9: AddLevelObject
bool EditorLoader::AddLevelObject( const tstring& modelPath,
const tstring& physxModelPath,
const tstring& normalPath,
const tstring& diffusePath,
const tstring& specPath,
const tstring& glossPath )
{
if (modelPath != _T("") && physxModelPath != _T(""))
{
if (physxModelPath.rfind(_T(".nxsoftbody")) == tstring::npos)
{
bool rigid = false;
int ret = MessageBoxA(0, "Load as staticmesh?", "Loading: ", MB_ICONQUESTION | MB_YESNO);
switch (ret)
{
case IDYES: rigid = false; break;
default: rigid = true; break;
}
SimpleObject* pObj = new SimpleObject();
pObj->SetNormalPath(normalPath);
pObj->SetModelPath(modelPath);
pObj->SetPhysXModel(physxModelPath);
pObj->SetDiffusePath(diffusePath);
pObj->SetSpecPath(specPath);
pObj->SetGlossPath(glossPath);
pObj->SetRigid(rigid);
Vector3 vLook = m_pRenderContext->GetCamera()->GetLook();
vLook.Normalize();
pObj->Init(m_pPhysXEngine);
pObj->Translate(m_pRenderContext->GetCamera()->GetPosition() + vLook * 10);
m_pLevel->AddLevelObject(pObj);
}
else
{
Vector3 vLook = m_pRenderContext->GetCamera()->GetLook();
vLook.Normalize();
SimpleSoftbody* pSoftbody = new SimpleSoftbody(m_pRenderContext->GetCamera()->GetPosition() + vLook * 10);
pSoftbody->SetModelPath(modelPath);
pSoftbody->SetPhysXModel(physxModelPath);
pSoftbody->SetDiffusePath(diffusePath);
pSoftbody->SetSpecPath(specPath);
pSoftbody->SetGlossPath(glossPath);
pSoftbody->SetNormalPath(normalPath);
pSoftbody->Init(m_pPhysXEngine);
m_pLevel->AddLevelObject(pSoftbody);
}
return true;
}
return false;
}