本文整理汇总了C++中AddressList::empty方法的典型用法代码示例。如果您正苦于以下问题:C++ AddressList::empty方法的具体用法?C++ AddressList::empty怎么用?C++ AddressList::empty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AddressList
的用法示例。
在下文中一共展示了AddressList::empty方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: hostDnsServers
int VBoxNetDhcp::hostDnsServers(const ComHostPtr& host,
const RTNETADDRIPV4& networkid,
const AddressToOffsetMapping& mapping,
AddressList& servers)
{
ComBstrArray strs;
HRESULT hrc = host->COMGETTER(NameServers)(ComSafeArrayAsOutParam(strs));
if (FAILED(hrc))
return VERR_NOT_FOUND;
/*
* Recent fashion is to run dnsmasq on 127.0.1.1 which we
* currently can't map. If that's the only nameserver we've got,
* we need to use DNS proxy for VMs to reach it.
*/
bool fUnmappedLoopback = false;
for (size_t i = 0; i < strs.size(); ++i)
{
RTNETADDRIPV4 addr;
int rc;
rc = RTNetStrToIPv4Addr(com::Utf8Str(strs[i]).c_str(), &addr);
if (RT_FAILURE(rc))
continue;
if (addr.au8[0] == 127)
{
AddressToOffsetMapping::const_iterator remap(mapping.find(addr));
if (remap != mapping.end())
{
int offset = remap->second;
addr.u = RT_H2N_U32(RT_N2H_U32(networkid.u) + offset);
}
else
{
fUnmappedLoopback = true;
continue;
}
}
servers.push_back(addr);
}
if (servers.empty() && fUnmappedLoopback)
{
RTNETADDRIPV4 proxy;
proxy.u = networkid.u | RT_H2N_U32_C(1U);
servers.push_back(proxy);
}
return VINF_SUCCESS;
}