本文整理汇总了C++中AStringVector::emplace_back方法的典型用法代码示例。如果您正苦于以下问题:C++ AStringVector::emplace_back方法的具体用法?C++ AStringVector::emplace_back怎么用?C++ AStringVector::emplace_back使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AStringVector
的用法示例。
在下文中一共展示了AStringVector::emplace_back方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: EnumLocalIPAddresses
AStringVector cNetwork::EnumLocalIPAddresses(void)
{
AStringVector res;
#ifdef _WIN32
// Query the OS for all adapters' addresses:
char buffer[64 KiB]; // A buffer backing the address list
PIP_ADAPTER_ADDRESSES pAddresses = reinterpret_cast<PIP_ADAPTER_ADDRESSES>(&buffer);
ULONG outBufLen = sizeof(buffer);
DWORD dwRetVal = GetAdaptersAddresses(
AF_UNSPEC,
GAA_FLAG_SKIP_ANYCAST | GAA_FLAG_SKIP_MULTICAST | GAA_FLAG_SKIP_DNS_SERVER | GAA_FLAG_SKIP_FRIENDLY_NAME, nullptr,
pAddresses, &outBufLen
);
if (dwRetVal != ERROR_SUCCESS)
{
LOG("GetAdaptersAddresses() failed: %u", dwRetVal);
return res;
}
// Enumerate all active adapters
for (auto pCurrAddresses = pAddresses; pCurrAddresses != nullptr; pCurrAddresses = pCurrAddresses->Next)
{
if (pCurrAddresses->OperStatus != IfOperStatusUp)
{
// Adapter not active, skip it:
continue;
}
// Collect all IP addresses on this adapter:
for (auto pUnicast = pCurrAddresses->FirstUnicastAddress; pUnicast != nullptr; pUnicast = pUnicast->Next)
{
auto Address = PrintAddress(pUnicast->Address);
if (!Address.empty())
{
res.push_back(Address);
}
} // for pUnicast
} // for pCurrAddresses
#else // _WIN32
struct ifaddrs * ifAddrStruct = nullptr;
getifaddrs(&ifAddrStruct);
for (auto ifa = ifAddrStruct; ifa != nullptr; ifa = ifa->ifa_next)
{
if (ifa->ifa_addr == nullptr)
{
continue;
}
auto Address = PrintAddress(ifa);
if (!Address.empty())
{
res.emplace_back(Address);
}
}
if (ifAddrStruct != nullptr)
{
freeifaddrs(ifAddrStruct);
}
#endif // else _WIN32
return res;
}