SF 3558085: Add formatter to MACAddress object

This commit is contained in:
Aleksandar Fabijanic
2012-08-17 04:07:18 +00:00
parent 84ca64e283
commit e7f2ade581
4 changed files with 32 additions and 6 deletions

View File

@@ -48,6 +48,8 @@
#include <ipifcons.h>
#endif
#include <cstring>
#include <iostream>
#include <iomanip>
using Poco::NumberFormatter;
@@ -55,6 +57,20 @@ using Poco::FastMutex;
using Poco::format;
std::ostream& operator<<(std::ostream& os, const Poco::Net::NetworkInterface::MACAddress& mac)
{
std::ios state(0);
state.copyfmt(os);
for (unsigned i = 0; i < mac.size(); ++i)
{
if (i > 0) os << Poco::Net::NetworkInterface::MAC_SEPARATOR;
os << std::hex << std::setw(2) << std::setfill('0') << (unsigned) mac[i];
}
os.copyfmt(state);
return os;
}
namespace Poco {
namespace Net {