本文整理汇总了C++中TSTRING::find_first_not_of方法的典型用法代码示例。如果您正苦于以下问题:C++ TSTRING::find_first_not_of方法的具体用法?C++ TSTRING::find_first_not_of怎么用?C++ TSTRING::find_first_not_of使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TSTRING
的用法示例。
在下文中一共展示了TSTRING::find_first_not_of方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: util_GetNextPathElement
////////////////////////////////////////////////////////////////////////////////////
// Function name : util_GetNextPathElement
// Description :
// starting from the left side of the path string, returns the index'th path element
// returns true if the element exists, false if there aren't <index + 1> many elements
//
// index is ZERO BASED
//
// 2rd element of ABC/DEF/GH -> GH
// 1st element of //ABC/DEF/GH -> DEF
//
// Return type : bool : got path element? ( i.e. was there index path elements? )
// Argument : const TSTRING& strPathC
// Argument : TSTRING& strElem
// Argument : int index
/////////////////////////////////////////////////////////////////////////////////
bool util_GetNextPathElement(const TSTRING& strPathC, TSTRING& strElem, int index)
{
// don't do anything if root or empty
if (strPathC.empty() || iFSServices::GetInstance()->IsRoot(strPathC))
return false;
TSTRING strPath = strPathC; // writable local version
bool fMoreSeps = true;
TSTRING::size_type nextSep, nextNonSep;
nextSep = nextNonSep = (TSTRING::size_type)-1;
for (int i = 0; i <= index && fMoreSeps; i++)
{
// go past leading separators
nextNonSep = strPath.find_first_not_of(TW_SLASH, nextSep + 1);
if (nextNonSep != TSTRING::npos)
{
// find index'th slash (start of index'th element)
nextSep = strPath.find(TW_SLASH, nextNonSep);
// if we're at the end and we haven't found the index'th element
// left, then tell the caller that there aren't that many elemnts
if (nextSep == TSTRING::npos && i < index)
fMoreSeps = false;
}
else
fMoreSeps = false;
}
// get the element and remove it from the path
if (fMoreSeps)
strElem = strPath.substr(nextNonSep, nextSep - nextNonSep);
return (fMoreSeps);
}