本文整理汇总了C++中common::UString::trim方法的典型用法代码示例。如果您正苦于以下问题:C++ UString::trim方法的具体用法?C++ UString::trim怎么用?C++ UString::trim使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类common::UString
的用法示例。
在下文中一共展示了UString::trim方法的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: getPCListInfo
void Creature::getPCListInfo(const Common::UString &bic, bool local,
Common::UString &name, Common::UString &classes,
Common::UString &portrait) {
Aurora::GFF3File *gff = openPC(bic, local);
try {
const Aurora::GFF3Struct &top = gff->getTopLevel();
// Reading name
const Common::UString firstName = top.getString("FirstName");
const Common::UString lastName = top.getString("LastName");
name = firstName + " " + lastName;
name.trim();
// Reading portrait (failure non-fatal)
try {
loadPortrait(top, portrait);
} catch (...) {
portrait.clear();
Common::exceptionDispatcherWarning("Can't read portrait for PC \"%s\"", bic.c_str());
}
// Reading classes
std::vector<Class> classLevels;
uint8 hitDice;
loadClasses(top, classLevels, hitDice);
getClassString(classLevels, classes);
classes = "(" + classes + ")";
} catch (...) {
delete gff;
throw;
}
delete gff;
}