本文整理汇总了C++中common::UString::findFirst方法的典型用法代码示例。如果您正苦于以下问题:C++ UString::findFirst方法的具体用法?C++ UString::findFirst怎么用?C++ UString::findFirst使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类common::UString
的用法示例。
在下文中一共展示了UString::findFirst方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: execute
void Console::execute(const Common::UString &line) {
if (line.empty())
return;
// Add the line to console
_console->print(Common::UString(kPrompt) + " " + line);
// Split command from redirect target
Common::UString command;
Common::UString redirect;
line.split(line.findFirst('>'), command, redirect, true);
command.trim();
redirect.trim();
// Split command from arguments
CommandLine cl;
command.split(command.findFirst(' '), cl.cmd, cl.args, true);
cl.cmd.trim();
cl.args.trim();
// Find the command
CommandMap::iterator cmd = _commands.find(cl.cmd);
if (cmd == _commands.end()) {
printf("Unknown command \"%s\". Type 'help' for a list of available commands.",
cl.cmd.c_str());
return;
}
// Set redirect
if (!_console->setRedirect(redirect))
return;
// Execute
_console->hidePrompt();
cmd->second.callback(cl);
_console->showPrompt();
// Reset redirect
_console->setRedirect();
}
示例2: updateCampaigns
void Console::updateCampaigns() {
_campaigns.clear();
_campaignModules.clear();
// Base game
for (int i = 0; i < 5; i++) {
Common::UString name = TalkMan.getString(kCampaignNames[i]);
name.truncate(name.findFirst('\n'));
name.trim();
_campaigns.push_back(name);
_campaignModules.insert(std::make_pair(name, i));
}
// XP1
if (ConfigMan.getBool("NWN_hasXP1")) {
for (int i = 5; i < 8; i++) {
Common::UString name = "XP1: " + TalkMan.getString(kCampaignNames[i]);
name.truncate(name.findFirst('\n'));
name.trim();
_campaigns.push_back(name);
_campaignModules.insert(std::make_pair(name, i));
}
}
// XP2
if (ConfigMan.getBool("NWN_hasXP2")) {
for (int i = 8; i < 11; i++) {
Common::UString name = "XP2: " + TalkMan.getString(kCampaignNames[i]);
name.truncate(name.findFirst('\n'));
name.trim();
_campaigns.push_back(name);
_campaignModules.insert(std::make_pair(name, i));
}
}
setArguments("loadcampaign", _campaigns);
}
示例3: parseOption
static bool parseOption(const Common::UString &arg, Common::UString &key) {
if (arg.size() < 2) {
warning("Unrecognized command line argument \"%s\"", arg.c_str());
return false;
}
Common::UString::iterator start = arg.begin();
++start;
Common::UString value;
if (*start == '-') {
// Long option
++start;
Common::UString::iterator e = arg.findFirst('=');
if (e != arg.end()) {
key = arg.substr(start, e++);
value = arg.substr(e, arg.end());
} else
key = arg.substr(start, arg.end());
} else {
// Short option
key = convertShortToLongOption(*start++);
value = arg.substr(start, arg.end());
}
if (key.empty()) {
warning("Unrecognized command line argument \"%s\"", arg.c_str());
return false;
}
if (value.empty())
return true;
if (!setOption(key, value))
return false;
return true;
}