本文整理汇总了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;
}
示例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;
}
示例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);
}
示例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");
}
示例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;
}
示例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);
}
示例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);
}
示例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;
}
示例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;
}
示例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);
}
}
示例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;
}
示例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;
}
示例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);
}
示例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);
}
示例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, "&", "&");
replace_all(result, "<", "<");
replace_all(result, ">", ">");
// 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", " ");
} else {
replace_all(result, "\xc2\xa0", " ");
}
return result;
}