本文整理汇总了C++中model::notify_list方法的典型用法代码示例。如果您正苦于以下问题:C++ model::notify_list方法的具体用法?C++ model::notify_list怎么用?C++ model::notify_list使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类model
的用法示例。
在下文中一共展示了model::notify_list方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: read_notify_list
void read_notify_list(model& aModel, std::function<bool()> aErrorFunction)
{
notify& theNotifyList = aModel.notify_list();
neolib::xml xmlNotifyList(true);
std::ifstream input((aModel.root_path() + "notify_list.xml").c_str());
xmlNotifyList.read(input);
if (xmlNotifyList.error() && aErrorFunction && aErrorFunction())
{
theNotifyList.entries().clear();
write_notify_list(aModel);
return;
}
theNotifyList.loading(true);
for (neolib::xml::element::const_iterator i = xmlNotifyList.root().begin(); i != xmlNotifyList.root().end(); ++i)
{
if (i->name() == "entry")
{
notify_entry_ptr e(new notify_entry);
for (neolib::xml::element::const_iterator j = i->begin(); j != i->end(); ++j)
{
if (j->name() == "user")
e->user() = user(j->attribute_value("value"), casemapping::rfc1459, false, true);
if (j->name() == "server_network" || j->name() == "server_group")
e->server().first = j->attribute_value("value");
if (j->name() == "server_name")
e->server().second = j->attribute_value("value");
if (j->name() == "channel")
e->channel() = j->attribute_value("value");
if (j->name() == "action")
e->action() = static_cast<notify_entry::action_e>(neolib::string_to_integer<char>(j->attribute_value("value")));
if (j->name() == "event")
e->event() = static_cast<notify_entry::event_e>(neolib::string_to_integer<char>(j->attribute_value("value")));
if (j->name() == "data")
e->data() = j->attribute_value("value");
}
if (e->user().nick_name().empty())
e->user().nick_name() = "*";
if (e->channel().empty())
e->channel() = "*";
theNotifyList.entries().push_back(e);
}
}
theNotifyList.loading(false);
}
示例2: write_notify_list
void write_notify_list(const model& aModel)
{
const notify& theNotifyList = aModel.notify_list();
neolib::xml xmlNotifyList(true);
xmlNotifyList.root().name() = "notify_list";
for (notify::container_type::const_iterator i = theNotifyList.entries().begin(); i != theNotifyList.entries().end(); ++i)
{
const notify_entry& entry = **i;
neolib::xml::element& xmlEntry = xmlNotifyList.append(xmlNotifyList.root(), "entry");
xmlNotifyList.append(xmlEntry, "user").set_attribute("value", entry.user().msgto_form());
xmlNotifyList.append(xmlEntry, "server_network").set_attribute("value", entry.server().first);
xmlNotifyList.append(xmlEntry, "server_name").set_attribute("value", entry.server().second);
xmlNotifyList.append(xmlEntry, "channel").set_attribute("value", entry.channel());
xmlNotifyList.append(xmlEntry, "action").set_attribute("value", neolib::integer_to_string<char>(entry.action()));
xmlNotifyList.append(xmlEntry, "event").set_attribute("value", neolib::integer_to_string<char>(entry.event()));
xmlNotifyList.append(xmlEntry, "data").set_attribute("value", entry.data());
}
std::ofstream output((aModel.root_path() + "notify_list.xml").c_str());
xmlNotifyList.write(output);
}