当前位置: 首页>>代码示例>>C++>>正文


C++ String::deleteLastChar方法代码示例

本文整理汇总了C++中common::String::deleteLastChar方法的典型用法代码示例。如果您正苦于以下问题:C++ String::deleteLastChar方法的具体用法?C++ String::deleteLastChar怎么用?C++ String::deleteLastChar使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在common::String的用法示例。


在下文中一共展示了String::deleteLastChar方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: prepareSaveNameForDisplay

Common::String Menu::prepareSaveNameForDisplay(const Common::String &name) {
	Common::String display = name;
	display.toUppercase();
	if (display.hasSuffix(".M3S")) {
		display.deleteLastChar();
		display.deleteLastChar();
		display.deleteLastChar();
		display.deleteLastChar();
	}

	while (display.size() > 17)
		display.deleteLastChar();

	return display;
}
开发者ID:frnknstn,项目名称:residualvm,代码行数:15,代码来源:menu.cpp

示例2: start

void SavesSyncRequest::start() {
	//cleanup
	_ignoreCallback = true;
	if (_workingRequest)
		_workingRequest->finish();
	_currentDownloadingFile = StorageFile();
	_currentUploadingFile = "";
	_filesToDownload.clear();
	_filesToUpload.clear();
	_localFilesTimestamps.clear();
	_totalFilesToHandle = 0;
	_ignoreCallback = false;

	//load timestamps
	_localFilesTimestamps = DefaultSaveFileManager::loadTimestamps();

	//list saves directory
	Common::String dir = _storage->savesDirectoryPath();
	if (dir.lastChar() == '/')
		dir.deleteLastChar();
	_workingRequest = _storage->listDirectory(
		dir,
		new Common::Callback<SavesSyncRequest, Storage::ListDirectoryResponse>(this, &SavesSyncRequest::directoryListedCallback),
		new Common::Callback<SavesSyncRequest, Networking::ErrorResponse>(this, &SavesSyncRequest::directoryListedErrorCallback)
	);
	if (!_workingRequest) finishError(Networking::ErrorResponse(this));
}
开发者ID:86400,项目名称:scummvm,代码行数:27,代码来源:savessyncrequest.cpp

示例3: handleInput

void Menu::handleInput(const Common::KeyState &e) {
	uint16 node = _vm->_state->getLocationNode();
	uint16 room = _vm->_state->getLocationRoom();
	uint16 item = _vm->_state->getMenuSaveLoadSelectedItem();

	if (room != 901 || node != 300 || item != 7)
		return;

	Common::String display = prepareSaveNameForDisplay(_saveName);

	if (e.keycode == Common::KEYCODE_BACKSPACE
			|| e.keycode == Common::KEYCODE_DELETE) {
		display.deleteLastChar();
		_saveName = display;
		return;
	} else if (e.keycode == Common::KEYCODE_RETURN
			|| e.keycode == Common::KEYCODE_KP_ENTER) {
		saveMenuSave();
		return;
	}

	if (((e.ascii >= 'a' && e.ascii <= 'z')
			|| (e.ascii >= 'A' && e.ascii <= 'Z')
			|| (e.ascii >= '0' && e.ascii <= '9')
			|| e.ascii == ' ')
			&& (display.size() < 17)) {
		display += e.ascii;
		display.toUppercase();
		_saveName = display;
	}
}
开发者ID:frnknstn,项目名称:residualvm,代码行数:31,代码来源:menu.cpp

示例4: bringWordtoTop

void bringWordtoTop(char *str, int wordnum) {
	// This function reorders the words on the given pred.dic line
	// by moving the word at position 'wordnum' to the front (that is, right behind
	// right behind the numerical code word at the start of the line).
	Common::Array<Common::String> words;
	char buf[MAXLINELEN];

	if (!str)
		return;
	strncpy(buf, str, MAXLINELEN);
	buf[MAXLINELEN - 1] = 0;
	char *word = strtok(buf, " ");
	if (!word) {
		debug("Invalid dictionary line");
		return;
	}

	words.push_back(word);
	while ((word = strtok(NULL, " ")) != NULL)
		words.push_back(word);
	words.insert_at(1, words.remove_at(wordnum + 1));

	Common::String tmp;
	for (uint8 i = 0; i < words.size(); i++)
			tmp += words[i] + " ";
	tmp.deleteLastChar();
	memcpy(str, tmp.c_str(), strlen(str));
}
开发者ID:St0rmcrow,项目名称:scummvm,代码行数:28,代码来源:predictive.cpp

示例5: 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();
}
开发者ID:megaboy,项目名称:scummvm,代码行数:28,代码来源:ThemeEngine.cpp

示例6: parse

bool LabelCommandParser::parse(const Common::String &line, ScriptParseContext &parseCtx, Command *&command) {
	if (line.lastChar() != ':') {
		return false;
	}

	Common::String label = line;
	label.deleteLastChar();

	LabelCommand *labelCmd = new LabelCommand(label);
	if (!parseCtx._labels.contains(label)) {
		parseCtx._labels[label] = labelCmd;
	} else {
		warning("Label '%s' already exists", label.c_str());
	}

	if (parseCtx._pendingGotos.contains(label)) {
		GotoCommands &gotos = parseCtx._pendingGotos[label];
		for (GotoCommands::const_iterator it = gotos.begin(); it != gotos.end(); ++it) {
			(*it)->setLabelCommand(labelCmd);
		}
		gotos.clear();
	}

	command = labelCmd;
	return true;
}
开发者ID:BenCastricum,项目名称:scummvm,代码行数:26,代码来源:labelcommand.cpp

示例7: directoryListedErrorCallback

void SavesSyncRequest::directoryListedErrorCallback(Networking::ErrorResponse error) {
	_workingRequest = nullptr;
	if (_ignoreCallback)
		return;

	bool irrecoverable = error.interrupted || error.failed;
	if (error.failed) {
		Common::JSONValue *value = Common::JSON::parse(error.response.c_str());
		if (value) {
			if (value->isObject()) {
				Common::JSONObject object = value->asObject();

				//Dropbox-related error:
				if (object.contains("error_summary") && object.getVal("error_summary")->isString()) {
					Common::String summary = object.getVal("error_summary")->asString();
					if (summary.contains("not_found")) {
						irrecoverable = false;
					}
				}

				//OneDrive-related error:
				if (object.contains("error") && object.getVal("error")->isObject()) {
					Common::JSONObject errorNode = object.getVal("error")->asObject();
					if (Networking::CurlJsonRequest::jsonContainsString(errorNode, "code", "SavesSyncRequest")) {
						Common::String code = errorNode.getVal("code")->asString();
						if (code == "itemNotFound") {
							irrecoverable = false;
						}
					}
				}
			}
			delete value;
		}

		//Google Drive and Box-related ScummVM-based error
		if (error.response.contains("subdirectory not found")) {
			irrecoverable = false; //base "/ScummVM/" folder not found
		} else if (error.response.contains("no such file found in its parent directory")) {
			irrecoverable = false; //"Saves" folder within "/ScummVM/" not found
		}
	}

	if (irrecoverable) {
		finishError(error);
		return;
	}

	//we're lucky - user just lacks his "/cloud/" folder - let's create one
	Common::String dir = _storage->savesDirectoryPath();
	if (dir.lastChar() == '/')
		dir.deleteLastChar();
	debug(9, "SavesSyncRequest: creating %s", dir.c_str());
	_workingRequest = _storage->createDirectory(
		dir,
		new Common::Callback<SavesSyncRequest, Storage::BoolResponse>(this, &SavesSyncRequest::directoryCreatedCallback),
		new Common::Callback<SavesSyncRequest, Networking::ErrorResponse>(this, &SavesSyncRequest::directoryCreatedErrorCallback)
	);
	if (!_workingRequest)
		finishError(Networking::ErrorResponse(this));
}
开发者ID:86400,项目名称:scummvm,代码行数:60,代码来源:savessyncrequest.cpp

示例8: detectGames

bool GlulxeMetaEngine::detectGames(const Common::FSList &fslist, DetectedGames &gameList) {
	const char *const EXTENSIONS[3] = { ".ulx", ".blb", ".gblorb" };

	// Loop through the files of the folder
	for (Common::FSList::const_iterator file = fslist.begin(); file != fslist.end(); ++file) {
		// Check for a recognised filename
		if (file->isDirectory())
			continue;
		Common::String filename = file->getName();
		bool hasExt = false;
		for (int idx = 0; idx < 3 && !hasExt; ++idx)
			hasExt = filename.hasSuffixIgnoreCase(EXTENSIONS[idx]);
		if (!hasExt)
			continue;

		// Open up the file and calculate the md5
		Common::File gameFile;
		if (!gameFile.open(*file))
			continue;
		Common::String md5 = Common::computeStreamMD5AsString(gameFile, 5000);
		size_t filesize = gameFile.size();
		gameFile.close();

		// Check for known games
		const GlulxeGameDescription *p = GLULXE_GAMES;
		while (p->_gameId && (md5 != p->_md5 || filesize != p->_filesize))
			++p;

		DetectedGame gd;
		if (!p->_gameId) {
			if (filename.hasSuffixIgnoreCase(".blb"))
				continue;

			if (gDebugLevel > 0) {
				// Print an entry suitable for putting into the detection_tables.h, using the
				// name of the parent folder the game is in as the presumed game Id
				Common::String folderName = file->getParent().getName();
				if (folderName.hasSuffix("\\"))
					folderName.deleteLastChar();
				Common::String fname = filename;
				const char *dot = strchr(fname.c_str(), '.');
				if (dot)
					fname = Common::String(fname.c_str(), dot);

				debug("ENTRY0(\"%s\", \"%s\", %u),", fname.c_str(), md5.c_str(), (uint)filesize);
			}
			const PlainGameDescriptor &desc = GLULXE_GAME_LIST[0];
			gd = DetectedGame(desc.gameId, desc.description, Common::UNK_LANG, Common::kPlatformUnknown);
		} else {
			PlainGameDescriptor gameDesc = findGame(p->_gameId);
			gd = DetectedGame(p->_gameId, gameDesc.description, p->_language, Common::kPlatformUnknown, p->_extra);
			gd.setGUIOptions(GUIO4(GUIO_NOSPEECH, GUIO_NOSFX, GUIO_NOMUSIC, GUIO_NOSUBTITLES));
		}

		gd.addExtraEntry("filename", filename);
		gameList.push_back(gd);
	}

	return !gameList.empty();
}
开发者ID:Templier,项目名称:scummvm,代码行数:60,代码来源:detection.cpp

示例9: resStrLen

Common::String ScummEngine_v60he::convertFilePath(const byte *src) {
	debug(2, "convertFilePath in: '%s'", (const char *)src);

	int srcSize = resStrLen(src);
	int start = 0;

	if (srcSize > 2) {
		if (src[0] == ':') { // Game Data Path (Macintosh)
			// The default game data path is set to ':' by ScummVM
			start = 1;
		} else if (src[0] == '.' && src[1] == '\\') { // Game Data Path (Windows)
			// The default game data path is set to '.\\' by ScummVM
			start = 2;
		} else if (src[0] == '*' && src[1] == '\\') { // Save Game Path (Windows HE72 - HE100)
			// The default save game path is set to '*\\' by ScummVM
			start = 2;
		} else if (src[0] == '*' && src[1] == ':') { // Save Game Path (Macintosh HE72 - HE100)
			// The default save game path is set to '*:' by ScummVM
			start = 2;
		} else if (src[0] == 'c' && src[1] == ':') { // Save Game Path (HE60 - HE71)
			// The default save path is game path (DOS) or 'c:\\hegames\\' (Windows)
			for (start = srcSize; start != 0; start--)
				if (src[start - 1] == '\\')
					break;
		} else if (src[0] == 'u' && src[1] == 's') { // Save Game Path (Moonbase Commander)
			// The default save path is 'user\\'
			start = 5;
		}
	}

	Common::String dst;

	for (int i = start; i < srcSize; i++) {
		// Convert path separators
		if (src[i] == '\\' || src[i] == ':')
			dst += '/';
		else
			dst += src[i];
	}

	// Sanity check
	if (dst.lastChar() == '/')
		dst.deleteLastChar();

	debug(2, "convertFilePath out: '%s'", dst.c_str());

	return dst;
}
开发者ID:bradparks,项目名称:scummvm,代码行数:48,代码来源:script_v60he.cpp

示例10: listNextDirectory

void OneDriveListDirectoryRequest::listNextDirectory() {
	if (_directoriesQueue.empty()) {
		finishListing(_files);
		return;
	}

	_currentDirectory = _directoriesQueue.back();
	_directoriesQueue.pop_back();

	if (_currentDirectory != "" && _currentDirectory.lastChar() != '/' && _currentDirectory.lastChar() != '\\')
		_currentDirectory += '/';

	Common::String dir = _currentDirectory;
	dir.deleteLastChar();
	Common::String url = Common::String::format(ONEDRIVE_API_SPECIAL_APPROOT_CHILDREN, ConnMan.urlEncode(dir).c_str());
	makeRequest(url);
}
开发者ID:86400,项目名称:scummvm,代码行数:17,代码来源:onedrivelistdirectoryrequest.cpp

示例11: cmd_lua_do

bool Debugger::cmd_lua_do(int argc, const char **argv) {
	if (argc < 2) {
		DebugPrintf("Usage: lua_do <lua command>\n");
		return true;
	}

	Common::String cmd;
	for (int i = 1; i < argc; ++i) {
		cmd += argv[i];
		cmd += " ";
	}
	cmd.deleteLastChar();
	DebugPrintf("Executing command: <%s>\n", cmd.c_str());
	cmd = Common::String::format("__temp_fn__ = function()\n%s\nend\nstart_script(__temp_fn__)", cmd.c_str());
	g_grim->debugLua(cmd);
	return true;
}
开发者ID:YakBizzarro,项目名称:residual,代码行数:17,代码来源:debugger.cpp

示例12: listSaves

SaveStateList BuriedMetaEngine::listSaves(const char *target) const {
	// The original had no pattern, so the user must rename theirs
	// Note that we ignore the target because saves are compatible between
	// all versions
	Common::StringArray fileNames = Buried::BuriedEngine::listSaveFiles();

	SaveStateList saveList;
	for (uint32 i = 0; i < fileNames.size(); i++) {
		// Isolate the description from the file name
		Common::String desc = fileNames[i].c_str() + 7;
		for (int j = 0; j < 4; j++)
			desc.deleteLastChar();

		saveList.push_back(SaveStateDescriptor(i, desc));
	}

	return saveList;
}
开发者ID:project-cabal,项目名称:cabal,代码行数:18,代码来源:detection.cpp

示例13: goUp

void RemoteBrowserDialog::goUp() {
	if (_rememberedNodeContents.contains(_node.path()))
		_rememberedNodeContents.erase(_node.path());

	Common::String path = _node.path();
	if (path.size() && (path.lastChar() == '/' || path.lastChar() == '\\'))
		path.deleteLastChar();
	if (path.empty()) {
		_rememberedNodeContents.erase("");
	} else {
		for (int i = path.size() - 1; i >= 0; --i)
			if (i == 0 || path[i] == '/' || path[i] == '\\') {
				path.erase(i);
				break;
			}
	}

	listDirectory(Cloud::StorageFile(path, 0, 0, true));
}
开发者ID:BenCastricum,项目名称:scummvm,代码行数:19,代码来源:remotebrowser.cpp

示例14: getThemeId

Common::String ThemeEngine::getThemeId(const Common::String &filename) {
	// If no filename has been given we will initialize the builtin theme
	if (filename.empty())
		return "builtin";

	Common::FSNode node(filename);
	if (!node.exists())
		return "builtin";

	if (node.getName().matchString("*.zip", true)) {
		Common::String id = node.getName();

		for (int i = 0; i < 4; ++i)
			id.deleteLastChar();

		return id;
	} else {
		return node.getName();
	}
}
开发者ID:megaboy,项目名称:scummvm,代码行数:20,代码来源:ThemeEngine.cpp

示例15: composeFileHashMap

static void composeFileHashMap(const Common::FSList &fslist, FileMap &allFiles, int depth, const char * const *directoryGlobs) {
    if (depth <= 0)
        return;

    if (fslist.empty())
        return;

    // First we compose a hashmap of all files in fslist.
    // Includes nifty stuff like removing trailing dots and ignoring case.
    for (Common::FSList::const_iterator file = fslist.begin(); file != fslist.end(); ++file) {
        if (file->isDirectory()) {
            Common::FSList files;

            if (!directoryGlobs)
                continue;

            bool matched = false;
            for (const char * const *glob = directoryGlobs; *glob; glob++)
                if (file->getName().matchString(*glob, true)) {
                    matched = true;
                    break;
                }

            if (!matched)
                continue;

            if (!file->getChildren(files, Common::FSNode::kListAll))
                continue;

            composeFileHashMap(files, allFiles, depth - 1, directoryGlobs);
        }

        Common::String tstr = file->getName();

        // Strip any trailing dot
        if (tstr.lastChar() == '.')
            tstr.deleteLastChar();

        allFiles[tstr] = *file;	// Record the presence of this file
    }
}
开发者ID:St0rmcrow,项目名称:scummvm,代码行数:41,代码来源:advancedDetector.cpp


注:本文中的common::String::deleteLastChar方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。