本文整理汇总了C++中gkString::substr方法的典型用法代码示例。如果您正苦于以下问题:C++ gkString::substr方法的具体用法?C++ gkString::substr怎么用?C++ gkString::substr使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gkString
的用法示例。
在下文中一共展示了gkString::substr方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getTextBom
BOM getTextBom(gkString& line, bool removeBom)
{
size_t len = line.size();
BOM bom = getTextEncoding(line.c_str(), len);
if (bom != BOM_NONE && removeBom) {
//strip bom
line = line.substr(getBOMLength(bom));
}
return bom;
}
示例2: strSplit
//-- gkString
//from ogre3d StringUtil
liStrVec strSplit( const gkString& str, const gkString& delims, UTuint32 maxSplits)
{
liStrVec ret;
// Pre-allocate some space for performance
ret.reserve(maxSplits ? maxSplits+1 : 10); // 10 is guessed capacity for most case
unsigned int numSplits = 0;
// Use STL methods
size_t start, pos;
start = 0;
do
{
pos = str.find_first_of(delims, start);
if (pos == start)
{
// Do nothing
start = pos + 1;
}
else if (pos == gkString::npos || (maxSplits && numSplits == maxSplits))
{
// Copy the rest of the gkString
ret.push_back( str.substr(start) );
break;
}
else
{
// Copy up to delimiter
ret.push_back( str.substr(start, pos - start) );
start = pos + 1;
}
// parse up to next real data
start = str.find_first_not_of(delims, start);
++numSplits;
} while (pos != gkString::npos);
return ret;
}