本文整理汇总了C++中common::UString::clear方法的典型用法代码示例。如果您正苦于以下问题:C++ UString::clear方法的具体用法?C++ UString::clear怎么用?C++ UString::clear使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类common::UString
的用法示例。
在下文中一共展示了UString::clear方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setOption
static bool setOption(Common::UString &key, const Common::UString &value) {
if (key.equalsIgnoreCase("config")) {
ConfigMan.setConfigFile(value);
if (!ConfigMan.load()) {
if (!ConfigMan.fileExists())
warning("No such config file \"%s\"", value.c_str());
return false;
}
key.clear();
return true;
}
ConfigMan.setCommandlineKey(key, value);
key.clear();
return true;
}
示例2: constructPartName
void Creature::constructPartName(const Common::UString &type, uint32 id,
const Common::UString &gender, const Common::UString &race,
const Common::UString &phenoType, const Common::UString &phenoTypeAlt,
Aurora::FileType fileType, Common::UString &part) {
constructPartName(type, id, gender, race, phenoType, part);
if ((fileType == Aurora::kFileTypeNone) || ResMan.hasResource(part, fileType))
return;
constructPartName(type, id, gender, race, phenoTypeAlt, part);
if (!ResMan.hasResource(part, fileType))
part.clear();
}
示例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;
}
示例4: Exception
bool GFF4Struct::getTalkString(uint32 field, Common::Encoding encoding,
uint32 &strRef, Common::UString &str) const {
const Field *f;
Common::SeekableReadStream *data = getField(field, f);
if (!data)
return false;
if (f->type != kIFieldTypeTlkString)
throw Common::Exception("GFF4: Field is not of TalkString type");
if (f->isList)
throw Common::Exception("GFF4: Tried reading list as singular value");
strRef = getUint(*data, kIFieldTypeUint32);
const uint32 offset = getUint(*data, kIFieldTypeUint32);
str.clear();
if ((offset != 0xFFFFFFFF) && (offset != 0))
str = getString(*data, encoding, _parent->getDataOffset() + offset);
return true;
}
示例5: main
int main(int argc, char **argv) {
initPlatform();
initConfig();
std::vector<Common::UString> args;
Common::Platform::getParameters(argc, argv, args);
Common::UString target;
int code;
if (!parseCommandline(args, target, code))
return code;
// Check the requested target
if (target.empty() || !ConfigMan.hasGame(target)) {
Common::UString path = ConfigMan.getString("path");
if (path.empty()) {
if (ConfigMan.getBool("listdebug", false)) {
listDebug();
return 0;
}
error("Neither an existing target, nor a path specified");
}
bool useExisting = false;
if (target.empty()) {
target = ConfigMan.findGame(path);
if (!target.empty()) {
warning("No target specified, but found a target with a matching path");
useExisting = true;
}
}
target = ConfigMan.createGame(path, target);
if (target.empty())
error("Failed creating a new config target for the game");
if (!useExisting)
warning("Creating a new target for this game");
}
if (!ConfigMan.setGame(target) || !ConfigMan.isInGame())
error("No target \"%s\" in the config file", target.c_str());
/* Open the log file.
*
* NOTE: A log is opened by default, unless the logfile config value
* is set to an empty string or nologfile is set to true.
*/
Common::UString logFile = DebugMan.getDefaultLogFile();
if (ConfigMan.hasKey("logfile"))
logFile = ConfigMan.getString("logfile");
if (ConfigMan.getBool("nologfile", false))
logFile.clear();
if (!logFile.empty())
if (!DebugMan.openLogFile(logFile))
warning("Failed to open log file \"%s\" for writing", logFile.c_str());
DebugMan.logCommandLine(args);
status("Target \"%s\"", target.c_str());
Common::UString dirArg = ConfigMan.getString("path");
if (dirArg.empty())
error("Target \"%s\" is missing a path", target.c_str());
Common::UString baseDir;
try {
baseDir = Common::FilePath::canonicalize(dirArg);
} catch (...) {
error("Invalid path \"%s\"", dirArg.c_str());
}
if (!Common::FilePath::isDirectory(baseDir) && !Common::FilePath::isRegularFile(baseDir))
error("No such file or directory \"%s\"", baseDir.c_str());
Engines::GameThread *gameThread = new Engines::GameThread;
try {
// Enable requested debug channels
initDebug();
// Initialize all necessary subsystems
init();
// Probe and create the game engine
gameThread->init(baseDir);
if (ConfigMan.getBool("listdebug", false)) {
// List debug channels
listDebug();
} else {
// Run the game
gameThread->run();
EventMan.runMainLoop();
}
} catch (...) {
EventMan.raiseFatalError();
//.........这里部分代码省略.........
示例6: parseCommandLine
bool parseCommandLine(const std::vector<Common::UString> &argv, int &returnValue,
Common::UString &inFile, Common::UString &outFile,
Common::Encoding &encoding, bool &nwnPremium) {
inFile.clear();
outFile.clear();
std::vector<Common::UString> args;
bool optionsEnd = false;
for (size_t i = 1; i < argv.size(); i++) {
bool isOption = false;
// A "--" marks an end to all options
if (argv[i] == "--") {
optionsEnd = true;
continue;
}
// We're still handling options
if (!optionsEnd) {
// Help text
if ((argv[i] == "-h") || (argv[i] == "--help")) {
printUsage(stdout, argv[0]);
returnValue = 0;
return false;
}
if (argv[i] == "--version") {
printVersion();
returnValue = 0;
return false;
}
if (argv[i] == "--cp1252") {
// Set the GFF4 string encoding to CP1252
isOption = true;
encoding = Common::kEncodingCP1252;
} else if (argv[i] == "--nwnpremium") {
isOption = true;
nwnPremium = true;
} else if (argv[i].beginsWith("-") || argv[i].beginsWith("--")) {
// An options, but we already checked for all known ones
printUsage(stderr, argv[0]);
returnValue = 1;
return false;
}
}
// Was this a valid option? If so, don't try to use it as a file
if (isOption)
continue;
// This is a file to use
args.push_back(argv[i]);
}
if ((args.size() < 1) || (args.size() > 2)) {
printUsage(stderr, argv[0]);
returnValue = 1;
return false;
}
inFile = args[0];
if (args.size() > 1)
outFile = args[1];
return true;
}
示例7: parseCommandLine
bool parseCommandLine(const std::vector<Common::UString> &argv, int &returnValue,
Command &command, Common::UString &file, Aurora::GameID &game) {
file.clear();
std::vector<Common::UString> args;
bool optionsEnd = false;
for (size_t i = 1; i < argv.size(); i++) {
bool isOption = false;
// A "--" marks an end to all options
if (argv[i] == "--") {
optionsEnd = true;
continue;
}
// We're still handling options
if (!optionsEnd) {
// Help text
if ((argv[i] == "-h") || (argv[i] == "--help")) {
printUsage(stdout, argv[0]);
returnValue = 0;
return false;
}
if (argv[i] == "--version") {
printVersion();
returnValue = 0;
return false;
}
if (argv[i] == "--nwn2") {
isOption = true;
game = Aurora::kGameIDNWN2;
} else if (argv[i] == "--jade") {
isOption = true;
game = Aurora::kGameIDJade;
} else if (argv[i].beginsWith("-") || argv[i].beginsWith("--")) {
// An options, but we already checked for all known ones
printUsage(stderr, argv[0]);
returnValue = 1;
return false;
}
}
// Was this a valid option? If so, don't try to use it as a file
if (isOption)
continue;
args.push_back(argv[i]);
}
if (args.size() != 2) {
printUsage(stderr, argv[0]);
returnValue = 1;
return false;
}
// Find out what we should do
command = kCommandNone;
for (int i = 0; i < kCommandMAX; i++)
if (!strcmp(args[0].c_str(), kCommandChar[i]))
command = (Command) i;
// Unknown command
if (command == kCommandNone) {
printUsage(stderr, argv[0]);
returnValue = 1;
return false;
}
file = args[1];
return true;
}
示例8: parseCommandLine
bool parseCommandLine(const std::vector<Common::UString> &argv, int &returnValue,
std::vector<Common::UString> &files, Common::UString &outFile, Format &format) {
files.clear();
outFile.clear();
bool optionsEnd = false;
for (size_t i = 1; i < argv.size(); i++) {
bool isOption = false;
// A "--" marks an end to all options
if (argv[i] == "--") {
optionsEnd = true;
continue;
}
// We're still handling options
if (!optionsEnd) {
// Help text
if ((argv[i] == "-h") || (argv[i] == "--help")) {
printUsage(stdout, argv[0]);
returnValue = 0;
return false;
}
if (argv[i] == "--version") {
printVersion();
returnValue = 0;
return false;
}
if ((argv[i] == "--2da") || (argv[i] == "-2")) {
isOption = true;
format = kFormat2DA;
} else if ((argv[i] == "--csv") || (argv[i] == "-c")) {
isOption = true;
format = kFormatCSV;
} else if ((argv[i] == "-o") || (argv[i] == "--output")) {
isOption = true;
// Needs a file name as the next parameter
if (i++ == (argv.size() - 1)) {
printUsage(stdout, argv[0]);
returnValue = 0;
return false;
}
outFile = argv[i];
} else if (argv[i].beginsWith("-") || argv[i].beginsWith("--")) {
// An options, but we already checked for all known ones
printUsage(stderr, argv[0]);
returnValue = -1;
return false;
}
}
// Was this a valid option? If so, don't try to use it as a file
if (isOption)
continue;
// This is a file to use
files.push_back(argv[i]);
}
// No files? Error.
if (files.empty()) {
printUsage(stderr, argv[0]);
returnValue = -1;
return false;
}
return true;
}
示例9: parseCommandLine
bool parseCommandLine(const std::vector<Common::UString> &argv, int &returnValue,
Command &command, Common::UString &archive, std::set<Common::UString> &files,
Aurora::GameID &game, std::vector<byte> &password) {
archive.clear();
files.clear();
std::vector<Common::UString> args;
bool optionsEnd = false;
for (size_t i = 1; i < argv.size(); i++) {
bool isOption = false;
// A "--" marks an end to all options
if (argv[i] == "--") {
optionsEnd = true;
continue;
}
// We're still handling options
if (!optionsEnd) {
// Help text
if ((argv[i] == "-h") || (argv[i] == "--help")) {
printUsage(stdout, argv[0]);
returnValue = 0;
return false;
}
if (argv[i] == "--version") {
printVersion();
returnValue = 0;
return false;
}
if (argv[i] == "--nwn2") {
isOption = true;
game = Aurora::kGameIDNWN2;
} else if (argv[i] == "--jade") {
isOption = true;
game = Aurora::kGameIDJade;
} else if (argv[i] == "--pass") {
isOption = true;
// Needs the password as the next parameter
if (i++ == (argv.size() - 1)) {
printUsage(stdout, argv[0]);
returnValue = 1;
return false;
}
parsePassword(argv[i], password);
} else if (argv[i] == "--nwm") {
isOption = true;
// Needs the file as the next parameter
if (i++ == (argv.size() - 1)) {
printUsage(stdout, argv[0]);
returnValue = 1;
return false;
}
readNWMMD5(argv[i], password);
} else if (argv[i].beginsWith("-") || argv[i].beginsWith("--")) {
// An options, but we already checked for all known ones
printUsage(stderr, argv[0]);
returnValue = 1;
return false;
}
}
// Was this a valid option? If so, don't try to use it as a file
if (isOption)
continue;
args.push_back(argv[i]);
}
if (args.size() < 2) {
printUsage(stderr, argv[0]);
returnValue = 1;
return false;
}
std::vector<Common::UString>::iterator arg = args.begin();
// Find out what we should do
command = kCommandNone;
for (int i = 0; i < kCommandMAX; i++)
if (!strcmp(arg->c_str(), kCommandChar[i]))
command = (Command) i;
//.........这里部分代码省略.........
示例10: parseCommandline
bool parseCommandline(const std::vector<Common::UString> &argv, Common::UString &target, int &code) {
target.clear();
Common::UString key;
bool stopMark = false;
for (size_t i = 1; i < argv.size(); i++) {
if (!key.empty()) {
// Still got one parameter missing from last time
if (!setOption(key, argv[i])) {
code = 1;
return false;
}
continue;
}
if (!stopMark && argv[i].beginsWith("-")) {
if (argv[i] == "--") {
stopMark = true;
continue;
}
if (argv[i] == "--help") {
code = 0;
displayUsage(argv[0]);
return false;
}
if (argv[i] == "--version") {
code = 0;
displayVersion();
return false;
}
if (!parseOption(argv[i], key)) {
code = 1;
return false;
}
if (key == "listdebug") {
setOption(key, "true");
key.clear();
}
if (key == "listlangs") {
setOption(key, "true");
key.clear();
}
continue;
}
if (!target.empty()) {
warning("Found multiple target (\"%s\" and \"%s\")", target.c_str(), argv[i].c_str());
code = 1;
return false;
}
target = argv[i];
}
if (target.empty() && !ConfigMan.hasKey("path") && !ConfigMan.getBool("listdebug", false)) {
displayUsage(argv[0]);
code = 1;
return false;
}
return true;
}
示例11: parseColors
void Text::parseColors(const Common::UString &str, Common::UString &parsed,
ColorPositions &colors) {
parsed.clear();
colors.clear();
ColorPosition color;
// Split by text tokens. They will have a strictly interleaving plain/token order
std::vector<Common::UString> tokens;
Common::UString::splitTextTokens(str, tokens);
bool plain = false;
for (std::vector<Common::UString>::iterator t = tokens.begin(); t != tokens.end(); ++t) {
plain = !plain;
if (plain) {
// Plain text, add it verbatim
parsed += *t;
continue;
}
if ((t->size() == 11) && t->beginsWith("<c") && t->endsWith(">")) {
// Color start token
uint8 colorValue[4];
Common::UString::iterator it = t->begin();
// Skip "<c"
++it;
++it;
for (int i = 0; i < 8; i++, ++it) {
uint32 c = *it;
// Convert the hex values into true nibble values
if ((c >= '0') && (c <= '9'))
c = c - '0';
else if ((c >= 'A') && (c <= 'F'))
c = (c - 'A') + 10;
else if ((c >= 'f') && (c <= 'f'))
c = (c - 'a') + 10;
else
c = 15;
// Merge two nibbles into one color value byte
uint8 &value = colorValue[i / 2];
bool high = (i % 2) == 0;
if (high)
value = c << 4;
else
value |= c;
}
// Add the color change
color.position = parsed.size();
color.defaultColor = false;
color.r = colorValue[0] / 255.0f;
color.g = colorValue[1] / 255.0f;
color.b = colorValue[2] / 255.0f;
color.a = colorValue[3] / 255.0f;
colors.push_back(color);
} else if (*t == "</c>") {
// Color end token, add a "uncolor" / default color change
color.position = parsed.size();
color.defaultColor = true;
colors.push_back(color);
} else
// Ignore non-color tokens
parsed += *t;
}
}
示例12: parseCommandLine
bool parseCommandLine(const std::vector<Common::UString> &argv, int &returnValue,
Common::UString &inFile, Common::UString &outFile,
Aurora::GameID &game, Command &command,
bool &printStack, bool &printControlTypes) {
inFile.clear();
outFile.clear();
std::vector<Common::UString> args;
command = kCommandListing;
bool optionsEnd = false;
for (size_t i = 1; i < argv.size(); i++) {
bool isOption = false;
// A "--" marks an end to all options
if (argv[i] == "--") {
optionsEnd = true;
continue;
}
// We're still handling options
if (!optionsEnd) {
// Help text
if ((argv[i] == "-h") || (argv[i] == "--help")) {
printUsage(stdout, argv[0]);
returnValue = 0;
return false;
}
if (argv[i] == "--version") {
printVersion();
returnValue = 0;
return false;
}
if (argv[i] == "--list") {
isOption = true;
command = kCommandListing;
} else if (argv[i] == "--assembly") {
isOption = true;
command = kCommandAssembly;
} else if (argv[i] == "--dot") {
isOption = true;
command = kCommandDot;
} else if (argv[i] == "--stack") {
isOption = true;
printStack = true;
} else if (argv[i] == "--control") {
isOption = true;
printControlTypes = true;
} else if (argv[i] == "--nwn") {
isOption = true;
game = Aurora::kGameIDNWN;
} else if (argv[i] == "--nwn2") {
isOption = true;
game = Aurora::kGameIDNWN2;
} else if (argv[i] == "--kotor") {
isOption = true;
game = Aurora::kGameIDKotOR;
} else if (argv[i] == "--kotor2") {
isOption = true;
game = Aurora::kGameIDKotOR2;
} else if (argv[i] == "--jade") {
isOption = true;
game = Aurora::kGameIDJade;
} else if (argv[i] == "--witcher") {
isOption = true;
game = Aurora::kGameIDWitcher;
} else if (argv[i] == "--dragonage") {
isOption = true;
game = Aurora::kGameIDDragonAge;
} else if (argv[i] == "--dragonage2") {
isOption = true;
game = Aurora::kGameIDDragonAge2;
} else if (argv[i].beginsWith("-") || argv[i].beginsWith("--")) {
// An options, but we already checked for all known ones
printUsage(stderr, argv[0]);
returnValue = 1;
return false;
}
}
// Was this a valid option? If so, don't try to use it as a file
if (isOption)
continue;
// This is a file to use
args.push_back(argv[i]);
}
assert(command != kCommandNone);
if ((args.size() < 1) || (args.size() > 2)) {
printUsage(stderr, argv[0]);
returnValue = 1;
//.........这里部分代码省略.........
示例13: parseCommandLine
bool parseCommandLine(const std::vector<Common::UString> &argv, int &returnValue,
Common::UString &inFile, Common::UString &outFile,
Common::Encoding &encoding, Aurora::GameID &game,
XML::TLKCreator::Version &version, uint32 &language) {
inFile.clear();
outFile.clear();
std::vector<Common::UString> args;
version = XML::TLKCreator::kVersionInvalid;
language = Aurora::kLanguageInvalid;
bool optionsEnd = false;
for (size_t i = 1; i < argv.size(); i++) {
bool isOption = false;
// A "--" marks an end to all options
if (argv[i] == "--") {
optionsEnd = true;
continue;
}
// We're still handling options
if (!optionsEnd) {
// Help text
if ((argv[i] == "-h") || (argv[i] == "--help")) {
printUsage(stdout, argv[0]);
returnValue = 0;
return false;
}
if (argv[i] == "--version") {
printVersion();
returnValue = 0;
return false;
}
if (argv[i] == "--cp1250") {
isOption = true;
encoding = Common::kEncodingCP1250;
game = Aurora::kGameIDUnknown;
} else if (argv[i] == "--cp1251") {
isOption = true;
encoding = Common::kEncodingCP1251;
game = Aurora::kGameIDUnknown;
} else if (argv[i] == "--cp1252") {
isOption = true;
encoding = Common::kEncodingCP1252;
game = Aurora::kGameIDUnknown;
} else if (argv[i] == "--cp932") {
isOption = true;
encoding = Common::kEncodingCP932;
game = Aurora::kGameIDUnknown;
} else if (argv[i] == "--cp936") {
isOption = true;
encoding = Common::kEncodingCP949;
game = Aurora::kGameIDUnknown;
} else if (argv[i] == "--cp949") {
isOption = true;
encoding = Common::kEncodingCP949;
game = Aurora::kGameIDUnknown;
} else if (argv[i] == "--cp950") {
isOption = true;
encoding = Common::kEncodingCP950;
game = Aurora::kGameIDUnknown;
} else if (argv[i] == "--utf8") {
isOption = true;
encoding = Common::kEncodingUTF8;
game = Aurora::kGameIDUnknown;
} else if (argv[i] == "--utf16le") {
isOption = true;
encoding = Common::kEncodingUTF16LE;
game = Aurora::kGameIDUnknown;
} else if (argv[i] == "--utf16be") {
isOption = true;
encoding = Common::kEncodingUTF16BE;
game = Aurora::kGameIDUnknown;
} else if (argv[i] == "--nwn") {
isOption = true;
encoding = Common::kEncodingInvalid;
game = Aurora::kGameIDNWN;
} else if (argv[i] == "--nwn2") {
isOption = true;
encoding = Common::kEncodingInvalid;
game = Aurora::kGameIDNWN2;
} else if (argv[i] == "--kotor") {
isOption = true;
encoding = Common::kEncodingInvalid;
game = Aurora::kGameIDKotOR;
} else if (argv[i] == "--kotor2") {
isOption = true;
encoding = Common::kEncodingInvalid;
game = Aurora::kGameIDKotOR2;
} else if (argv[i] == "--jade") {
isOption = true;
encoding = Common::kEncodingInvalid;
game = Aurora::kGameIDJade;
} else if (argv[i] == "--witcher") {
//.........这里部分代码省略.........
示例14: parseCommandLine
bool parseCommandLine(const std::vector<Common::UString> &argv, int &returnValue,
Command &command, Common::UString &file) {
file.clear();
std::vector<Common::UString> args;
bool optionsEnd = false;
for (size_t i = 1; i < argv.size(); i++) {
// A "--" marks an end to all options
if (argv[i] == "--") {
optionsEnd = true;
continue;
}
// We're still handling options
if (!optionsEnd) {
// Help text
if ((argv[i] == "-h") || (argv[i] == "--help")) {
printUsage(stdout, argv[0]);
returnValue = 0;
return false;
}
if (argv[i] == "--version") {
printVersion();
returnValue = 0;
return false;
}
if (argv[i].beginsWith("-") || argv[i].beginsWith("--")) {
// An options, but we already checked for all known ones
printUsage(stderr, argv[0]);
returnValue = -1;
return false;
}
}
args.push_back(argv[i]);
}
if (args.size() != 2) {
printUsage(stderr, argv[0]);
returnValue = -1;
return false;
}
// Find out what we should do
command = kCommandNone;
for (int i = 0; i < kCommandMAX; i++)
if (!strcmp(args[0].c_str(), kCommandChar[i]))
command = (Command) i;
// Unknown command
if (command == kCommandNone) {
printUsage(stderr, argv[0]);
returnValue = -1;
return false;
}
file = args[1];
return true;
}