IpAddress.h

Go to the documentation of this file.
00001 
00014 // IpAddress.h -- interface to the IpAddress class
00015 
00016 #ifndef IPADDRESS_H_
00017 #define IPADDRESS_H_
00018 
00019 #ifdef _MSC_VER
00020 #pragma once
00021 #endif // MSVC
00022 
00023 #include <iosfwd>
00024 #include <string>
00025 #include <memory>
00026 
00027 // platform specific header
00028 #include "SocketIncludes.h"
00029 
00030 
00032 // IpAddress
00033 
00034 class IpAddress
00035 {
00036 public:
00037         // Constructors.
00038         IpAddress( unsigned long code = INADDR_ANY );
00039         IpAddress( const std::string& address );
00040         IpAddress( const in_addr& address );
00041         IpAddress( const IpAddress& address );
00042 
00043         // Destructor.
00044         ~IpAddress();
00045 
00046         // Assignment.
00047         IpAddress& operator=( const in_addr& address );
00048         IpAddress& operator=( const IpAddress& address );
00049 
00050         // Comparison.
00051         bool operator==( const IpAddress& address ) const;
00052         bool operator<( const IpAddress& address ) const;
00053 
00054         // Standard c++ iostream inserter
00055         std::ostream& operator<<( std::ostream& stream) const;
00056 
00057         // Conversion to a Berkley Socket in_addr structure
00058         operator in_addr() const;
00059 
00060         // Conversion of IpAddress to a long
00061         unsigned long toLong() const throw();
00062 
00063         // Accessors to set IpAddress
00064         void set( const std::string& string );
00065         void set( unsigned long code ) throw();
00066         void setHostName( const std::string& hostName );
00067 
00068         // Whether the IpAddress represents the local host
00069         bool isLocal() const;
00070 
00071         // Validity test for IpAddress
00072         bool isDefined() const;
00073 
00074         // Retrieve an IpAddress representing the local host
00075         static const IpAddress& getLocalIpAddress();
00076 
00077 private:
00078         // Berkley Socket in_addr structure.
00079         struct in_addr ipAddress;
00080 
00081         // Collection of IpAddresses for the local host
00082         static std::auto_ptr<IpAddress> localIpAddress;        
00083 };
00084 
00085 
00086 #endif // IPADDRESS_H_
00087 

Generated on Tue Mar 28 09:10:14 2006 for Simple SOAP by  doxygen 1.4.6