本文整理汇总了C++中DiString::Tokenize方法的典型用法代码示例。如果您正苦于以下问题:C++ DiString::Tokenize方法的具体用法?C++ DiString::Tokenize怎么用?C++ DiString::Tokenize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DiString
的用法示例。
在下文中一共展示了DiString::Tokenize方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ExecuteCommand
bool DiCommandManager::ExecuteCommand(const DiString& cmd)
{
if (cmd.size() < 1)
return false;
// this is a comment
if (cmd[0] == '#')
return true;
DiCmdArgs argus;
DiString& command = argus.GetCommand();
DiKeyList& splitList = argus.GetKeyList();
DiString cmds = cmd;
cmds.Tokenize(" ", splitList);
if (splitList.empty())
return true;
command = cmd;
DiString& kName = splitList.at(0);
kName.ToLower();
DiStringCmdInfoMap::iterator it = mCmdInfos.find(kName);
if (it == mCmdInfos.end())
{
DI_WARNING( "can't find command. [%s]", kName.c_str());
return false;
}
DiCmdInfo kCmdInfo = it->second;
bool iRlt = kCmdInfo.mFunc(&argus);
if (!iRlt)
{
DI_WARNING( "execute failed. [%s]", command.c_str());
return false;
}
return true;
}
示例2: AddCommand
bool DiCommandManager::AddCommand(const DiString& cmd, DiCmdFuntion function, const DiString& help)
{
DI_ASSERT(function);
if (!function)
return false;
DiVector<DiString> splitList = cmd.Tokenize(" ");
if (splitList.empty())
return false;
DiCmdInfo kCmdInfo;
kCmdInfo.mName = splitList[0];
kCmdInfo.mDesc = help;
kCmdInfo.mFunc = function;
kCmdInfo.mName.ToLower();
mCmdInfos[kCmdInfo.mName] = kCmdInfo;
return true;
}