本文整理汇总了C++中ConvToStr函数的典型用法代码示例。如果您正苦于以下问题:C++ ConvToStr函数的具体用法?C++ ConvToStr怎么用?C++ ConvToStr使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ConvToStr函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ProcessMessages
ModResult ProcessMessages(User* user,Channel* dest, const std::string &text)
{
if ((!IS_LOCAL(user)) || !dest->IsModeSet(mf))
return MOD_RES_PASSTHRU;
if (ServerInstance->OnCheckExemption(user,dest,"flood") == MOD_RES_ALLOW)
return MOD_RES_PASSTHRU;
floodsettings *f = mf.ext.get(dest);
if (f)
{
if (f->addmessage(user))
{
/* Youre outttta here! */
f->clear(user);
if (f->ban)
{
std::vector<std::string> parameters;
parameters.push_back(dest->name);
parameters.push_back("+b");
parameters.push_back("*!*@" + user->dhost);
ServerInstance->Modes->Process(parameters, ServerInstance->FakeClient);
}
const std::string kickMessage = "Channel flood triggered (limit is " + ConvToStr(f->lines) +
" in " + ConvToStr(f->secs) + " secs)";
dest->KickUser(ServerInstance->FakeClient, user, kickMessage);
return MOD_RES_DENY;
}
}
return MOD_RES_PASSTHRU;
}
示例2: SendHeaders
void SendHeaders(unsigned long size, int response, HTTPHeaders &rheaders)
{
WriteData(http_version + " "+ConvToStr(response)+" "+Response(response)+"\r\n");
time_t local = ServerInstance->Time();
struct tm *timeinfo = gmtime(&local);
char *date = asctime(timeinfo);
date[strlen(date) - 1] = '\0';
rheaders.CreateHeader("Date", date);
rheaders.CreateHeader("Server", BRANCH);
rheaders.SetHeader("Content-Length", ConvToStr(size));
if (size)
rheaders.CreateHeader("Content-Type", "text/html");
else
rheaders.RemoveHeader("Content-Type");
/* Supporting Connection: keep-alive causes a whole world of hurt syncronizing timeouts,
* so remove it, its not essential for what we need.
*/
rheaders.SetHeader("Connection", "Close");
WriteData(rheaders.GetFormattedHeaders());
WriteData("\r\n");
}
示例3: OnStats
ModResult OnStats(Stats::Context& stats) override
{
if (stats.GetSymbol() != 'G')
return MOD_RES_PASSTHRU;
unsigned int unknown = 0;
std::map<std::string, unsigned int> results;
const UserManager::LocalList& list = ServerInstance->Users.GetLocalUsers();
for (UserManager::LocalList::const_iterator i = list.begin(); i != list.end(); ++i)
{
std::string* cc = ext.get(*i);
if (cc)
results[*cc]++;
else
unknown++;
}
for (std::map<std::string, unsigned int>::const_iterator i = results.begin(); i != results.end(); ++i)
{
stats.AddRow(801, "GeoIPSTATS " + i->first + " " + ConvToStr(i->second));
}
if (unknown)
stats.AddRow(801, "GeoIPSTATS Unknown " + ConvToStr(unknown));
return MOD_RES_DENY;
}
示例4: OnSetAway
virtual ModResult OnSetAway(User *user, const std::string &awaymsg)
{
std::string numeric;
int inum;
if (awaymsg.empty())
{
numeric = user->nick + " " + user->ident + " " + user->dhost + " " + ConvToStr(ServerInstance->Time()) + " :is no longer away";
inum = 599;
}
else
{
numeric = user->nick + " " + user->ident + " " + user->dhost + " " + ConvToStr(ServerInstance->Time()) + " :" + awaymsg;
inum = 598;
}
watchentries::iterator x = whos_watching_me->find(user->nick.c_str());
if (x != whos_watching_me->end())
{
for (std::deque<User*>::iterator n = x->second.begin(); n != x->second.end(); n++)
{
(*n)->WriteNumeric(inum, numeric);
}
}
return MOD_RES_PASSTHRU;
}
示例5: OnUserJoin
void ModuleSpanningTree::OnUserJoin(userrec* user, chanrec* channel, bool &silent)
{
// Only do this for local users
if (IS_LOCAL(user))
{
if (channel->GetUserCounter() == 1)
{
std::deque<std::string> params;
// set up their permissions and the channel TS with FJOIN.
// All users are FJOINed now, because a module may specify
// new joining permissions for the user.
params.push_back(channel->name);
params.push_back(ConvToStr(channel->age));
params.push_back(std::string(channel->GetAllPrefixChars(user))+","+std::string(user->nick));
Utils->DoOneToMany(ServerInstance->Config->ServerName,"FJOIN",params);
/* First user in, sync the modes for the channel */
params.pop_back();
params.push_back(channel->ChanModes(true));
Utils->DoOneToMany(ServerInstance->Config->ServerName,"FMODE",params);
}
else
{
std::deque<std::string> params;
params.push_back(channel->name);
params.push_back(ConvToStr(channel->age));
Utils->DoOneToMany(user->nick,"JOIN",params);
}
}
}
示例6: Handle
CmdResult Handle (const std::vector<std::string> ¶meters, User *src)
{
std::map<std::string,int> closed;
for (LocalUserList::const_iterator u = ServerInstance->Users->local_users.begin(); u != ServerInstance->Users->local_users.end(); ++u)
{
LocalUser* user = *u;
if (user->registered != REG_ALL)
{
ServerInstance->Users->QuitUser(user, "Closing all unknown connections per request");
std::string key = ConvToStr(user->GetIPString())+"."+ConvToStr(user->GetServerPort());
closed[key]++;
}
}
int total = 0;
for (std::map<std::string,int>::iterator ci = closed.begin(); ci != closed.end(); ci++)
{
src->WriteNotice("*** Closed " + ConvToStr(ci->second) + " unknown " + (ci->second == 1 ? "connection" : "connections") +
" from [" + ci->first + "]");
total += ci->second;
}
if (total)
src->WriteNotice("*** " + ConvToStr(total) + " unknown " + (total == 1 ? "connection" : "connections") + " closed");
else
src->WriteNotice("*** No unknown connections found");
return CMD_SUCCESS;
}
示例7: OnStats
ModResult OnStats(char symbol, User* user, string_list &out)
{
if (symbol != 'G')
return MOD_RES_PASSTHRU;
unsigned int unknown = 0;
std::map<std::string, unsigned int> results;
for (LocalUserList::const_iterator i = ServerInstance->Users->local_users.begin(); i != ServerInstance->Users->local_users.end(); ++i)
{
std::string* cc = ext.get(*i);
if (cc)
results[*cc]++;
else
unknown++;
}
std::string p = ServerInstance->Config->ServerName + " 801 " + user->nick + " :GeoIPSTATS ";
for (std::map<std::string, unsigned int>::const_iterator i = results.begin(); i != results.end(); ++i)
{
out.push_back(p + i->first + " " + ConvToStr(i->second));
}
if (unknown)
out.push_back(p + "Unknown " + ConvToStr(unknown));
return MOD_RES_DENY;
}
示例8: params
void ModuleSpanningTree::OnUserJoin(Membership* memb, bool sync, bool created_by_local, CUList& excepts)
{
// Only do this for local users
if (!IS_LOCAL(memb->user))
return;
if (created_by_local)
{
CmdBuilder params("FJOIN");
params.push_back(memb->chan->name);
params.push_back(ConvToStr(memb->chan->age));
params.push_raw(" +").push_raw(memb->chan->ChanModes(true));
params.push(memb->modes).push_raw(',').push_raw(memb->user->uuid);
params.Broadcast();
}
else
{
CmdBuilder params(memb->user, "IJOIN");
params.push_back(memb->chan->name);
if (!memb->modes.empty())
{
params.push_back(ConvToStr(memb->chan->age));
params.push_back(memb->modes);
}
params.Broadcast();
}
}
示例9: ExpireLine
void XLineManager::InvokeStats(const std::string &type, int numeric, User* user, string_list &results)
{
ContainerIter n = lookup_lines.find(type);
time_t current = ServerInstance->Time();
LookupIter safei;
if (n != lookup_lines.end())
{
XLineLookup& list = n->second;
for (LookupIter i = list.begin(); i != list.end(); )
{
safei = i;
safei++;
if (i->second->duration && current > i->second->expiry)
{
ExpireLine(n, i);
}
else
results.push_back(ServerInstance->Config->ServerName+" "+ConvToStr(numeric)+" "+user->nick+" :"+i->second->Displayable()+" "+
ConvToStr(i->second->set_time)+" "+ConvToStr(i->second->duration)+" "+i->second->source+" :"+i->second->reason);
i = safei;
}
}
}
示例10: ModeSet
ModePair ModeSet(userrec* source, userrec* dest, chanrec* channel, const std::string ¶meter)
{
floodsettings* x;
if (channel->GetExt("flood",x))
return std::make_pair(true, (x->ban ? "*" : "")+ConvToStr(x->lines)+":"+ConvToStr(x->secs));
else
return std::make_pair(false, parameter);
}
示例11: sizeof
std::string CommandWhowas::GetStats()
{
int whowas_size = 0;
int whowas_bytes = 0;
for (whowas_users::iterator i = whowas.begin(); i != whowas.end(); ++i)
{
whowas_set* n = i->second;
whowas_size += n->size();
whowas_bytes += (sizeof(whowas_set) + ( sizeof(WhoWasGroup) * n->size() ) );
}
return "Whowas entries: " +ConvToStr(whowas_size)+" ("+ConvToStr(whowas_bytes)+" bytes)";
}
示例12: SendTopic
void SpanningTreeProtocolInterface::SendTopic(Channel* channel, std::string &topic)
{
parameterlist params;
params.push_back(channel->name);
params.push_back(ConvToStr(channel->age));
params.push_back(ConvToStr(ServerInstance->Time()));
params.push_back(ServerInstance->Config->ServerName);
params.push_back(":" + topic);
Utils->DoOneToMany(ServerInstance->Config->GetSID(),"FTOPIC", params);
}
示例13: return
std::string ModuleSpanningTree::TimeToStr(time_t secs)
{
time_t mins_up = secs / 60;
time_t hours_up = mins_up / 60;
time_t days_up = hours_up / 24;
secs = secs % 60;
mins_up = mins_up % 60;
hours_up = hours_up % 24;
return ((days_up ? (ConvToStr(days_up) + "d") : "")
+ (hours_up ? (ConvToStr(hours_up) + "h") : "")
+ (mins_up ? (ConvToStr(mins_up) + "m") : "")
+ ConvToStr(secs) + "s");
}
示例14: DoCommand
void DoCommand(std::string newline, userrec* user, chanrec *c,const std::string &original_line)
{
for (int v = 1; v < 10; v++)
{
std::string var = "$";
var.append(ConvToStr(v));
var.append("-");
std::string::size_type x = newline.find(var);
while (x != std::string::npos)
{
newline.erase(x, var.length());
newline.insert(x, GetVar(var, original_line));
x = newline.find(var);
}
var = "$";
var.append(ConvToStr(v));
x = newline.find(var);
while (x != std::string::npos)
{
newline.erase(x, var.length());
newline.insert(x, GetVar(var, original_line));
x = newline.find(var);
}
}
/* Special variables */
SearchAndReplace(newline, "$nick", user->nick);
SearchAndReplace(newline, "$ident", user->ident);
SearchAndReplace(newline, "$host", user->host);
SearchAndReplace(newline, "$vhost", user->dhost);
SearchAndReplace(newline, "$chan", c->name);
/* Unescape any variable names in the user text before sending */
SearchAndReplace(newline, "\r", "$");
irc::tokenstream ss(newline);
const char* parv[127];
int x = 0;
while (ss.GetToken(pars[x]))
{
parv[x] = pars[x].c_str();
x++;
}
ServerInstance->Parser->CallHandler(parv[0], &parv[1], x-1, user);
}
示例15: params
void ModuleSpanningTree::OnUserJoin(Membership* memb, bool sync, bool created_by_local, CUList& excepts)
{
// Only do this for local users
if (!IS_LOCAL(memb->user))
return;
// Assign the current membership id to the new Membership and increase it
memb->id = currmembid++;
if (created_by_local)
{
CommandFJoin::Builder params(memb->chan);
params.add(memb);
params.finalize();
params.Broadcast();
}
else
{
CmdBuilder params(memb->user, "IJOIN");
params.push_back(memb->chan->name);
params.push_int(memb->id);
if (!memb->modes.empty())
{
params.push_back(ConvToStr(memb->chan->age));
params.push_back(memb->modes);
}
params.Broadcast();
}
}