Socket/Protocols/Raw: added MACAddress input streaming
[senf.git] / Socket / Protocols / Raw / MACAddress.hh
index de52a30..00030c6 100644 (file)
@@ -23,8 +23,8 @@
 /** \file
     \brief MACAddress public header */
 
-#ifndef HH_MACAddress_
-#define HH_MACAddress_ 1
+#ifndef HH_SENF_Socket_Protocols_Raw_MACAddress_
+#define HH_SENF_Socket_Protocols_Raw_MACAddress_ 1
 
 // Custom includes
 #include <iostream>
@@ -48,7 +48,7 @@ namespace senf {
         The following statements all create the same MAC address <code>00:1A:2B:3C:4D:5F</code>
         \code
         // Used to construct constant MAC addresses
-        MACAddress(0x001A2B3C4D5Flu)
+        MACAddress(0x001A2B3C4D5Full)
 
         // Construct a MAC address from it's string representation:
         MACAddress::from_string("00:1a:2b:3c:4d:5f")   // case is ignored
@@ -62,19 +62,12 @@ namespace senf {
 
         // Construct a MAC from the EUID64 as used by INet6 interfaces.  The eui64 will come from an
         // INet6 address:
-        MACAddress::from_eui64(0x001A2BFFFE3C4D5Ful)
+        MACAddress::from_eui64(0x001A2BFFFE3C4D5Full)
         MACAddress::from_eui64(
             INet6Address(0x2001u,0xDB8u,0x1u,0x0u,0x001Au,0x2BFFu,0xFE3Cu,0x3D5Fu).id())
         \endcode
 
-        Since MACAddress is based on \c boo Ziel, aber nur ein paar davon sind standardkomform.
-
-Der aktuelle C++ Standard unterstützt drei verschiedene Möglichkeiten eine Zahl in einen String umzuwandeln. Diese Möglichkeiten sind:
-
-    * sprintf
-    * std::strstream
-    * std::stringstream
-        st::array, you can access the raw data bytes of the
+        Since MACAddress is based on \c boost::array, you can access the raw data bytes of the
         address using \c begin(), \c end() or \c operator[]:
         \code
         MACAddress mac = ...;
@@ -135,15 +128,22 @@ Der aktuelle C++ Standard unterstützt drei verschiedene Möglichkeiten eine Zah
         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
 
     };
 
-    /** \brief Write MAC address
+    /** \brief Output MAC instance as it's string representation
         \related MACAddress
      */
     std::ostream & operator<<(std::ostream & os, MACAddress const & mac);
+    /** \brief Try to initialize MACAddress instance from a string representation
+        sets std::ios::failbit on the stream if an error occurred
+        \see MACAddress from_string()
+        \related MACAddress
+     */
+    std::istream & operator>>(std::istream & os, MACAddress & mac);
 
 }