AsyncIpAddress.h

Go to the documentation of this file.
00001 
00030 #ifndef ASYNC_IP_ADDRESS_INCLUDED
00031 #define ASYNC_IP_ADDRESS_INCLUDED
00032 
00033 
00034 /****************************************************************************
00035  *
00036  * System Includes
00037  *
00038  ****************************************************************************/
00039 
00040 #include <netinet/in.h>
00041 
00042 #include <string>
00043 #include <iostream>
00044 
00045 
00046 /****************************************************************************
00047  *
00048  * Project Includes
00049  *
00050  ****************************************************************************/
00051 
00052 
00053 
00054 /****************************************************************************
00055  *
00056  * Local Includes
00057  *
00058  ****************************************************************************/
00059 
00060 
00061 
00062 /****************************************************************************
00063  *
00064  * Forward declarations
00065  *
00066  ****************************************************************************/
00067 
00068 
00069 
00070 /****************************************************************************
00071  *
00072  * Namespace
00073  *
00074  ****************************************************************************/
00075 
00076 namespace Async
00077 {
00078 
00079 /****************************************************************************
00080  *
00081  * Defines & typedefs
00082  *
00083  ****************************************************************************/
00084 
00085 
00086 
00087 /****************************************************************************
00088  *
00089  * Exported Global Variables
00090  *
00091  ****************************************************************************/
00092 
00093 
00094 
00095 /****************************************************************************
00096  *
00097  * Class definitions
00098  *
00099  ****************************************************************************/
00100 
00104 class IpAddress
00105 {
00106   public:
00110     typedef struct in_addr Ip4Addr;
00111     
00115     IpAddress(void);
00116     
00121     IpAddress(const std::string& addr);
00122      
00127     IpAddress(const Ip4Addr& addr);
00128     
00133     IpAddress(const IpAddress& addr) { *this = addr; }
00134     
00138     ~IpAddress(void) {}
00139     
00144     Ip4Addr ip4Addr(void) const { return m_addr; }
00145     
00151     bool isUnicast(void) const;
00152     
00160     bool isWithinSubet(const std::string& subnet) const;
00161     
00166     std::string toString(void) const;
00167     
00173     IpAddress& operator=(const IpAddress& rhs)
00174     {
00175       m_addr = rhs.m_addr;
00176       return *this;
00177     }
00178     
00185     bool operator==(const IpAddress& rhs) const
00186     {
00187       return m_addr.s_addr == rhs.m_addr.s_addr;
00188     }
00189     
00196     bool operator!=(const IpAddress& rhs) const
00197     {
00198       return !(*this == rhs);
00199     }
00200     
00207     bool operator<(const IpAddress& rhs) const
00208     {
00209       return m_addr.s_addr < rhs.m_addr.s_addr;
00210     }
00211     
00217     friend std::ostream& operator<<(std::ostream& os,
00218         const Async::IpAddress& ip);
00219     
00220   protected:
00221     
00222   private:
00223     Ip4Addr m_addr;
00224   
00225 };  /* class IpAddress */
00226 
00227 
00228 std::ostream& operator<<(std::ostream& os, const IpAddress& ip);
00229 
00230 
00231 } /* namespace */
00232 
00233 
00234 #endif /* ASYNC_IP_ADDRESS_INCLUDED */
00235 
00236 
00237 
00238 /*
00239  * This file has not been truncated
00240  */
00241 
Generated by  doxygen 1.6.2-20100208