generatorglukoff 11.07.2012 22:30 Досктоп

вот так просто и легко можно десериализовать xml:

auto root_node = doc.first_node("User");

char *jid,
*password;

if (!XMLPath::process(root_node,
[&](rapidxml::xml_node<> *node) → bool
{
return XMLPath::process(node, XMLNode{"Jid"}, XMLNode{0}, XMLValueRetrieve{jid}) &&
XMLPath::process(node, XMLNode{"Password"}, XMLNode{0}, XMLValueRetrieve{password}) &&
XMLPath::process(node, XMLNode{"Roster"},
[&](rapidxml::xml_node<> *node) → bool
{
result→rosterReserve(rapidxml::count_children(node));
for (auto it = node→first_node("Item"); it != 0; it = it→next_sibling("Item"))
{
char *jid,
*subscriptionStatusString;

if (!XMLPath::process(it, XMLAttributeWithResult{"jid", jid},
XMLAttributeWithResult{"subscription_status", subscriptionStatusString}))
{
return false;
}

RosterItem item;
item.setJid(Jid(jid, jid + strlen(jid)));
item.setSubscriptionStatus(toSubscriptionStatus(subscriptionStatusString));

result→addRosterItem(item);
}
return true;
});
}
))
{
return 0;
}

1. efrod 12.07.2012 01:22

атмта, пуги получ

Do you really want to delete ?