本文整理汇总了C++中common::String::empty方法的典型用法代码示例。如果您正苦于以下问题:C++ String::empty方法的具体用法?C++ String::empty怎么用?C++ String::empty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类common::String
的用法示例。
在下文中一共展示了String::empty方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: checkDatafiles
bool MohawkEngine_Riven::checkDatafiles() {
Common::String missingFiles;
const char **datafiles = listExpectedDatafiles();
for (int i = 0; datafiles[i] != nullptr; i++) {
if (!SearchMan.hasFile(datafiles[i])) {
if (strcmp(datafiles[i], "j_Data3.mhk") == 0
|| strcmp(datafiles[i], "b_Data1.mhk") == 0) {
// j_Data3.mhk and b_Data1.mhk come from the 1.02 patch. They are not required to play.
continue;
}
if (!missingFiles.empty()) {
missingFiles += ", ";
}
missingFiles += datafiles[i];
}
}
if (missingFiles.empty()) {
return true;
}
Common::String message = _("You are missing the following required Riven data files:\n") + missingFiles;
warning("%s", message.c_str());
GUIErrorMessage(message);
return false;
}
示例2: getIconPath
void Win32TaskbarManager::setOverlayIcon(const Common::String &name, const Common::String &description) {
//warning("[Win32TaskbarManager::setOverlayIcon] Setting overlay icon to: %s (%s)", name.c_str(), description.c_str());
if (_taskbar == NULL)
return;
if (name.empty()) {
_taskbar->SetOverlayIcon(getHwnd(), NULL, L"");
return;
}
// Compute full icon path
Common::String path = getIconPath(name);
if (path.empty())
return;
HICON pIcon = (HICON)::LoadImage(NULL, path.c_str(), IMAGE_ICON, 16, 16, LR_LOADFROMFILE);
if (!pIcon) {
warning("[Win32TaskbarManager::setOverlayIcon] Cannot load icon!");
return;
}
// Sets the overlay icon
LPWSTR desc = ansiToUnicode(description.c_str());
_taskbar->SetOverlayIcon(getHwnd(), pIcon, desc);
DestroyIcon(pIcon);
delete[] desc;
}
示例3: node
Common::String Win32TaskbarManager::getIconPath(Common::String target) {
// We first try to look for a iconspath configuration variable then
// fallback to the extra path
//
// Icons can be either in a subfolder named "icons" or directly in the path
Common::String iconsPath = ConfMan.get("iconspath");
Common::String extraPath = ConfMan.get("extrapath");
#define TRY_ICON_PATH(path) { \
Common::FSNode node((path)); \
if (node.exists()) \
return (path); \
}
if (!iconsPath.empty()) {
TRY_ICON_PATH(iconsPath + "/" + target + ".ico");
TRY_ICON_PATH(iconsPath + "/" + ConfMan.get("gameid") + ".ico");
TRY_ICON_PATH(iconsPath + "/icons/" + target + ".ico");
TRY_ICON_PATH(iconsPath + "/icons/" + ConfMan.get("gameid") + ".ico");
}
if (!extraPath.empty()) {
TRY_ICON_PATH(extraPath + "/" + target + ".ico");
TRY_ICON_PATH(extraPath + "/" + ConfMan.get("gameid") + ".ico");
TRY_ICON_PATH(extraPath + "/icons/" + target + ".ico");
TRY_ICON_PATH(extraPath + "/icons/" + ConfMan.get("gameid") + ".ico");
}
return "";
}
示例4: getDefaultConfigFileName
Common::String OSystem_POSIX::getDefaultConfigFileName() {
Common::String configFile;
Common::String prefix;
#ifdef MACOSX
prefix = getenv("HOME");
#elif !defined(SAMSUNGTV)
const char *envVar;
// Our old configuration file path for POSIX systems was ~/.scummvmrc.
// If that file exists, we still use it.
envVar = getenv("HOME");
if (envVar && *envVar) {
configFile = envVar;
configFile += '/';
configFile += ".scummvmrc";
if (configFile.size() < MAXPATHLEN) {
struct stat sb;
if (stat(configFile.c_str(), &sb) == 0) {
return configFile;
}
}
}
// On POSIX systems we follow the XDG Base Directory Specification for
// where to store files. The version we based our code upon can be found
// over here: http://standards.freedesktop.org/basedir-spec/basedir-spec-0.8.html
envVar = getenv("XDG_CONFIG_HOME");
if (!envVar || !*envVar) {
envVar = getenv("HOME");
if (!envVar) {
return 0;
}
if (Posix::assureDirectoryExists(".config", envVar)) {
prefix = envVar;
prefix += "/.config";
}
} else {
prefix = envVar;
}
if (!prefix.empty() && Posix::assureDirectoryExists("scummvm", prefix.c_str())) {
prefix += "/scummvm";
}
#endif
if (!prefix.empty() && (prefix.size() + 1 + _baseConfigName.size()) < MAXPATHLEN) {
configFile = prefix;
configFile += '/';
configFile += _baseConfigName;
} else {
configFile = _baseConfigName;
}
return configFile;
}
示例5: CreateFileA
bool Win32AudioCDManager::openCD(const Common::String &drive) {
// Just some bounds checking
if (drive.empty() || drive.size() > 3)
return false;
if (!Common::isAlpha(drive[0]) || drive[1] != ':')
return false;
if (drive[2] != 0 && drive[2] != '\\')
return false;
DriveList drives;
if (!tryAddDrive(toupper(drive[0]), drives))
return false;
// Construct the drive path and try to open it
Common::String drivePath = Common::String::format("\\\\.\\%c:", drives[0]);
_driveHandle = CreateFileA(drivePath.c_str(), GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
if (_driveHandle == INVALID_HANDLE_VALUE) {
warning("Failed to open drive %c:\\, error %d", drives[0], (int)GetLastError());
return false;
}
if (!loadTOC()) {
close();
return false;
}
return true;
}
示例6: addLine
void AboutDialog::addLine(const char *str) {
if (*str == 0) {
_lines.push_back("");
} else {
Common::String format(str, 2);
str += 2;
static Common::String asciiStr;
if (format[0] == 'A') {
bool useAscii = false;
#ifdef USE_TRANSLATION
// We could use TransMan.getCurrentCharset() but rather than compare strings
// it is easier to use TransMan.getCharsetMapping() (non null in case of non
// ISO-8859-1 mapping)
useAscii = (TransMan.getCharsetMapping() != NULL);
#endif
if (useAscii)
asciiStr = str;
return;
}
StringArray wrappedLines;
if (!asciiStr.empty()) {
g_gui.getFont().wordWrapText(asciiStr, _w - 2 * _xOff, wrappedLines);
asciiStr.clear();
} else
g_gui.getFont().wordWrapText(str, _w - 2 * _xOff, wrappedLines);
for (StringArray::const_iterator i = wrappedLines.begin(); i != wrappedLines.end(); ++i) {
_lines.push_back(format + *i);
}
}
}
示例7: parseScrFile
void ScriptManager::parseScrFile(const Common::String &fileName, bool isGlobal) {
Common::File file;
if (!file.open(fileName)) {
warning("Script file not found: %s", fileName.c_str());
return;
}
while(!file.eos()) {
Common::String line = file.readLine();
if (file.err()) {
warning("Error parsing scr file: %s", fileName.c_str());
return;
}
trimCommentsAndWhiteSpace(&line);
if (line.empty())
continue;
if (line.matchString("puzzle:*", true)) {
Puzzle *puzzle = new Puzzle();
sscanf(line.c_str(),"puzzle:%u",&(puzzle->key));
parsePuzzle(puzzle, file);
if (isGlobal) {
_globalPuzzles.push_back(puzzle);
} else {
_activePuzzles.push_back(puzzle);
}
} else if (line.matchString("control:*", true)) {
parseControl(line, file);
}
}
}
示例8: themeConfigParseHeader
bool ThemeEngine::themeConfigParseHeader(Common::String header, Common::String &themeName) {
// Check that header is not corrupted
if ((byte)header[0] > 127) {
warning("Corrupted theme header found");
return false;
}
header.trim();
if (header.empty())
return false;
if (header[0] != '[' || header.lastChar() != ']')
return false;
header.deleteChar(0);
header.deleteLastChar();
Common::StringTokenizer tok(header, ":");
if (tok.nextToken() != SCUMMVM_THEME_VERSION_STR)
return false;
themeName = tok.nextToken();
Common::String author = tok.nextToken();
return tok.empty();
}
示例9: getSize
int32 NotesHandler::getSize() {
Common::String fileName = _file->build();
if (fileName.empty())
return -1;
Common::InSaveFile *saveFile;
SaveConverter_Notes converter(_vm, _notesSize, fileName);
if (converter.isOldSave(&saveFile)) {
// Old save, get the size olden-style
int32 size = saveFile->size();
delete saveFile;
return size;
}
SaveReader reader(1, 0, fileName);
SaveHeader header;
if (!reader.load())
return -1;
if (!reader.readPartHeader(0, &header))
return -1;
// Return the part's size
return header.getSize();
}
示例10: resolutionCheck
bool ThemeParser::resolutionCheck(const Common::String &resolution) {
if (resolution.empty())
return true;
Common::StringTokenizer globTokenizer(resolution, ", ");
Common::String cur, w, h;
bool definedRes = false;
while (!globTokenizer.empty()) {
bool ignore = false;
cur = globTokenizer.nextToken();
if (cur[0] == '-') {
ignore = true;
cur.deleteChar(0);
} else {
definedRes = true;
}
Common::StringTokenizer resTokenizer(cur, "x");
w = resTokenizer.nextToken();
h = resTokenizer.nextToken();
if ((w == "X" || atoi(w.c_str()) == g_system->getOverlayWidth()) &&
(h == "Y" || atoi(h.c_str()) == g_system->getOverlayHeight()))
return !ignore;
}
return !definedRes;
}
示例11: saveRestoreGame
bool LabEngine::saveRestoreGame() {
bool isOK = false;
// The original had one screen for saving/loading. We have two.
// Ask the user which screen to use.
GUI::MessageDialog saveOrLoad(_("Would you like to save or restore a game?"), _("Save"), _("Restore"));
int choice = saveOrLoad.runModal();
if (choice == GUI::kMessageOK) {
// Save
GUI::SaveLoadChooser *dialog = new GUI::SaveLoadChooser(_("Save game:"), _("Save"), true);
int slot = dialog->runModalWithCurrentTarget();
if (slot >= 0) {
Common::String desc = dialog->getResultString();
if (desc.empty()) {
// create our own description for the saved game, the user didn't enter it
desc = dialog->createDefaultSaveDescription(slot);
}
isOK = saveGame(slot, desc);
}
delete dialog;
} else {
// Restore
GUI::SaveLoadChooser *dialog = new GUI::SaveLoadChooser(_("Restore game:"), _("Restore"), false);
int slot = dialog->runModalWithCurrentTarget();
if (slot >= 0) {
isOK = loadGame(slot);
}
delete dialog;
}
return isOK;
}
示例12: loadFile
void MemoryObject::loadFile(const Common::String &filename) {
debugC(5, kDebugLoading, "MemoryObject::loadFile(<%s>)", filename.c_str());
if (filename.empty())
return;
if (!_data) {
NGIArchive *arr = g_fp->_currArchive;
if (g_fp->_currArchive != _libHandle && _libHandle)
g_fp->_currArchive = _libHandle;
Common::SeekableReadStream *s = g_fp->_currArchive->createReadStreamForMember(filename);
if (s) {
assert(s->size() > 0);
_dataSize = s->size();
debugC(5, kDebugLoading, "Loading %s (%d bytes)", filename.c_str(), _dataSize);
_data = (byte *)calloc(_dataSize, 1);
s->read(_data, _dataSize);
delete s;
} else {
// We have no object to read. This is fine
}
g_fp->_currArchive = arr;
}
}
示例13: getFilePath
Common::String BuriedEngine::getFilePath(uint32 stringID) {
Common::String path = getString(stringID);
Common::String output;
if (path.empty())
return output;
uint i = 0;
// The non-demo paths have CD info followed by a backslash.
// We ignore this.
// In the demo, we remove the "BITDATA" prefix because the
// binaries are in the same directory.
if (isDemo())
i += 8;
else
i += 2;
for (; i < path.size(); i++) {
if (path[i] == '\\')
output += '/';
else
output += path[i];
}
return output;
}
示例14: int
FilesystemNode::FilesystemNode(const Common::String &p) {
if (p.empty() || p == ".")
_realNode = AbstractFilesystemNode::getCurrentDirectory();
else
_realNode = AbstractFilesystemNode::getNodeForPath(p);
_refCount = new int(1);
}
示例15: getExtraGuiOptions
const ExtraGuiOptions AdvancedMetaEngine::getExtraGuiOptions(const Common::String &target) const {
if (!_extraGuiOptions)
return ExtraGuiOptions();
ExtraGuiOptions options;
// If there isn't any target specified, return all available GUI options.
// Only used when an engine starts in order to set option defaults.
if (target.empty()) {
for (const ADExtraGuiOptionsMap *entry = _extraGuiOptions; entry->guioFlag; ++entry)
options.push_back(entry->option);
return options;
}
// Query the GUI options
const Common::String guiOptionsString = ConfMan.get("guioptions", target);
const Common::String guiOptions = parseGameGUIOptions(guiOptionsString);
// Add all the applying extra GUI options.
for (const ADExtraGuiOptionsMap *entry = _extraGuiOptions; entry->guioFlag; ++entry) {
if (guiOptions.contains(entry->guioFlag))
options.push_back(entry->option);
}
return options;
}