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

C++ replace_all函数代码示例

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

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



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

示例1: replace_all

string ClientInfo::clean(string str)
{
	replace_all(str, "=", "");
	replace_all(str, "+", "-");
	replace_all(str, "/", "_");
	
	return str;
}
开发者ID:rallan9,项目名称:inetfs,代码行数:8,代码来源:ClientInfo.cpp


示例2: replace_all

string parser::fix_corrupted_data(const string &in)
{
    string out = in;
    replace_all(out, "mimetype:", "\"mimetype\":");
    replace_all(out, "compressed:", "\"compressed\":");
    replace_all(out, "encoding:", "\"encoding\":");
    replace_all(out, "data:", "\"data\":");
    return out;
}
开发者ID:woronin,项目名称:kumir2,代码行数:9,代码来源:parser.cpp


示例3: convertPathToDelims

// ensures all the delims are constant
std::string convertPathToDelims(const char* file)
{
  if (!file)
    return std::string();

  std::string delim;
  delim += _DirDelim;
  return replace_all(replace_all(file,"/",delim),"\\",delim);
}
开发者ID:szakats,项目名称:bzflag_mirror,代码行数:10,代码来源:plugin_files.cpp


示例4: lcl_fred_replace_stuff

void lcl_fred_replace_stuff(SCP_string &text)
{
	if (!Fred_running)
		return;

	replace_all(text, "\"", "$quote");
	replace_all(text, ";", "$semicolon");
	replace_all(text, "/", "$slash");
	replace_all(text, "\\", "$backslash");
}
开发者ID:X3N0-Life-Form,项目名称:fs2open.github.com,代码行数:10,代码来源:localize.cpp


示例5: substitute_xml_entities_into_text

std::string GumboInterface::substitute_xml_entities_into_attributes(char quote, const std::string &text)
{
    std::string result = substitute_xml_entities_into_text(text);
    if (quote == '"') {
        replace_all(result,"\"",""");
    } else if (quote == '\'') {
        replace_all(result,"'","'");
    }
    return result;
}
开发者ID:CedarLogic,项目名称:Sigil,代码行数:10,代码来源:GumboInterface.cpp


示例6: migrate_init

static inline void migrate_init()
{
	char buffer[MAX_PACKET_SIZE];
	struct timeval t1, t2, dt;

	gettimeofday_safe(&t1);
	eprintf("migrate to IP: #%s#\n", migrate_ip);
	init_sockaddr(&migrate_addr, migrate_ip, MANAGER_PORT);

	strcpy(buffer, "establish");
	send_msg(manager_socket, &migrate_addr, buffer, strlen(buffer));
	printf("sent establish\n");

	send_msg(manager_socket, &migrate_addr, out_invite.buffer, out_invite.size);
	printf("sent INIT\n");

	send_msg(manager_socket, &migrate_addr, out_ack.buffer, out_ack.size);
	printf("sent ACK\n");

	send_msg(manager_socket, &migrate_addr, out_op_ok.buffer, out_op_ok.size);
	printf("sent OPTIONS OK\n");

	recv_msg(manager_socket, &migrate_addr, buffer);
	printf("\nreceived:\n%s\n", buffer);
	gettimeofday_safe(&t2);

	time_diff(&t1, &t2, &dt);
	printf("time 1: %lu.%06lu\n", dt.tv_sec, dt.tv_usec);

	init_sockaddr(&migrate_addr, remote_ip, MANAGER_PORT);
	strcpy(buffer, "redirect: ");
	strcat(buffer, migrate_ip);
	gettimeofday_safe(&t1);
	send_msg(manager_socket, &migrate_addr, buffer, strlen(buffer));
	gettimeofday_safe(&t2);

	time_diff(&t1, &t2, &dt);
	printf("time 2: %lu.%06lu\n", dt.tv_sec, dt.tv_usec);

	gettimeofday_safe(&t1);
	get_data(out_ack.buffer, &ack_data);
	memset(buffer, 0, MAX_PACKET_SIZE);
	strcpy(buffer, bye);
	replace_all(buffer, "local_ip", local_ip);
	replace_all(buffer, "remote_ip", remote_ip);
	replace_all(buffer, "from_tag", ack_data.to_tag);
	replace_all(buffer, "to_tag", ack_data.from_tag);
	replace_all(buffer, "call_id", ack_data.call_id);
	send_msg(proxy_to_linphone_socket, &proxy_to_linphone_addr, buffer, strlen(buffer));
	gettimeofday_safe(&t2);

	time_diff(&t1, &t2, &dt);
	printf("time 3: %lu.%06lu\n", dt.tv_sec, dt.tv_usec);
}
开发者ID:cristianbercaru,项目名称:linphone_proxy,代码行数:54,代码来源:main.c


示例7: flush

void TextIOHandler::show_message(MessageType type, String const& message) {
	flush();
	stream = stderr;
	if (type == MESSAGE_WARNING) {
		*this << YELLOW << _("WARNING: ") << NORMAL << replace_all(message,_("\n"),_("\n         ")) << ENDL;
	} else {
		*this << RED << _("ERROR: ") << NORMAL << replace_all(message,_("\n"),_("\n       ")) << ENDL;
	}
	flush();
	stream = stdout;
	if (raw_mode) raw_mode_status = max(raw_mode_status, type == MESSAGE_WARNING ? 1 : 2);
}
开发者ID:BestRCH,项目名称:magicseteditor,代码行数:12,代码来源:text_io_handler.cpp


示例8: PrepareString

    ACE_TString PrepareString(const ACE_TString& str)
    {
        ACE_TString newstr;
        if(str.length()>MAX_STRING_LENGTH)
            newstr = str.substr(0, MAX_STRING_LENGTH);
        else
            newstr = str;

        replace_all(newstr, ACE_TEXT("\\"), ACE_TEXT("\\\\"));
        replace_all(newstr, ACE_TEXT("\""), ACE_TEXT("\\\""));
        replace_all(newstr, ACE_TEXT("\r"), ACE_TEXT("\\r"));
        replace_all(newstr, ACE_TEXT("\n"), ACE_TEXT("\\n"));

        return newstr;
    }
开发者ID:BearWare,项目名称:TeamTalk5,代码行数:15,代码来源:Commands.cpp


示例9: file

int
TokenServer::tokenToUser(ServerContext& ctxt, const string& token, string& user)
{
	if (ctxt.user() != string(":root") && ctxt.user() != string(":admin") && ctxt.user() != string(":web"))
	{
		return -ENOENT;
	}

	token_map_t::iterator it = active_tokens.find(token);
	if (it != active_tokens.end())
	{
		// cache for 60 seconds
		time_t when = get<0>(it->second);
		if (when < time(0) + 60)
		{
			user = get<1>(it->second);
			return 0;
		}
		active_tokens.erase(token);
	}
	string path = SEPSTR + token + "/:tokenuser";
	SingleFile file(ctxt, *this, path.c_str());
	user = file.get();
	replace_all(user, "\n", "");
	if (user.empty())
	{
		return -ENOENT;
	}
	active_tokens[token] = make_pair(time(0), user);
	return 0;
}
开发者ID:rallan9,项目名称:inetfs,代码行数:31,代码来源:TokenServer.cpp


示例10: lcl_replace_stuff

void lcl_replace_stuff(char *text, unsigned int max_len)
{
	Assert(text);	// Goober5000

	if (Fred_running)
		return;

	if (!Player)
		return;

	int i;
	char replace[LCL_NUM_REPLACEMENTS][2][NAME_LENGTH];

	// fill replacements array (this is if we want to add more in the future)
	strcpy(replace[0][0], "$callsign");
	strcpy(replace[0][1], Player->callsign);
	strcpy(replace[1][0], "$rank");
	strcpy(replace[1][1], Ranks[Player->stats.rank].name);
	strcpy(replace[2][0], "$quote");
	strcpy(replace[2][1], "\"");
	strcpy(replace[3][0], "$semicolon");
	strcpy(replace[3][1], ";");

	// do all replacements
	for (i = 0; i < LCL_NUM_REPLACEMENTS; i++)
	{
		// replace all instances of that string
		replace_all(text, replace[i][0], replace[i][1], max_len);
	}
}
开发者ID:chief1983,项目名称:Imperial-Alliance,代码行数:30,代码来源:LOCALIZE.CPP


示例11: replace_all

map<int,var_val___>::iterator var___::huashen__(const string& s1,char use,size_t n){
	string s=s1;
	replace_all(s,"\\","/");
	/*int i;
	for(i=huashen_.size();--i>=0;){
		if(huashen_[i].rfind__(s,n))
			break;
	}
	return i<0 ? huashen_.end() : huashen_.find(i);*/
	/*map<int,var_val___>::reverse_iterator mi;
	for(mi=huashen_.rbegin();mi!=huashen_.rend();mi--){
		if(mi->second.rfind__(s,n)){
			if(use=='x')
				--mi;
			return mi.base();
		}
	}
	return huashen_.end();*/
	map<int,var_val___>::iterator mi1=huashen_.end();
	for(map<int,var_val___>::iterator mi=huashen_.begin();mi!=huashen_.end();mi++){
		if(mi->second.rfind__(s,n))
			mi1=mi;
	}
	return mi1;
}
开发者ID:BGCX261,项目名称:zhscript-svn-to-git,代码行数:25,代码来源:var___.cpp


示例12: base_name

int
TokenServer::checkToken(const char *path, file_stat_t& fs)
{
	const char *bname = base_name(path);
	if (Config::instance()->enable_token_server() && strncmp(bname, ".token-",  7) == 0)
	{
		string b64;
		sha2_loop(Config::instance()->token_group(), 5, b64);
		replace_all(b64, "=", "");
		b64 = "/.token-" + b64std2inet(b64);
		if (b64 == bname)
		{
			fs.fs_ino = 1;
			fs.fs_size = 0;
			fs.fs_blocks = 1024;
			fs.fs_atime = fs.fs_mtime = fs.fs_ctime = time(0);
			fs.fs_mode = S_IFREG | 0000;
			fs.fs_nlink = 0;
			fs.fs_uid = 65534;
			fs.fs_gid = 65534;
			fs.fs_blksize = 4096;
			return 0;
		}
	}
	return -ENOENT;
}
开发者ID:rallan9,项目名称:inetfs,代码行数:26,代码来源:TokenServer.cpp


示例13: strOld

int CMyString::Replace(const wchar_t * lpszOld, const wchar_t * lpszNew)
{
	CMyString			strOld(lpszOld);
	CMyString			strNew(lpszNew);

	return replace_all(*this, strOld, strNew);
}
开发者ID:maxspot,项目名称:MFCClasses_in_ATL,代码行数:7,代码来源:MyString.cpp


示例14: while

string Bubble::drawTextLine(int x0, int y0, string text, int maxwidth, float rel_height, bool centered) const {
    string prefix = "", oldprefix = "";
    int height, width = 0;
    while (width < maxwidth && oldprefix != text) {
	oldprefix = prefix;
	// Find the next word boundary
	size_t len = prefix.length();
	size_t word_idx = text.find(" ", len+1);

	if (word_idx != string::npos) {
	    prefix = text.substr(0, word_idx);
	} else {
	    prefix = text;
	}
	imlib_get_text_size(prefix.c_str(), &width, &height);
    }

    imlib_get_text_size(oldprefix.c_str(), &width, &height);
    int xpos = x0 + 2;
    if (centered) xpos += (maxwidth-width)/2;
    int ypos = y0 - height/2 - static_cast<int>(round(1.1*rel_height*(height/2.0)));
    imlib_text_draw(xpos, ypos, replace_all(oldprefix, "~", " ").c_str());
    //imlib_image_draw_line(x0, y0, x0+maxwidth, y0, 0);
    if (oldprefix == text) return "";
    else                   return text.substr(oldprefix.length()+1);
}
开发者ID:HendrikR,项目名称:comictranslator,代码行数:26,代码来源:bubble.cpp


示例15: replace_all

std::string GumboInterface::substitute_xml_entities_into_text(const std::string &text)
{
    std::string result = text;
    // replacing & must come first 
    replace_all(result, "&", "&amp;");
    replace_all(result, "<", "&lt;");
    replace_all(result, ">", "&gt;");
    // convert non-breaking spaces to entities to prevent their loss for later editing
    // See the strange//buggy behaviour of Qt QTextDocument toPlainText() routine 
    if (m_hasnbsp) {
        replace_all(result, "\xc2\xa0", "&nbsp;");
    } else {
        replace_all(result, "\xc2\xa0", "&#160;");
    }
    return result;
}
开发者ID:CedarLogic,项目名称:Sigil,代码行数:16,代码来源:GumboInterface.cpp


示例16: RebuildString

    ACE_TString RebuildString(const ACE_TString& str)
    {
        ACE_TString resultstr = str, tmpstr;
        ACE_TCHAR search[3][3] = { ACE_TEXT("\\n"), ACE_TEXT("\\r"), ACE_TEXT("\\\"") };
        ACE_TCHAR replace[3][2] = { ACE_TEXT("\n"), ACE_TEXT("\r"), ACE_TEXT("\"") };

        for(size_t j = 0; j < 3; j++)
        {
            size_t pos1 = 0, oldpos = 0;
            tmpstr = resultstr;
            resultstr.clear();
            while( (pos1 = tmpstr.find(search[j], pos1)) != ACE_TString::npos)
            {
                int i = (int)pos1;
                int slashes = 0;
                while(i >= 0 && tmpstr[i--] == '\\')slashes++;
                if(slashes % 2 != 0) //odd number of \ means the character should be escaped
                {
                    resultstr += tmpstr.substr(oldpos, pos1 - oldpos) + replace[j];
                    oldpos = pos1 + 2;
                }
                pos1 += 2;
            }

            resultstr += tmpstr.substr(oldpos, tmpstr.length() - oldpos);
        }

        replace_all(resultstr, ACE_TEXT("\\\\"), ACE_TEXT("\\"));
        return resultstr;
    }
开发者ID:BearWare,项目名称:TeamTalk5,代码行数:30,代码来源:Commands.cpp


示例17: sprintf

bool
BlackList::is_black_listed(uint32_t pid)
{
	char buffer[2048];
	sprintf(buffer, "/proc/%u/cmdline", pid);

	if (!file_exists(buffer))
	{
		return true;
	}

	string contents;
	FILE *in = fopen(buffer, "r");
	if (in == NULL)
	{
		return true;
	}
	*buffer = 0;
	if (NULL == fgets(buffer, sizeof (buffer), in))
	{
		fclose(in);
		return true;
	}
	fclose(in);
	contents = buffer;
	replace_all(contents, "\n", "");
	return is_black_listed(contents.c_str());
}
开发者ID:rallan9,项目名称:inetfs,代码行数:28,代码来源:BlackList.cpp


示例18: warn

void UserInterface::exec_fityk_script(const string& filename)
{
    user_interrupt = false;

    boost::scoped_ptr<FileOpener> opener;
    if (endswith(filename, ".gz"))
        opener.reset(new GzipFileOpener);
    else
        opener.reset(new NormalFileOpener);
    if (!opener->open(filename.c_str())) {
        warn("Can't open file: " + filename);
        return;
    }

    int line_index = 0;
    char *line;
    string s;
    while ((line = opener->read_line()) != NULL) {
        ++line_index;
        if (line[0] == '\0')
            continue;
        if (ctx_->get_verbosity() >= 0)
            show_message (kQuoted, S(line_index) + "> " + line);
        s += line;
        if (*(s.end() - 1) == '\\') {
            s.resize(s.size()-1);
            continue;
        }
        if (s.find("_SCRIPT_DIR_/") != string::npos) {
            string dir = get_directory(filename);
            replace_all(s, "_EXECUTED_SCRIPT_DIR_/", dir); // old magic string
            replace_all(s, "_SCRIPT_DIR_/", dir); // new magic string
        }
        Status r = execute_line(s);
        if (r != kStatusOk &&
                ctx_->get_settings()->on_error[0] != 'n' /*nothing*/)
            break;
        if (user_interrupt) {
            mesg("Script stopped by signal INT.");
            break;
        }
        s.clear();
    }
    if (line == NULL && !s.empty())
        throw SyntaxError("unfinished line");
}
开发者ID:simedcn,项目名称:fityk,代码行数:46,代码来源:ui.cpp


示例19: THREAD_CHECK

const char *luaL_gsub (LuaThread *L, const char *s, const char *p, const char *r) {
  THREAD_CHECK(L);

  std::string result = replace_all(s, p, r);

  LuaString* s2 = L->l_G->strings_->Create(result.c_str());
  L->stack_.push(s2);
  return s2->c_str();
}
开发者ID:aappleby,项目名称:Lumina,代码行数:9,代码来源:lauxlib.cpp


示例20: switch

//--------------------------------------------------------------
void testApp::keyPressed(int key)
{
	int len = input.length();
	switch(key) {
/*	case ' ':
		input += "%20";
		break;
	case 'x':
		showXYZ = (showXYZ) ? false : true;
		break;
	case 'q':
		eyeZ += 0.005f;
		break;
	case 'w':
		eyeZ -= 0.005f;
		break;
*/
	case OF_KEY_LEFT:
		if (--current < 0) current = cities.size() - 1;
		break;
	case OF_KEY_RIGHT:
		if (++current >= cities.size()) current = 0;
		break;
	case OF_KEY_UP:
		eyeZ -= 0.001f;
		break;
	case OF_KEY_DOWN:
		eyeZ += 0.001f;
		break;
	case OF_KEY_PAGE_UP:
		//eyeY += 0.005f;
		break;
	case OF_KEY_PAGE_DOWN:
		//eyeY -= 0.005f;
		break;
	case OF_KEY_BACKSPACE:
		if (len) input.erase(len-1);
		break;
	case OF_KEY_RETURN:
		input = replace_all(input, " ", "%20");
		try {
			cities.push_back(City(input, *earth));
			input.erase(0);
			current = cities.size() - 1;
		} catch (runtime_error e) {
			cout << e.what() << endl;
			input.erase(0);
			showError = true;
		}
		break;
	default:
		showError = false;
		input += key;
		break;
	}
}
开发者ID:mhayashi,项目名称:worldclock,代码行数:57,代码来源:testApp.cpp



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ replace_program函数代码示例发布时间:2022-05-30
下一篇:
C++ replaceString函数代码示例发布时间: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