本文整理汇总了C++中networkinterface::Map::empty方法的典型用法代码示例。如果您正苦于以下问题:C++ Map::empty方法的具体用法?C++ Map::empty怎么用?C++ Map::empty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类networkinterface::Map
的用法示例。
在下文中一共展示了Map::empty方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: testListMapConformance
void NetworkInterfaceTest::testListMapConformance()
{
NetworkInterface::Map m = NetworkInterface::map(false, false);
assert (!m.empty());
NetworkInterface::List l = NetworkInterface::list(false, false);
assert (!l.empty());
int counter = 0;
NetworkInterface::Map::const_iterator mapIt = m.begin();
NetworkInterface::List::const_iterator listIt = l.begin();
for (; mapIt != m.end(); ++mapIt)
{
NetworkInterface::MACAddress mac(mapIt->second.macAddress());
typedef NetworkInterface::AddressList List;
const List& ipList = mapIt->second.addressList();
List::const_iterator ipIt = ipList.begin();
List::const_iterator ipEnd = ipList.end();
for (; ipIt != ipEnd; ++ipIt, ++counter, ++listIt)
{
NetworkInterface::MACAddress lmac = listIt->macAddress();
assert (lmac == mac);
if (listIt == l.end()) fail ("wrong number of list items");
}
}
assert (counter == l.size());
}
示例2: testMapUpOnly
void NetworkInterfaceTest::testMapUpOnly()
{
NetworkInterface::Map m = NetworkInterface::map(false, true);
assert (!m.empty());
for (NetworkInterface::Map::const_iterator it = m.begin(); it != m.end(); ++it)
{
assert(it->second.isUp());
}
}
示例3: testMapIpOnly
void NetworkInterfaceTest::testMapIpOnly()
{
NetworkInterface::Map m = NetworkInterface::map(true, false);
assert (!m.empty());
for (NetworkInterface::Map::const_iterator it = m.begin(); it != m.end(); ++it)
{
assert(it->second.supportsIPv4() || it->second.supportsIPv6());
}
}
示例4: testMapIpOnly
void NetworkInterfaceTest::testMapIpOnly()
{
NetworkInterface::Map m = NetworkInterface::map(true, false);
assert (!m.empty());
std::cout << std::endl;
for (NetworkInterface::Map::const_iterator it = m.begin(); it != m.end(); ++it)
{
assert(it->second.supportsIPv4() || it->second.supportsIPv6());
std::cout << "Interface: (" << it->second.index() << ")" << std::endl;
std::cout << "Address: " << it->second.address() << std::endl;
NetworkInterface::MACAddress mac(it->second.macAddress());
if (!mac.empty() && (it->second.type() != NetworkInterface::NI_TYPE_SOFTWARE_LOOPBACK))
std::cout << "MAC Address:" << mac << std::endl;
}
}
示例5: testMap
void NetworkInterfaceTest::testMap()
{
NetworkInterface::Map m = NetworkInterface::map(false, false);
assert (!m.empty());
for (NetworkInterface::Map::const_iterator it = m.begin(); it != m.end(); ++it)
{
std::cout << std::endl << "=============" << std::endl;
std::cout << "Index: " << it->second.index() << std::endl;
std::cout << "Name: " << it->second.name() << std::endl;
std::cout << "DisplayName: " << it->second.displayName() << std::endl;
std::cout << "Status: " << (it->second.isUp() ? "Up" : "Down") << std::endl;
NetworkInterface::MACAddress mac(it->second.macAddress());
if (!mac.empty() && (it->second.type() != NetworkInterface::NI_TYPE_SOFTWARE_LOOPBACK))
std::cout << "MAC Address: (" << it->second.type() << ") " << mac << std::endl;
typedef NetworkInterface::AddressList List;
const List& ipList = it->second.addressList();
List::const_iterator ipIt = ipList.begin();
List::const_iterator ipEnd = ipList.end();
for (int counter = 0; ipIt != ipEnd; ++ipIt, ++counter)
{
std::cout << std::endl << "----------" << std::endl;
std::cout << "Address " << counter << std::endl;
std::cout << "----------" << std::endl;
std::cout << "Address: " << ipIt->get<NetworkInterface::IP_ADDRESS>() << std::endl;
IPAddress addr = ipIt->get<NetworkInterface::SUBNET_MASK>();
if (!addr.isWildcard()) std::cout << "Subnet: " << addr << " (/" << addr.prefixLength() << ")" << std::endl;
addr = ipIt->get<NetworkInterface::BROADCAST_ADDRESS>();
if (!addr.isWildcard()) std::cout << "Broadcast: " << addr << std::endl;
}
std::cout << "=============" << std::endl << std::endl;
}
}