From: tho Date: Thu, 9 Jun 2011 15:49:59 +0000 (+0000) Subject: fixed right padding issue for several output members X-Git-Url: http://g0dil.de/git?a=commitdiff_plain;h=9ab6056a616342015eb35d6730d61c45412eec46;p=senf.git fixed right padding issue for several output members git-svn-id: https://svn.berlios.de/svnroot/repos/senf/trunk@1792 270642c3-0616-0410-b53a-bc976706d245 --- diff --git a/senf/Packets/DefaultBundle/EthernetPacket.cc b/senf/Packets/DefaultBundle/EthernetPacket.cc index b220729..290b7a5 100644 --- a/senf/Packets/DefaultBundle/EthernetPacket.cc +++ b/senf/Packets/DefaultBundle/EthernetPacket.cc @@ -85,7 +85,7 @@ prefix_ void senf::EthVLanPacketType::dump(packet p, std::ostream & os) << senf::fieldName("cfi") << p->cfi() << "\n" << senf::fieldName("vlan-ID") << p->vlanId() << "\n" << senf::fieldName("ethertype") - << " 0x" << std::hex << std::setw(4) << std::setfill('0') << p->type() << "\n"; + << " 0x" << std::hex << std::setw(4) << std::setfill('0') << std::right << p->type() << "\n"; } prefix_ void senf::EthVLanPacketType::finalize(packet p) diff --git a/senf/Packets/DefaultBundle/IPv4Packet.cc b/senf/Packets/DefaultBundle/IPv4Packet.cc index 7800b97..d9aa563 100644 --- a/senf/Packets/DefaultBundle/IPv4Packet.cc +++ b/senf/Packets/DefaultBundle/IPv4Packet.cc @@ -71,7 +71,7 @@ prefix_ void senf::IPv4PacketType::dump(packet p, std::ostream & os) << senf::fieldName("ttl") << unsigned(p->ttl()) << "\n" << senf::fieldName("protocol") << unsigned(p->protocol()) << "\n" << senf::fieldName("checksum") - << "0x" << std::hex << std::setw(4) << std::setfill('0') << p->checksum() << std::dec << "\n" + << "0x" << std::hex << std::setw(4) << std::setfill('0') << std::right << p->checksum() << std::dec << "\n" << senf::fieldName("source") << p->source() << "\n" << senf::fieldName("destination") << p->destination() << "\n"; } diff --git a/senf/Packets/DefaultBundle/IPv6Packet.cc b/senf/Packets/DefaultBundle/IPv6Packet.cc index b7e4dd7..dc688b1 100644 --- a/senf/Packets/DefaultBundle/IPv6Packet.cc +++ b/senf/Packets/DefaultBundle/IPv6Packet.cc @@ -46,9 +46,9 @@ prefix_ void senf::IPv6PacketType::dump(packet p, std::ostream & os) os << "Internet protocol Version 6:\n" << senf::fieldName("version") << unsigned(p->version()) << "\n" << senf::fieldName("traffic class") - << "0x" << std::hex << std::setw(2) << std::setfill('0') << unsigned(p->trafficClass()) << "\n" + << "0x" << std::hex << std::setw(2) << std::setfill('0') << std::right << unsigned(p->trafficClass()) << "\n" << senf::fieldName("flow label") - << "0x" << std::hex << std::setw(5) << std::setfill('0') << unsigned(p->flowLabel()) << "\n" + << "0x" << std::hex << std::setw(5) << std::setfill('0') << std::right << unsigned(p->flowLabel()) << "\n" << senf::fieldName("payload length") << std::dec << unsigned(p->length()) << "\n" << senf::fieldName("next header") << unsigned(p->nextHeader()) << "\n" << senf::fieldName("hop limit") << unsigned(p->hopLimit()) << "\n" diff --git a/senf/Packets/DefaultBundle/LlcSnapPacket.cc b/senf/Packets/DefaultBundle/LlcSnapPacket.cc index 1afc7ec..534fdfe 100644 --- a/senf/Packets/DefaultBundle/LlcSnapPacket.cc +++ b/senf/Packets/DefaultBundle/LlcSnapPacket.cc @@ -37,7 +37,7 @@ prefix_ void senf::LlcSnapPacketType::dump(packet p, std::ostream & os) { boost::io::ios_all_saver ias(os); os << "LLC/SNAP:\n" - << std::hex << std::setfill('0') + << std::hex << std::setfill('0') << std::right << " LLC\n" << senf::fieldName(" dsap") << "0x" << unsigned(p->dsap()) << "\n" << senf::fieldName(" ssap") << "0x" << unsigned(p->ssap()) << "\n" diff --git a/senf/Packets/DefaultBundle/TCPPacket.cc b/senf/Packets/DefaultBundle/TCPPacket.cc index 02476f4..1737b72 100644 --- a/senf/Packets/DefaultBundle/TCPPacket.cc +++ b/senf/Packets/DefaultBundle/TCPPacket.cc @@ -124,7 +124,7 @@ prefix_ void senf::TCPPacketType::dump(packet p, std::ostream & os) << senf::fieldName("fin flag") << p->finf() << "\n" << senf::fieldName("window size") << p->window() << "\n" << senf::fieldName("checksum") - << "0x" << std::hex << std::setw(4) << std::setfill('0') << p->checksum() << "\n" + << "0x" << std::hex << std::setw(4) << std::setfill('0') << std::right << p->checksum() << "\n" << senf::fieldName("urgent pointer") << p->urgentpointer() << "\n"; } diff --git a/senf/Packets/DefaultBundle/UDPPacket.cc b/senf/Packets/DefaultBundle/UDPPacket.cc index 6a9f03b..499ac92 100644 --- a/senf/Packets/DefaultBundle/UDPPacket.cc +++ b/senf/Packets/DefaultBundle/UDPPacket.cc @@ -101,7 +101,7 @@ prefix_ void senf::UDPPacketType::dump(packet p, std::ostream & os) << senf::fieldName("dest port") << p->destination() << "\n" << senf::fieldName("length") << p->length() << "\n" << senf::fieldName("checksum") - << "0x" << std::hex << std::setw(4) << std::setfill('0') << p->checksum() << "\n"; + << "0x" << std::hex << std::setw(4) << std::setfill('0') << std::right << p->checksum() << "\n"; } prefix_ void senf::UDPPacketType::finalize(packet p) diff --git a/senf/Socket/Protocols/Raw/EUI64.cc b/senf/Socket/Protocols/Raw/EUI64.cc index f3f3d68..111727b 100644 --- a/senf/Socket/Protocols/Raw/EUI64.cc +++ b/senf/Socket/Protocols/Raw/EUI64.cc @@ -47,7 +47,7 @@ prefix_ senf::EUI64 senf::EUI64::from_string(std::string const & s) prefix_ std::ostream & senf::operator<<(std::ostream & os, EUI64 const & eui) { boost::io::ios_all_saver ias(os); - os << std::hex << std::setfill('0') + os << std::hex << std::setfill('0') << std::right << std::setw(2) << unsigned(eui[0]) << ":" << std::setw(2) << unsigned(eui[1]) << ":" << std::setw(2) << unsigned(eui[2]) << ":" diff --git a/senf/Socket/Protocols/Raw/EUI64.test.cc b/senf/Socket/Protocols/Raw/EUI64.test.cc index 316109e..9d12430 100644 --- a/senf/Socket/Protocols/Raw/EUI64.test.cc +++ b/senf/Socket/Protocols/Raw/EUI64.test.cc @@ -85,6 +85,16 @@ SENF_AUTO_UNIT_TEST(eui64) } } +SENF_AUTO_UNIT_TEST(eui64_fillRight) +{ + std::string eui64Str ("01:02:03:ff-fe:04:05:06"); + senf::EUI64 eui64 (senf::EUI64::from_string( eui64Str)); + + std::stringstream ss; + ss << std::left << eui64; + BOOST_CHECK_EQUAL( ss.str(), eui64Str); +} + //-///////////////////////////////////////////////////////////////////////////////////////////////// #undef prefix_ diff --git a/senf/Socket/Protocols/Raw/MACAddress.cc b/senf/Socket/Protocols/Raw/MACAddress.cc index 46eb7aa..dcc4e7e 100644 --- a/senf/Socket/Protocols/Raw/MACAddress.cc +++ b/senf/Socket/Protocols/Raw/MACAddress.cc @@ -71,7 +71,7 @@ senf::MACAddress const senf::MACAddress::None; prefix_ std::ostream & senf::operator<<(std::ostream & os, MACAddress const & mac) { boost::io::ios_all_saver ias (os); - os << std::hex << std::setfill('0'); + os << std::hex << std::setfill('0') << std::right; for (MACAddress::const_iterator i (mac.begin()); i != mac.end(); ++i) { if (i != mac.begin()) os << ':'; diff --git a/senf/Utils/Logger/LogFormat.cc b/senf/Utils/Logger/LogFormat.cc index b4d2d49..c61eb2c 100644 --- a/senf/Utils/Logger/LogFormat.cc +++ b/senf/Utils/Logger/LogFormat.cc @@ -126,10 +126,9 @@ prefix_ std::string senf::log::detail::LogFormat::prefix(time_type timestamp, if (noformat_) { if (timeBase_ == -1) timeBase_ = timestamp; time_type delta (timestamp - timeBase_); - datestream_ << std::setfill('0') << std::setw(10) - << (delta / 1000000000ll) << '.' - << std::setfill('0') << std::setw(9) - << (delta % 1000000000ll); + datestream_ << std::setfill('0') << std::right + << std::setw(10) << (delta / 1000000000ll) << '.' + << std::setw(9) << (delta % 1000000000ll); } else datestream_ << senf::ClockService::abstime(timestamp); diff --git a/senf/Utils/hexdump.cc b/senf/Utils/hexdump.cc index c7f43bf..817c11a 100644 --- a/senf/Utils/hexdump.cc +++ b/senf/Utils/hexdump.cc @@ -42,7 +42,7 @@ prefix_ void senf::detail::HexDumper::operator()(unsigned char ch) ascii_ = ""; } os_ << " " - << std::hex << std::setw(4) << std::setfill('0') + << std::hex << std::setw(4) << std::setfill('0') << std::right << offset_ << ' '; } else if ((offset_ % block_size_) == block_size_/2) { os_ << " ";