本文整理汇总了C++中anope::string::find方法的典型用法代码示例。如果您正苦于以下问题:C++ string::find方法的具体用法?C++ string::find怎么用?C++ string::find使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类anope::string
的用法示例。
在下文中一共展示了string::find方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Unescape
static Anope::string Unescape(const Anope::string &string)
{
Anope::string ret = string;
for (int i = 0; special[i].character.empty() == false; ++i)
if (!special[i].replace.empty())
ret = ret.replace_all_cs(special[i].replace, special[i].character);
for (size_t i, last = 0; (i = string.find("&#", last)) != Anope::string::npos;)
{
last = i + 1;
size_t end = string.find(';', i);
if (end == Anope::string::npos)
break;
Anope::string ch = string.substr(i + 2, end - (i + 2));
if (ch.empty())
continue;
long l;
if (!ch.empty() && ch[0] == 'x')
l = strtol(ch.substr(1).c_str(), NULL, 16);
else
l = strtol(ch.c_str(), NULL, 10);
if (l > 0 && l < 256)
ret = ret.replace_all_cs("&#" + ch + ";", Anope::string(l));
}
return ret;
}
示例2: RealMask
Anope::string RealMask(const Anope::string &mask)
{
/* If it s an existing user, we ignore the hostmask. */
User *u = User::Find(mask, true);
if (u)
return "*!*@" + u->host;
size_t host = mask.find('@');
/* Determine whether we get a nick or a mask. */
if (host != Anope::string::npos)
{
size_t user = mask.find('!');
/* Check whether we have a nick too.. */
if (user != Anope::string::npos)
{
if (user > host)
/* this should never happen */
return "";
else
return mask;
}
else
/* We have [email protected] Add nick wildcard. */
return "*!" + mask;
}
/* We only got a nick.. */
return mask + "!*@*";
}
示例3: IsValid
bool ChannelModeKey::IsValid(Anope::string &value) const
{
if (!value.empty() && value.find(':') == Anope::string::npos && value.find(',') == Anope::string::npos)
return true;
return false;
}
示例4: Provider
MyRedisService(Module *c, const Anope::string &n, const Anope::string &h, int p, unsigned d) : Provider(c, n), host(h), port(p), db(d), sock(NULL), sub(NULL),
ti(c), in_transaction(false)
{
sock = new RedisSocket(this, host.find(':') != Anope::string::npos);
sock->Connect(host, port);
sub = new RedisSocket(this, host.find(':') != Anope::string::npos);
sub->Connect(host, port);
}
示例5: HasPriv
bool AccessGroup::HasPriv(const Anope::string &name) const
{
if (this->super_admin)
return true;
else if (!ci || ci->GetLevel(name) == ACCESS_INVALID)
return false;
/* Privileges prefixed with auto are understood to be given
* automatically. Sometimes founders want to not automatically
* obtain privileges, so we will let them */
bool auto_mode = !name.find("AUTO");
/* Only grant founder privilege if this isn't an auto mode or if they don't match any entries in this group */
if ((!auto_mode || this->empty()) && this->founder)
return true;
EventReturn MOD_RESULT;
FOREACH_RESULT(OnGroupCheckPriv, MOD_RESULT, (this, name));
if (MOD_RESULT != EVENT_CONTINUE)
return MOD_RESULT == EVENT_ALLOW;
for (unsigned i = this->size(); i > 0; --i)
{
ChanAccess *access = this->at(i - 1);
if (::HasPriv(*this, access, name))
return true;
}
return false;
}
示例6:
cidr::cidr(const Anope::string &ip, unsigned char len)
{
bool ipv6 = ip.find(':') != Anope::string::npos;
this->addr.pton(ipv6 ? AF_INET6 : AF_INET, ip);
this->cidr_ip = ip;
this->cidr_len = len;
}
示例7: Identify
void User::Identify(NickServ::Nick *na)
{
if (this->nick.equals_ci(na->GetNick()))
{
na->SetLastUsermask(this->GetIdent() + "@" + this->GetDisplayedHost());
na->SetLastRealhost(this->GetIdent() + "@" + this->host);
na->SetLastRealname(this->realname);
na->SetLastSeen(Anope::CurTime);
}
IRCD->SendLogin(this, na);
this->Login(na->GetAccount());
EventManager::Get()->Dispatch(&Event::NickIdentify::OnNickIdentify, this);
if (this->IsServicesOper())
{
Anope::string m = this->nc->o->GetType()->modes;
if (!m.empty())
{
this->SetModes(NULL, "%s", m.c_str());
this->SendMessage(Me, "Changing your usermodes to \002{0}\002", m.c_str());
UserMode *um = ModeManager::FindUserModeByName("OPER");
if (um && !this->HasMode("OPER") && m.find(um->mchar) != Anope::string::npos)
IRCD->SendOper(this);
}
if (IRCD->CanSetVHost && !this->nc->o->GetVhost().empty())
{
this->SendMessage(Me, "Changing your vhost to \002{0}\002", this->nc->o->GetVhost());
this->SetDisplayedHost(this->nc->o->GetVhost());
IRCD->SendVhost(this, "", this->nc->o->GetVhost());
}
}
}
示例8: CleanMail
/* strip dots from username, and remove anything after the first + */
Anope::string CleanMail(const Anope::string &email)
{
size_t host = email.find('@');
if (host == Anope::string::npos)
return email;
Anope::string username = email.substr(0, host);
username = username.replace_all_cs(".", "");
size_t sz = username.find('+');
if (sz != Anope::string::npos)
username = username.substr(0, sz);
Anope::string cleaned = username + email.substr(host);
logger.Debug("cleaned {0} to {1}", email, cleaned);
return cleaned;
}
示例9: if
MessageSource::MessageSource(const Anope::string &src) : source(src)
{
/* no source for incoming message is our uplink */
if (src.empty())
this->s = Servers::GetUplink();
else if (IRCD->RequiresID || src.find('.') != Anope::string::npos)
this->s = Server::Find(src);
if (this->s == NULL)
this->u = User::Find(src);
}
示例10: Send
void Send(Interface *i, const std::vector<std::pair<const char *, size_t> > &args)
{
if (!sock)
{
sock = new RedisSocket(this, host.find(':') != Anope::string::npos);
sock->Connect(host, port);
}
this->Send(sock, i, args);
}
示例11: myStrGetToken
/**
* Get the token
* @param str String to search in
* @param dilim Character to search for
* @param token_number the token number
* @return token
*/
Anope::string myStrGetToken(const Anope::string &str, char dilim, int token_number)
{
if (str.empty() || str.find(dilim) == Anope::string::npos)
return token_number ? "" : str;
Anope::string substring;
sepstream sep(str, dilim);
for (int i = 0; i < token_number + 1 && !sep.StreamEnd() && sep.GetToken(substring); ++i);
return substring;
}
示例12: Subscribe
void Subscribe(Interface *i, const Anope::string &ch) override
{
if (sub == NULL)
{
sub = new RedisSocket(this, host.find(':') != Anope::string::npos);
sub->Connect(host, port);
}
std::vector<Anope::string> args = { "SUBSCRIBE", ch };
this->SendCommand(sub, NULL, args);
sub->subinterfaces[ch] = i;
}
示例13: sep
NumberList::NumberList(const Anope::string &list, bool descending) : is_valid(true), desc(descending)
{
Anope::string error;
commasepstream sep(list);
Anope::string token;
sep.GetToken(token);
if (token.empty())
token = list;
do
{
size_t t = token.find('-');
if (t == Anope::string::npos)
{
unsigned num = convertTo<unsigned>(token, error, false);
if (error.empty())
numbers.insert(num);
else
{
if (!this->InvalidRange(list))
{
is_valid = false;
return;
}
}
}
else
{
Anope::string error2;
unsigned num1 = convertTo<unsigned>(token.substr(0, t), error, false);
unsigned num2 = convertTo<unsigned>(token.substr(t + 1), error2, false);
if (error.empty() && error2.empty())
{
for (unsigned i = num1; i <= num2; ++i)
numbers.insert(i);
}
else
{
if (!this->InvalidRange(list))
{
is_valid = false;
return;
}
}
}
} while (sep.GetToken(token));
}
示例14: MailValidate
/**
* Checks whether we have a valid, common e-mail address.
* This is NOT entirely RFC compliant, and won't be so, because I said
* *common* cases. ;) It is very unlikely that e-mail addresses that
* are really being used will fail the check.
*
* @param email Email to Validate
* @return bool
*/
bool MailValidate(const Anope::string &email)
{
bool has_period = false;
static char specials[] = {'(', ')', '<', '>', '@', ',', ';', ':', '\\', '\"', '[', ']', ' '};
if (email.empty())
return false;
Anope::string copy = email;
size_t at = copy.find('@');
if (at == Anope::string::npos)
return false;
Anope::string domain = copy.substr(at + 1);
copy = copy.substr(0, at);
/* Don't accept empty copy or domain. */
if (copy.empty() || domain.empty())
return false;
/* Check for forbidden characters in the name */
for (unsigned i = 0, end = copy.length(); i < end; ++i)
{
if (copy[i] <= 31 || copy[i] >= 127)
return false;
for (unsigned int j = 0; j < 13; ++j)
if (copy[i] == specials[j])
return false;
}
/* Check for forbidden characters in the domain */
for (unsigned i = 0, end = domain.length(); i < end; ++i)
{
if (domain[i] <= 31 || domain[i] >= 127)
return false;
for (unsigned int j = 0; j < 13; ++j)
if (domain[i] == specials[j])
return false;
if (domain[i] == '.')
{
if (!i || i == end - 1)
return false;
has_period = true;
}
}
return has_period;
}
示例15: nickIsServices
/**
* Is the given nick a network service
* @param nick to check
* @param int Check if botserv bots
* @return int
*/
bool nickIsServices(const Anope::string &tempnick, bool bot)
{
if (tempnick.empty())
return false;
Anope::string nick = tempnick;
size_t at = nick.find('@');
if (at != Anope::string::npos)
{
Anope::string servername = nick.substr(at + 1);
if (!servername.equals_ci(Config->ServerName))
return false;
nick = nick.substr(0, at);
}
BotInfo *bi = findbot(nick);
if (bi)
return bot ? true : bi->HasFlag(BI_CORE);
return false;
}