From: tho Date: Tue, 10 Feb 2009 16:18:05 +0000 (+0000) Subject: removed .toString() members from address classes; use senf::str() instead X-Git-Url: http://g0dil.de/git?a=commitdiff_plain;h=922dffd5b5cba475669b9a2d2504bededb46a957;p=senf.git removed .toString() members from address classes; use senf::str() instead git-svn-id: https://svn.berlios.de/svnroot/repos/senf/trunk@1115 270642c3-0616-0410-b53a-bc976706d245 --- diff --git a/Socket/Protocols/INet/INet4Address.cc b/Socket/Protocols/INet/INet4Address.cc index d83c034..33720d3 100644 --- a/Socket/Protocols/INet/INet4Address.cc +++ b/Socket/Protocols/INet/INet4Address.cc @@ -89,15 +89,6 @@ prefix_ senf::INet4Address senf::INet4Address::from_string(std::string const & s reinterpret_cast(*(ent->h_addr_list))->s_addr); } -prefix_ std::string senf::INet4Address::toString() const { - char buffer[4*4]; - ::in_addr ina; - ina.s_addr = (*this).inaddr(); - ::inet_ntop(AF_INET, & ina , buffer, sizeof(buffer)); - buffer[sizeof(buffer)-1] = 0; - return buffer; -} - prefix_ bool senf::INet4Address::local() const { diff --git a/Socket/Protocols/INet/INet4Address.hh b/Socket/Protocols/INet/INet4Address.hh index b41369a..4b5f3ec 100644 --- a/Socket/Protocols/INet/INet4Address.hh +++ b/Socket/Protocols/INet/INet4Address.hh @@ -159,9 +159,6 @@ namespace senf { /**< This member returns the address as an integer number in host byte order. This representation allows simple network math operations. */ - std::string toString() const; - ///< get the string representation of this INet4Address - ////@} private: diff --git a/Socket/Protocols/INet/INet6Address.cc b/Socket/Protocols/INet/INet6Address.cc index 9aa5238..94afd47 100644 --- a/Socket/Protocols/INet/INet6Address.cc +++ b/Socket/Protocols/INet/INet6Address.cc @@ -91,17 +91,14 @@ prefix_ in6_addr senf:: INet6Address::toin6_addr() const { return ina; } -prefix_ std::string senf::INet6Address::toString() const { - char buffer[5*8]; - ::in6_addr ina = (*this).toin6_addr(); - ::inet_ntop(AF_INET6, & ina , buffer, sizeof(buffer)); - buffer[sizeof(buffer)-1] = 0; - return buffer; -} - prefix_ std::ostream & senf::operator<<(std::ostream & os, INet6Address const & addr) { - os << addr.toString(); + ::in6_addr ina; + char buffer[5*8]; + std::copy(addr.begin(),addr.end(),&ina.s6_addr[0]); + ::inet_ntop(AF_INET6,&ina,buffer,sizeof(buffer)); + buffer[sizeof(buffer)-1] = 0; + os << buffer; return os; } @@ -147,7 +144,7 @@ prefix_ senf::INet6Network::INet6Network(std::string s) #undef prefix_ //#include "INet6Address.mpp" - + // Local Variables: // mode: c++ // fill-column: 100 diff --git a/Socket/Protocols/INet/INet6Address.hh b/Socket/Protocols/INet/INet6Address.hh index e2bad76..a959837 100644 --- a/Socket/Protocols/INet/INet6Address.hh +++ b/Socket/Protocols/INet/INet6Address.hh @@ -203,11 +203,7 @@ namespace senf { \par INet4 compatible INet6 addresses are not directly supported, they are deprecated in the RFC. */ - std::string toString() const; - ///< get the string representation of this INet6Address - in6_addr toin6_addr() const; - ///< get the linux in6_addr struct (convinience only) - + in6_addr toin6_addr() const; ///< get the linux in6_addr struct (convinience only) ///@} /////////////////////////////////////////////////////////////////////////// @@ -393,7 +389,7 @@ namespace senf { #include "INet6Address.cti" #endif - + // Local Variables: // mode: c++ // fill-column: 100 diff --git a/Socket/Protocols/Raw/MACAddress.cc b/Socket/Protocols/Raw/MACAddress.cc index 6c36a47..e8fb19b 100644 --- a/Socket/Protocols/Raw/MACAddress.cc +++ b/Socket/Protocols/Raw/MACAddress.cc @@ -57,7 +57,7 @@ namespace { else throw senf::AddressSyntaxException(); } - + template boost::uint8_t hexToByte(Range const & range) { @@ -107,11 +107,6 @@ prefix_ senf::MACAddress senf::MACAddress::from_eui64(boost::uint64_t v) senf::MACAddress const senf::MACAddress::Broadcast = senf::MACAddress(0xFFFFFFFFFFFFull); senf::MACAddress const senf::MACAddress::None; -prefix_ std::string senf::MACAddress::toString() const { - std::ostringstream tmp; - tmp << (*this); - return tmp.str(); -} /////////////////////////////////////////////////////////////////////////// // namespace members @@ -146,7 +141,7 @@ prefix_ std::istream & senf::operator>>(std::istream & is, MACAddress & mac) #undef prefix_ //#include "MACAddress.mpp" - + // Local Variables: // mode: c++ // fill-column: 100 diff --git a/Socket/Protocols/Raw/MACAddress.hh b/Socket/Protocols/Raw/MACAddress.hh index 00030c6..64049dd 100644 --- a/Socket/Protocols/Raw/MACAddress.hh +++ b/Socket/Protocols/Raw/MACAddress.hh @@ -42,7 +42,7 @@ namespace senf { /** \brief Ethernet MAC address - + The Ethernet MAC is modelled as a fixed-size container/sequence of 6 bytes. The following statements all create the same MAC address 00:1A:2B:3C:4D:5F @@ -85,7 +85,7 @@ namespace senf { \ingroup addr_group */ struct MACAddress - : public boost::array, + : public boost::array, public comparable_safe_bool { static MACAddress const Broadcast; ///< The broadcast address @@ -103,7 +103,7 @@ namespace senf { accepted as a delimiter. \throws AddressSyntaxException */ - template + template static MACAddress from_data(InputIterator i); ///< Construct address from raw data /**< Copies the data from \a i into the MAC address. @@ -126,12 +126,9 @@ namespace senf { boost::uint32_t oui() const; ///< Return first 3 bytes of the address boost::uint32_t nic() const; ///< Return last 3 bytes of the address - - boost::uint64_t eui64() const; ///< Build EUI-64 from the MAC address - boost::uint64_t uint64() const; ///< Return MAC address as uint64 value - - std::string toString() const; ///< Return string representation of MAC address like 12:34:56:78:90:ab + boost::uint64_t eui64() const; ///< Build EUI-64 from the MAC address + boost::uint64_t uint64() const; ///< Return MAC address as uint64 value }; /** \brief Output MAC instance as it's string representation @@ -153,7 +150,7 @@ namespace senf { //#include "MACAddress.cti" #endif - + // Local Variables: // mode: c++ // fill-column: 100