• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ replaceString函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中replaceString函数的典型用法代码示例。如果您正苦于以下问题:C++ replaceString函数的具体用法?C++ replaceString怎么用?C++ replaceString使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: replaceString

std::string Mission::getDescription(Player* player) const
{
	int32_t value;
	player->getStorageValue(storageID, value);

	if (!mainDescription.empty()) {
		std::string desc = mainDescription;
		replaceString(desc, "|STATE|", std::to_string(value));
		replaceString(desc, "\\n", "\n");
		return desc;
	}

	if (ignoreEndValue) {
		for (int32_t current = endValue; current >= startValue; current--) {
			if (value >= current) {
				auto sit = descriptions.find(current);
				if (sit != descriptions.end()) {
					return sit->second;
				}
			}
		}
	} else {
		for (int32_t current = endValue; current >= startValue; current--) {
			if (value == current) {
				auto sit = descriptions.find(current);
				if (sit != descriptions.end()) {
					return sit->second;
				}
			}
		}
	}
	return "An error has occurred, please contact a gamemaster.";
}
开发者ID:HeavenIsLost,项目名称:forgottenserver,代码行数:33,代码来源:quests.cpp


示例2: textAlreadyAdded

static int textAlreadyAdded(char *text)
{
	int i;
	char *clean;

	if (strcmpignorecase("msgid \"\"", text) == 0)
	{
		return TRUE;
	}

	clean = replaceString(text, "msgid \"", "");
	clean[strlen(clean) - 1] = '\0';
	clean = replaceString(clean, "\\", "");
	clean = replaceString(clean, "\\", "");

	for (i=0;i<poIndex;i++)
	{
		if (strcmpignorecase(added[i], text) == 0)
		{
			return TRUE;
		}
	}

	if (checkExists(clean) == FALSE)
	{
		return TRUE;
	}

	STRNCPY(added[poIndex], text, MAX_LINE_LENGTH);

	poIndex++;

	return FALSE;
}
开发者ID:revcozmo,项目名称:edgar,代码行数:34,代码来源:po_creator.c


示例3: replaceString

	std::ofstream &exportSubScript(std::ofstream &stream, Script &script, const std::string &subName)
	{
		SubScript &subScript = script.subScripts[subName];

		if(subName == "execute"  && subScript.script.empty())
			return stream;

		// HACK: special sub is not actually a sub... -jpk
		if (subName != "special")
		{
			stream << "sub " << subName << std::endl;
		}

		if(subName == "main")
		{
			stream << "   call createpaths" << std::endl;

			for(unsigned int i = 0; i < script.initialization.size(); ++i)
				stream << "   " << replaceString(script.initialization[i], script.properties.strings, script.stringProperties.defaults) << std::endl;
		}

		for(unsigned int i = 0; i < subScript.script.size(); ++i)
			stream << "   " << replaceString(subScript.script[i], script.properties.strings, script.stringProperties.defaults) << std::endl;

		// HACK: special sub is not actually a sub... -jpk
		if (subName != "special")
		{
			stream << "endSub" << std::endl;
		}

		return stream;
	}
开发者ID:DeejStar,项目名称:Jack-Claw,代码行数:32,代码来源:exporter_scripts.cpp


示例4: replaceString

std::string Mission::getDescription(Player* player)
{
	std::string value;
	player->getStorage(storageId, value);
	if(state.size())
	{
		std::string ret = state;
		replaceString(ret, "|STATE|", value);
		return ret;
	}

	if(atoi(value.c_str()) >= endValue)
	{
		std::string ret = states.rbegin()->second;
		replaceString(ret, "|STATE|", value);
		return ret;
	}

	for(int32_t i = endValue; i >= startValue; --i)
	{
		player->getStorage(storageId, value);
		if(atoi(value.c_str()) != i)
			continue;
 
		std::string ret = states[i - startValue];
		replaceString(ret, "|STATE|", value);
		return ret;
 
	}
 
	return "Couldn't retrieve any mission description, please report to a gamemaster.";
}
开发者ID:Berze,项目名称:sour,代码行数:32,代码来源:quests.cpp


示例5: startARunLog

	/**@brief A function to start a runLog in the named directory
	 * @param dirName The name of the directory to start the runLog, runLog name
	 *will be runLog_[NAME_OF_PROGRAM]
	 *
	 */
	void startARunLog(const std::string &dirName) {
		rLog_.setFilenameAndOpen(
				files::make_path(dirName,"runLog_"
						+ replaceString(replaceString(commands_.getProgramName(), "./", ""),
								" ", "-")+ "_" + getCurrentDate() + ".txt").string(), timer_.start_);
		rLog_.startRunLog(commands_);
	}
开发者ID:umass-bib,项目名称:bibcpp,代码行数:12,代码来源:programSetUp.hpp


示例6: trimString

	string trimString(string const &text)
	{
		string ret = replaceString(text, " ", "");
		ret = replaceString(ret, "\t", "");
		ret = replaceString(ret, "\r", "");
		ret = replaceString(ret, "\n", "");
		return ret;
	}
开发者ID:duchien85,项目名称:cellengine,代码行数:8,代码来源:StringReader.cpp


示例7: getSharedLibSuffix

	SLAString getSharedLibSuffix()	{
		SLAString libSuffix(Poco::SharedLibrary::suffix());
#if defined(_DEBUG)
		libSuffix = replaceString(libSuffix, "d.", "_Debug.");
#else
		libSuffix = replaceString(libSuffix, ".", "_Release.");
#endif
		return libSuffix;
	}
开发者ID:Mobiletainment,项目名称:Multiplayer-Network-Conecpts,代码行数:9,代码来源:slPluginLauncher.cpp


示例8: handSanitizer

char * handSanitizer(char *fix) {//returns a string that is dynamically alcolated.
		fix = replaceString("--","+",fix);
		fix = replaceString(" ","",fix);
		fix = replaceString("-", "+-",fix);
		fix = replaceString("X", "x",fix);
		fix = replaceString("^+-", "^-",fix);
		fix = replaceString("++-", "+-", fix);
		fix = replaceString("*+-", "*-",fix);
		fix = replaceString("(+-", "(-",fix);
		fix = replaceString(")(",")*(",fix);
		
		if(strncmp(fix,"+-",2)==0){
			size_t len = strlen(fix);//original length
			memcpy(fix,&fix[1],len);//cpy to fix starting at fix[1], for orig len-1
			fix = (char *) realloc(fix,len);//realloc space to be smaller
		}
		if(strncmp(fix,"+",1)==0){//same as above
			size_t len = strlen(fix);
			memcpy(fix,&fix[1],len);
			fix = (char *) realloc(fix,len);
		}
	
		printf("Reformatted Equation: %s",fix);
		return fix;
		
}
开发者ID:rgw3d,项目名称:ExpressionParseTree-In-C,代码行数:26,代码来源:InputSanitation.c


示例9: getExporterFileName

std::string getExporterFileName( std::string const& fileName ) {
	std::string sourceName = "Exported from: ";
	sourceName += fileName;

	// these symbols can't be in the meta data
	replaceString( sourceName, "=", "_" );
	replaceString( sourceName, ";", "_" );
  replaceString( sourceName, "\\", "/" );
	
	return sourceName;
}
开发者ID:kidintwo3,项目名称:ExocortexCrate,代码行数:11,代码来源:CommonUtilities.cpp


示例10: getConfigTree

qpid::types::Variant::Map getConfigTree() {
    qpid::types::Variant::Map tree;
    if (augeas==NULL) augeas_init();
    if (augeas == NULL) {
        AGO_ERROR() << "cannot initialize augeas";
        return tree;
    }
    char **matches;
    std::stringstream path;
    path << "/files";
    path << getConfigPath(MODULE_CONFDIR).string();
    path << "/";
    std::string prefix = path.str();
    path << "/*";
    int num = aug_match(augeas, path.str().c_str(), &matches);
    for (int i=0; i < num; i++) {
        const char *val;
        aug_get(augeas, matches[i], &val);
        if (val != NULL) {
            std::vector<std::string> elements;
            std::string match = matches[i];
            AGO_TRACE() << "getConfigTree:augeas match result[" << i << "]:" << match << ": " << val;
            replaceString(match, prefix, "");
            replaceString(match, ".conf", "");
            elements = split(match, '/');
            if (elements.size() != 3) {
                AGO_ERROR() << "augeas match ignored: does not split by / in three parts: " << match;
                continue;
            }
            std::string file = elements[0];
            std::string section = elements[1];
            std::string option = elements[2];
            AGO_TRACE() << "File: " << file << " Section: " << section << " Option: " << option;

            qpid::types::Variant::Map fileMap;
            qpid::types::Variant::Map sectionMap;
            if (!(tree[file].isVoid())) {
                fileMap = tree[file].asMap();
            }
            if (!(fileMap[section].isVoid())) {
                sectionMap = fileMap[section].asMap();
            }
            sectionMap[option] = val;
            fileMap[section] = sectionMap;
            tree[file] = fileMap;
        }
        free((void *) matches[i]);
    }
    free(matches);
    return tree;

}
开发者ID:mce35,项目名称:agocontrol,代码行数:52,代码来源:agoconfig.cpp


示例11: str

//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
std::string
DatabaseConnection::escapeString(const std::string& _string)
{
    std::string str(_string);

    // Escape the project name
    std::string searchString("\'"); 
    std::string replaceString("\'\'");

    std::string::size_type pos = 0;
    while ((pos = str.find(searchString, pos)) != std::string::npos) 
    {
        str.replace(pos, searchString.size(), replaceString);
        pos += replaceString.size();
    }

    searchString = "\"\"";
    pos = 0;

    while ((pos = str.find(searchString, pos)) != std::string::npos) 
    {
        str.replace(pos, searchString.size(), replaceString);
        pos += replaceString.size();
    }

    return str;
}
开发者ID:SgtFlame,项目名称:indiezen,代码行数:28,代码来源:DatabaseConnection.cpp


示例12: replaceStringInFile

void
replaceStringInFile(const char *filename, const string &toFind, const string &replaceWith) {
	FILE *f = fopen(filename, "r");
	if (f == NULL) {
		int e = errno;
		string message = "Cannot open file '";
		message.append(filename);
		message.append("' for reading");
		throw FileSystemException(message, e, filename);
	}
	string content(readAll(fileno(f)));
	fclose(f);
	
	f = fopen(filename, "w");
	if (f == NULL) {
		int e = errno;
		string message = "Cannot open file '";
		message.append(filename);
		message.append("' for writing");
		throw FileSystemException(message, e, filename);
	}
	content = replaceString(content, toFind, replaceWith);
	fwrite(content.data(), 1, content.size(), f);
	fclose(f);
}
开发者ID:andersjo,项目名称:passenger,代码行数:25,代码来源:Support.cpp


示例13: replaceString

bool CHostTracker::isNavigatedToBadLink()
{
	bool isBadLink = true;
	rho::StringW navUrl = replaceString(m_szNavigatedUrl, L"%20", L" ");
	//replace back slash in badlink url to front slash
	rho::StringW badUrl = replaceString(m_szBadLinkUrl, L"\\", L"/");

	LOG(INFO)  + "CHostTracker::run navigated url"+  navUrl.c_str(); 
	LOG(INFO)  + "CHostTracker::run badlink url"+  badUrl.c_str();

	if(std::string::npos == navUrl.find(badUrl))
	{		
		isBadLink = false;
	}
	return isBadLink;
}
开发者ID:wkhq84,项目名称:rhodes,代码行数:16,代码来源:HostTracker.cpp


示例14: readStringFromFile

void convert::replaceStringInFile(const std::string& oldfilename, const std::string& newfilename, const std::string& oldstring, const std::string& newstring)
{
    std::string s = readStringFromFile(oldfilename);
    if (s.length() <= 0) { return; }
    replaceString(s, oldstring, newstring);
    writeStringToFile(s, newfilename);
}
开发者ID:hfr1988,项目名称:DEye,代码行数:7,代码来源:libconvert.cpp


示例15: nameFunction

void nameFunction(t_tree node)
{
	if (node == NULL)
		return;

	if (nameCurrentPrimitive != NULL)
	{
		if (strcmp(node->Node.Function.Name, "main") == 0)
		{
			replaceString(&node->Node.Function.Name, nameCurrentPrimitive->Node.Primitive.Name);
			node->Node.Function.Variables = nameCurrentPrimitive->Node.Primitive.Variables;
			nameCurrentPrimitive->Node.Primitive.Variables = NULL;
			namePrimitiveVariables(node->Node.Function.Variables);
		}
		else
			joinStrings(&node->Node.Function.Name, nameCurrentPrimitive->Node.Primitive.Name, node->Node.Function.Name);			
	}
	
	checkIdExists(node->Node.Function.Name, node->LineNr, node->Node.Function.Type, NAME_TABLE_FUNCTION);
	scope = FindId(node->Node.Function.Name, scope);
		
	nameVariable(node->Node.Function.Variables);

	nameStmnt(node->Node.Function.Stmnts);

	scope = scope->parent;
	namePrimitive(node->Node.Function.Next);
}
开发者ID:christofferholmstedt,项目名称:naiad-auv-software,代码行数:28,代码来源:name.c


示例16: cacheFileName

	std::string FileCacheExt::createCacheFileName(const std::string& originalFileName) const
	{
		std::string serverAddress = osgDB::getServerAddress(originalFileName);
		std::string cacheFileName(_fileCachePath);
		cacheFileName.append("/");
		if (serverAddress.empty())
		{
			cacheFileName.append(originalFileName);
			osg::notify(osg::NOTICE) << "FileCache::_fileCachePath ==" << _fileCachePath << std::endl;
		}
		else
		{
			int size = _serverAddress.size();
			std::string rFile = originalFileName.substr(size + 1, originalFileName.size() - size - 1);
			replaceString(rFile,"/", "%2F", -1);
			std::string eName = tryConvertStringFromEscapeToUTF8(rFile);
			std::string localFile = cacheFileName;
			localFile.append(eName);
			if (osgDB::fileExists(localFile))
				return localFile;
			std::string gbkString("");
			tryConvertStringFromUTF8ToGB2312(localFile, gbkString);
			if (osgDB::fileExists(gbkString))
				return gbkString;
			return originalFileName;
		}
		osg::notify(osg::NOTICE) << "FileCache::createCacheFileName(" << originalFileName << ") = " << cacheFileName << std::endl;
		return cacheFileName;
	}
开发者ID:FreeDegree,项目名称:Zhang,代码行数:29,代码来源:FileCacheExt.cpp


示例17: while

std::string ModelMaker::replaceAllString(std::string& fullString, std::string toReplace, std::string replaceWith){
	std::string returnString = fullString;
	while(returnString.find(toReplace) != std::string::npos)	{
		returnString = replaceString(returnString, toReplace, replaceWith);
	}

	return returnString;
}
开发者ID:hksonngan,项目名称:ds_cinder,代码行数:8,代码来源:model_maker.cpp


示例18: programSetUp

	/**@brief Construct the setUp with the generic argc and argv
	 *
	 * @param argc The number of arguments
	 * @param argv The array of char pointers of the arguments
	 *
	 */
	programSetUp(int argc, char *argv[]) :
			commands_(commandLineArguments(argc, argv)) {
		commands_.arguments_["-program"] = argv[0];
		// get rid of the ./ if program is being called from current dir, it can
		// mess things up latter
		programName_ = replaceString(argv[0], "./", "");
		init();
	}
开发者ID:bailey-lab,项目名称:cppprogutils,代码行数:14,代码来源:programSetUp.hpp


示例19: replaceAll

string
replaceAll(const string &str, const string &toFind, const string &replaceWith) {
	string result = str;
	while (result.find(toFind) != string::npos) {
		result = replaceString(result, toFind, replaceWith);
	}
	return result;
}
开发者ID:dirkmueller,项目名称:passenger,代码行数:8,代码来源:StrIntUtils.cpp


示例20: main

int main(void)
{
    char text[] = "I have a dream and have 1 dreame * ding word.";

    printf("%s\n", text);

    replaceString(text, "1", "one");
    printf("%s\n", text);

    replaceString(text, "a", "");
    printf("%s\n", text);

    replaceString(text, " ", "");
    printf("%s\n", text);

    return 0;

}
开发者ID:ceye1992,项目名称:learn,代码行数:18,代码来源:9.09.c



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ replace_all函数代码示例发布时间:2022-05-30
下一篇:
C++ replaceAll函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap