fixed right padding issue for several output members
tho [Thu, 9 Jun 2011 15:49:59 +0000 (15:49 +0000)]
git-svn-id: https://svn.berlios.de/svnroot/repos/senf/trunk@1792 270642c3-0616-0410-b53a-bc976706d245

senf/Packets/DefaultBundle/EthernetPacket.cc
senf/Packets/DefaultBundle/IPv4Packet.cc
senf/Packets/DefaultBundle/IPv6Packet.cc
senf/Packets/DefaultBundle/LlcSnapPacket.cc
senf/Packets/DefaultBundle/TCPPacket.cc
senf/Packets/DefaultBundle/UDPPacket.cc
senf/Socket/Protocols/Raw/EUI64.cc
senf/Socket/Protocols/Raw/EUI64.test.cc
senf/Socket/Protocols/Raw/MACAddress.cc
senf/Utils/Logger/LogFormat.cc
senf/Utils/hexdump.cc

index b220729..290b7a5 100644 (file)
@@ -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)
index 7800b97..d9aa563 100644 (file)
@@ -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";
 }
index b7e4dd7..dc688b1 100644 (file)
@@ -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"
index 1afc7ec..534fdfe 100644 (file)
@@ -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"
index 02476f4..1737b72 100644 (file)
@@ -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";
 }
 
index 6a9f03b..499ac92 100644 (file)
@@ -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)
index f3f3d68..111727b 100644 (file)
@@ -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]) << ":"
index 316109e..9d12430 100644 (file)
@@ -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_
 
index 46eb7aa..dcc4e7e 100644 (file)
@@ -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 << ':';
index b4d2d49..c61eb2c 100644 (file)
@@ -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);
index c7f43bf..817c11a 100644 (file)
@@ -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_ << " ";