本文整理汇总了C++中IpAddress::set_from_string方法的典型用法代码示例。如果您正苦于以下问题:C++ IpAddress::set_from_string方法的具体用法?C++ IpAddress::set_from_string怎么用?C++ IpAddress::set_from_string使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IpAddress
的用法示例。
在下文中一共展示了IpAddress::set_from_string方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: deserialize
void HostContacts::deserialize(NetworkInterface *iface, GenericHost *h, json_object *o) {
json_object *obj;
IpAddress ip;
if(!o) return;
/* Reset all */
memset(clientContacts, 0, sizeof(clientContacts));
memset(serverContacts, 0, sizeof(serverContacts));
if(json_object_object_get_ex(o, "client", &obj)) {
struct json_object_iterator it = json_object_iter_begin(obj);
struct json_object_iterator itEnd = json_object_iter_end(obj);
while (!json_object_iter_equal(&it, &itEnd)) {
char *key = (char*)json_object_iter_peek_name(&it);
int value = json_object_get_int(json_object_iter_peek_value(&it));
ip.set_from_string(key);
incrContact(iface, h->get_host_serial(), &ip, true /* client */, value, HOST_FAMILY_ID, false);
//ntop->getTrace()->traceEvent(TRACE_WARNING, "%s=%d", key, value);
json_object_iter_next(&it);
}
}
if(json_object_object_get_ex(o, "server", &obj)) {
struct json_object_iterator it = json_object_iter_begin(obj);
struct json_object_iterator itEnd = json_object_iter_end(obj);
while (!json_object_iter_equal(&it, &itEnd)) {
char *key = (char*)json_object_iter_peek_name(&it);
int value = json_object_get_int(json_object_iter_peek_value(&it));
ip.set_from_string(key);
incrContact(iface, h->get_host_serial(), &ip, false /* server */, value, HOST_FAMILY_ID, false);
// ntop->getTrace()->traceEvent(TRACE_WARNING, "%s=%d", key, value);
json_object_iter_next(&it);
}
}
}