本文整理汇总了C++中IP::ip方法的典型用法代码示例。如果您正苦于以下问题:C++ IP::ip方法的具体用法?C++ IP::ip怎么用?C++ IP::ip使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IP
的用法示例。
在下文中一共展示了IP::ip方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: get_ip
unsigned long get_ip(Data &p)
{
IP *ip = (IP*)p.ptr;
if (ip)
return ip->ip();
return 0;
}
示例2: start_resolve
void IPResolver::start_resolve()
{
if (resolver && resolver->isWorking()) return;
if (queue.empty())
return;
IP *ip = *queue.begin();
m_addr = ip->ip();
struct in_addr inaddr;
inaddr.s_addr = m_addr;
log(L_DEBUG, "start resolve %s", inet_ntoa(inaddr));
#if COMPAT_QT_VERSION >= 0x030000
if (resolver)
delete resolver;
resolver = new QDns(QHostAddress(htonl(m_addr)), QDns::Ptr);
connect(resolver, SIGNAL(resultsReady()), this, SLOT(resolve_ready()));
#else
resolver->setLabel(QHostAddress(htonl(m_addr)));
#endif
}
示例3: save_data
EXPORT string save_data(const DataDef *def, void *data)
{
string res;
unsigned offs = 0;
for (; def->name; def++){
string value;
bool bSave = false;
unsigned i;
if (def->type == DATA_STRUCT){
string s = save_data((DataDef*)(def->def_value), ((char*)data) + offs);
if (s.length()){
if (res.length())
res += "\n";
res += s;
}
}else if (*def->name){
switch (def->type){
case DATA_IP:{
IP *p = *((IP**)(((char*)data) + offs));
if (p && p->ip()){
struct in_addr inaddr;
inaddr.s_addr = p->ip();
value = inet_ntoa(inaddr);
const char *host = p->host();
if (host && *host){
value += ",";
value += host;
}
bSave = true;
}
break;
}
case DATA_STRLIST:{
STRING_MAP *p = *((STRING_MAP**)(((char*)data) + offs));
if (p){
for (STRING_MAP::iterator it = p->begin(); it != p->end(); ++it){
if (res.length())
res += "\n";
res += def->name;
res += "=";
res += number((*it).first);
res += ",";
res += quoteString((*it).second.c_str());
}
}
break;
}
case DATA_UTFLIST:{
STRING_MAP *p = *((STRING_MAP**)(((char*)data) + offs));
if (p){
for (STRING_MAP::iterator it = p->begin(); it != p->end(); ++it){
if (res.length())
res += "\n";
res += def->name;
res += "=";
res += number((*it).first);
res += ",";
QString s = QString::fromUtf8((*it).second.c_str());
QCString ls = s.local8Bit();
if (QString::fromLocal8Bit(ls) == s){
res += quoteString((const char*)ls);
}else{
res += quoteString((const char*)(s.utf8()));
res += "u";
}
}
}
break;
}
case DATA_STRING:{
char **p = (char**)(((char*)data) + offs);
for (i = 0; i < def->n_values; i++, p++){
if (value.length())
value += ",";
if (def->def_value){
if ((*p == NULL) || strcmp(*p, (char*)(def->def_value))){
value += quoteString(*p);
bSave = true;
}
}else{
if ((*p != NULL) && **p){
value += quoteString(*p);
bSave = true;
}
}
}
break;
}
case DATA_UTF:{
char **p = (char**)(((char*)data) + offs);
for (i = 0; i < def->n_values; i++, p++){
if (value.length())
value += ",";
QString s;
if (*p != NULL)
s = QString::fromUtf8(*p);
if (def->def_value){
if (s != i18n((const char*)(def->def_value)))
bSave = true;
}else{
//.........这里部分代码省略.........