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


C++ replace_all函数代码示例

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


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


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