本文整理汇总了C++中anope::string::empty方法的典型用法代码示例。如果您正苦于以下问题:C++ string::empty方法的具体用法?C++ string::empty怎么用?C++ string::empty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类anope::string
的用法示例。
在下文中一共展示了string::empty方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OnResult
void OnResult(const SQL::Result &r) override
{
SQLOperResultDeleter d(this);
if (!user || !user->Account())
return;
if (r.Rows() == 0)
{
Log(LogType::DEBUG) << "m_sql_oper: Got 0 rows for " << user->nick;
Deoper();
return;
}
Anope::string opertype;
try
{
opertype = r.Get(0, "opertype");
}
catch (const SQL::Exception &)
{
Log(this->owner) << "Expected column named \"opertype\" but one was not found";
return;
}
Log(LogType::DEBUG) << "m_sql_oper: Got result for " << user->nick << ", opertype " << opertype;
Anope::string modes;
try
{
modes = r.Get(0, "modes");
}
catch (const SQL::Exception &) { }
ServiceBot *OperServ = Config->GetClient("OperServ");
if (opertype.empty())
{
Deoper();
return;
}
OperType *ot = OperType::Find(opertype);
if (ot == NULL)
{
Log(this->owner) << "m_sql_oper: Oper " << user->nick << " has type " << opertype << ", but this opertype does not exist?";
return;
}
Oper *oper = user->Account()->GetOper();
if (oper == nullptr || oper->GetType() != ot)
{
Log(this->owner) << "m_sql_oper: Tieing oper " << user->nick << " to type " << opertype;
if (oper)
oper->Delete();
oper = Serialize::New<Oper *>();
oper->SetName(user->Account()->GetDisplay());
oper->SetType(ot);
user->Account()->SetOper(oper);
}
if (!user->HasMode("OPER"))
{
IRCD->SendOper(user);
if (!modes.empty())
user->SetModes(OperServ, "%s", modes.c_str());
}
}
示例2:
sockaddrs::sockaddrs(const Anope::string &address)
{
this->clear();
if (!address.empty() && address.find_first_not_of_ci("0123456789abcdef.:") == Anope::string::npos)
this->pton(address.find(':') != Anope::string::npos ? AF_INET6 : AF_INET, address);
}
示例3: Execute
void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override
{
Anope::string param = !params.empty() ? params[0] : "", chan;
ChanServ::Channel *ci = NULL;
MemoServ::MemoInfo *mi;
if (!param.empty() && param[0] == '#')
{
chan = param;
param = params.size() > 1 ? params[1] : "";
ci = ChanServ::Find(chan);
if (!ci)
{
source.Reply(_("Channel \002{0}\002 isn't registered."), chan);
return;
}
if (!source.AccessFor(ci).HasPriv("MEMO"))
{
source.Reply(_("Access denied. You do not have privilege \002{0}\002 on \002{1}\002."), "MEMO", ci->GetName());
return;
}
mi = ci->GetMemos();
}
else
mi = source.nc->GetMemos();
if (!param.empty() && !isdigit(param[0]) && !param.equals_ci("NEW"))
{
this->OnSyntaxError(source, param);
return;
}
if (!mi)
return;
auto memos = mi->GetMemos();
if (!memos.size())
{
if (!chan.empty())
source.Reply(_("\002{0}\002 has no memos."), chan);
else
source.Reply(_("You have no memos."));
return;
}
ListFormatter list(source.GetAccount());
list.AddColumn(_("Number")).AddColumn(_("Sender")).AddColumn(_("Date/Time"));
if (!param.empty() && isdigit(param[0]))
{
NumberList(param, false,
[&](unsigned int number)
{
if (!number || number > memos.size())
return;
MemoServ::Memo *m = mi->GetMemo(number - 1);
ListFormatter::ListEntry entry;
entry["Number"] = (m->GetUnread() ? "* " : " ") + stringify(number);
entry["Sender"] = m->GetSender();
entry["Date/Time"] = Anope::strftime(m->GetTime(), source.GetAccount());
list.AddEntry(entry);
},
[]{});
}
else
{
if (!param.empty())
{
unsigned i, end;
for (i = 0, end = memos.size(); i < end; ++i)
if (mi->GetMemo(i)->GetUnread())
break;
if (i == end)
{
if (!chan.empty())
source.Reply(_("\002{0}\002 has no new memos."), chan);
else
source.Reply(_("You have no new memos."));
return;
}
}
for (unsigned i = 0, end = memos.size(); i < end; ++i)
{
if (!param.empty() && !mi->GetMemo(i)->GetUnread())
continue;
MemoServ::Memo *m = mi->GetMemo(i);
ListFormatter::ListEntry entry;
entry["Number"] = (m->GetUnread() ? "* " : " ") + stringify(i + 1);
entry["Sender"] = m->GetSender();
//.........这里部分代码省略.........
示例4: Execute
void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override
{
const Anope::string &cmd = params[0], target = params[1], info = params.size() > 2 ? params[2] : "";
Serialize::Object *e;
if (IRCD->IsChannelValid(target))
{
ChanServ::Channel *ci = ChanServ::Find(target);
if (!ci)
{
source.Reply(_("Channel \002{0}\002 isn't registered."), target);
return;
}
e = ci;
}
else
{
NickServ::Nick *na = NickServ::FindNick(target);
if (!na)
{
source.Reply(_("\002{0}\002 isn't registered."), target);
return;
}
e = na->GetAccount();
}
if (cmd.equals_ci("ADD"))
{
if (info.empty())
{
this->OnSyntaxError(source, cmd);
return;
}
std::vector<OperInfo *> oinfos = e->GetRefs<OperInfo *>(operinfo);
if (oinfos.size() >= Config->GetModule(this->module)->Get<unsigned int>("max", "10"))
{
source.Reply(_("The oper info list for \002{0}\002 is full."), target);
return;
}
for (OperInfo *o : oinfos)
if (o->GetInfo().equals_ci(info))
{
source.Reply(_("The oper info already exists on \002{0}\002."), target);
return;
}
OperInfo *o = operinfo.Create();
o->SetTarget(e);
o->SetInfo(info);
o->SetCreator(source.GetNick());
o->SetCreated(Anope::CurTime);
source.Reply(_("Added info to \002{0}\002."), target);
Log(LOG_ADMIN, source, this) << "to add information to " << target;
if (Anope::ReadOnly)
source.Reply(_("Services are in read-only mode. Any changes made may not persist."));
}
else if (cmd.equals_ci("DEL"))
{
if (info.empty())
{
this->OnSyntaxError(source, cmd);
return;
}
std::vector<OperInfo *> oinfos = e->GetRefs<OperInfo *>(operinfo);
if (oinfos.empty())
{
source.Reply(_("Oper info list for \002{0}\002 is empty."), target);
return;
}
for (OperInfo *o : oinfos)
{
if (o->GetInfo().equals_ci(info))
{
o->Delete();
source.Reply(_("Deleted info from \002{0}\002."), target);
Log(LOG_ADMIN, source, this) << "to remove information from " << target;
if (Anope::ReadOnly)
source.Reply(_("Services are in read-only mode. Any changes made may not persist."));
return;
}
}
source.Reply(_("No such info \002{0}\002 on \002{1}\002."), info, target);
}
else if (cmd.equals_ci("CLEAR"))
{
std::vector<OperInfo *> oinfos = e->GetRefs<OperInfo *>(operinfo);
if (oinfos.empty())
{
//.........这里部分代码省略.........
示例5: x
Server::Server(Server *up, const Anope::string &sname, unsigned shops, const Anope::string &desc, const Anope::string &ssid, bool jupe) : name(sname), hops(shops), description(desc), sid(ssid), uplink(up), users(0)
{
syncing = true;
juped = jupe;
quitting = false;
Servers::ByName[sname] = this;
if (!ssid.empty())
Servers::ByID[ssid] = this;
Log(this, "connect") << "has connected to the network (uplinked to " << (this->uplink ? this->uplink->GetName() : "no uplink") << ")";
/* Add this server to our uplinks leaf list */
if (this->uplink)
{
this->uplink->AddLink(this);
/* Check to be sure this isn't a juped server */
if (Me == this->uplink && !juped)
{
/* Now do mode related stuff as we know what modes exist .. */
for (botinfo_map::iterator it = BotListByNick->begin(), it_end = BotListByNick->end(); it != it_end; ++it)
{
BotInfo *bi = it->second;
Anope::string modes = !bi->botmodes.empty() ? ("+" + bi->botmodes) : IRCD->DefaultPseudoclientModes;
bi->SetModesInternal(bi, modes.c_str());
for (unsigned i = 0; i < bi->botchannels.size(); ++i)
{
size_t h = bi->botchannels[i].find('#');
if (h == Anope::string::npos)
continue;
Anope::string chname = bi->botchannels[i].substr(h);
Channel *c = Channel::Find(chname);
if (c && c->FindUser(bi))
{
Anope::string want_modes = bi->botchannels[i].substr(0, h);
for (unsigned j = 0; j < want_modes.length(); ++j)
{
ChannelMode *cm = ModeManager::FindChannelModeByChar(want_modes[j]);
if (cm == NULL)
cm = ModeManager::FindChannelModeByChar(ModeManager::GetStatusChar(want_modes[j]));
if (cm && cm->type == MODE_STATUS)
{
MessageSource ms = bi;
c->SetModeInternal(ms, cm, bi->nick);
}
}
}
}
}
IRCD->SendBOB();
for (unsigned i = 0; i < Me->GetLinks().size(); ++i)
{
Server *s = Me->GetLinks()[i];
if (s->juped)
IRCD->SendServer(s);
}
/* We make the bots go online */
for (user_map::const_iterator it = UserListByNick.begin(); it != UserListByNick.end(); ++it)
{
User *u = it->second;
BotInfo *bi = BotInfo::Find(u->GetUID());
if (bi)
{
XLine x(bi->nick, "Reserved for services");
IRCD->SendSQLine(NULL, &x);
}
IRCD->SendClientIntroduction(u);
if (bi)
bi->introduced = true;
}
for (channel_map::const_iterator it = ChannelList.begin(), it_end = ChannelList.end(); it != it_end; ++it)
{
Channel *c = it->second;
if (c->users.empty())
IRCD->SendChannel(c);
else
for (Channel::ChanUserList::const_iterator cit = c->users.begin(), cit_end = c->users.end(); cit != cit_end; ++cit)
IRCD->SendJoin(cit->second->user, c, &cit->second->status);
for (Channel::ModeList::const_iterator it2 = c->GetModes().begin(); it2 != c->GetModes().end(); ++it2)
{
ChannelMode *cm = ModeManager::FindChannelModeByName(it2->first);
if (!cm || cm->type != MODE_LIST)
continue;
ModeManager::StackerAdd(c->ci->WhoSends(), c, cm, true, it2->second);
}
if (!c->topic.empty() && !c->topic_setter.empty())
IRCD->SendTopic(c->ci->WhoSends(), c);
//.........这里部分代码省略.........