本文整理汇总了C++中StringVar::Count方法的典型用法代码示例。如果您正苦于以下问题:C++ StringVar::Count方法的具体用法?C++ StringVar::Count怎么用?C++ StringVar::Count使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StringVar
的用法示例。
在下文中一共展示了StringVar::Count方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: StringVar_Find_Execute
bool StringVar_Find_Execute(COMMAND_ARGS, UInt32 mode, CommandInfo* commandInfo)
{
*result = -1;
UInt32 strID = 0;
UInt32 startPos = 0;
UInt32 numChars = -1;
UInt32 bCaseSensitive = 0;
UInt32 numToReplace = -1; //replace all by default
char toFind[kMaxMessageLength] = { 0 };
UInt32 intResult = -1;
if (!ExtractFormatStringArgs(0, toFind, PASS_FMTSTR_ARGS, commandInfo->numParams, &strID, &startPos, &numChars, &bCaseSensitive, &numToReplace))
return true;
StringVar* strVar = g_StringMap.Get(strID);
if (strVar)
{
if (numChars == -1)
numChars = strVar->GetLength() - startPos;
switch (mode)
{
case eMode_svFind:
intResult = strVar->Find(toFind, startPos, numChars, bCaseSensitive ? true : false);
break;
case eMode_svCount:
intResult = strVar->Count(toFind, startPos, numChars, bCaseSensitive ? true : false);
break;
case eMode_svReplace:
{
std::string str(toFind);
UInt32 splitPoint = str.find(GetSeparatorChar(scriptObj));
if (splitPoint != -1 && splitPoint < str.length())
{
toFind[splitPoint] = '\0';
char* replaceWith = (splitPoint == str.length() - 1) ? "" : toFind + splitPoint + 1;
intResult = strVar->Replace(toFind, replaceWith, startPos, numChars, bCaseSensitive ? true : false, numToReplace);
}
break;
}
}
}
if (intResult != -1)
*result = intResult;
return true;
}