本文整理汇总了C++中anope::string::str方法的典型用法代码示例。如果您正苦于以下问题:C++ string::str方法的具体用法?C++ string::str怎么用?C++ string::str使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类anope::string
的用法示例。
在下文中一共展示了string::str方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Check
bool Check(User *u, XLine *x) override
{
if (x->regex)
{
Anope::string uh = u->GetIdent() + "@" + u->host, nuhr = u->nick + "!" + uh + "#" + u->realname;
return std::regex_match(uh.str(), *x->regex) || std::regex_match(nuhr.str(), *x->regex);
}
if (!x->GetNick().empty() && !Anope::Match(u->nick, x->GetNick()))
return false;
if (!x->GetUser().empty() && !Anope::Match(u->GetIdent(), x->GetUser()))
return false;
if (!x->GetReal().empty() && !Anope::Match(u->realname, x->GetReal()))
return false;
if (x->c && x->c->match(u->ip))
return true;
if (x->GetHost().empty() || Anope::Match(u->host, x->GetHost()) || Anope::Match(u->ip.addr(), x->GetHost()))
return true;
return false;
}
示例2: OnLoadDatabase
EventReturn OnLoadDatabase() override
{
const Anope::string &db_name = Anope::DataDir + "/" + Config->GetModule(this)->Get<Anope::string>("database", "anope.db");
std::fstream fd(db_name.c_str(), std::ios_base::in | std::ios_base::binary);
if (!fd.is_open())
{
Log(this) << "Unable to open " << db_name << " for reading!";
return EVENT_STOP;
}
Serialize::TypeBase *type = nullptr;
Serialize::Object *obj = nullptr;
for (Anope::string buf; std::getline(fd, buf.str());)
{
if (buf.find("OBJECT ") == 0)
{
Anope::string t = buf.substr(7);
if (obj)
Log(LOG_DEBUG) << "obj != null but got OBJECT";
if (type)
Log(LOG_DEBUG) << "type != null but got OBJECT";
type = Serialize::TypeBase::Find(t);
obj = nullptr;
}
else if (buf.find("ID ") == 0)
{
if (!type || obj)
continue;
try
{
Serialize::ID id = convertTo<Serialize::ID>(buf.substr(3));
obj = type->Require(id);
}
catch (const ConvertException &)
{
Log(LOG_DEBUG) << "Unable to parse object id " << buf.substr(3);
}
}
else if (buf.find("DATA ") == 0)
{
if (!type)
continue;
if (!obj)
obj = type->Create();
size_t sp = buf.find(' ', 5); // Skip DATA
if (sp == Anope::string::npos)
continue;
Anope::string key = buf.substr(5, sp - 5), value = buf.substr(sp + 1);
Serialize::FieldBase *field = type->GetField(key);
if (field)
field->UnserializeFromString(obj, value);
}
else if (buf.find("END") == 0)
{
type = nullptr;
obj = nullptr;
}
}
fd.close();
loaded = true;
return EVENT_STOP;
}
示例3: IsValid
bool ChannelModeParam::IsValid(Anope::string &value) const
{
return std::regex_search(value.str(), param_validation);
}