本文整理汇总了C++中String32::length方法的典型用法代码示例。如果您正苦于以下问题:C++ String32::length方法的具体用法?C++ String32::length怎么用?C++ String32::length使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类String32
的用法示例。
在下文中一共展示了String32::length方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getWordStartIdx
/*************************************************************************
Return the index of the first character of the word at 'idx'.
*************************************************************************/
String32::size_type TextUtils::getWordStartIdx(const String32& str, String32::size_type idx)
{
String32 temp = str.substr(0, idx);
trimTrailingChars(temp, DefaultWhitespace);
if (temp.length() <= 1) {
return 0;
}
// identify the type of character at 'pos'
if (String32::npos != DefaultAlphanumerical.find(temp[temp.length() - 1]))
{
idx = temp.find_last_not_of(DefaultAlphanumerical);
}
// since whitespace was stripped, character must be a symbol
else
{
idx = temp.find_last_of(DefaultAlphanumerical + DefaultWhitespace);
}
// make sure we do not go past end of string (+1)
if (idx == String32::npos)
{
return 0;
}
else
{
return idx + 1;
}
}
示例2: getNextWordStartIdx
/*************************************************************************
Return the index of the first character of the word after the word
at 'idx'.
*************************************************************************/
String32::size_type TextUtils::getNextWordStartIdx(const String32& str, String32::size_type idx)
{
String32::size_type str_len = str.length();
// do some checks for simple cases
if ((idx >= str_len) || (str_len == 0))
{
return str_len;
}
// is character at 'idx' alphanumeric
if (String32::npos != DefaultAlphanumerical.find(str[idx]))
{
// find position of next character that is not alphanumeric
idx = str.find_first_not_of(DefaultAlphanumerical, idx);
}
// is character also not whitespace (therefore a symbol)
else if (String32::npos == DefaultWhitespace.find(str[idx]))
{
// find index of next character that is either alphanumeric or whitespace
idx = str.find_first_of(DefaultAlphanumerical + DefaultWhitespace, idx);
}
// check result at this stage.
if (String32::npos == idx)
{
idx = str_len;
}
else
{
// if character at 'idx' is whitespace
if (String32::npos != DefaultWhitespace.find(str[idx]))
{
// find next character that is not whitespace
idx = str.find_first_not_of(DefaultWhitespace, idx);
}
if (String32::npos == idx)
{
idx = str_len;
}
}
return idx;
}