00001
00014
00015
00016 #ifndef HOST_H_
00017 #define HOST_H_
00018
00019 #ifdef _MSC_VER
00020 #pragma once
00021 #endif // MSVC
00022
00023 #include <string>
00024 #include <vector>
00025
00026
00027 #include "IpAddress.h"
00028
00029
00031
00032
00033
00034
00035
00036 class Host
00037 {
00038 public:
00039
00040 Host();
00041 Host( const std::string& name );
00042 Host( const IpAddress& address );
00043 Host( const hostent& host );
00044 Host( const Host& host );
00045
00046
00047 Host& operator=( const Host& host );
00048 bool operator==( const Host& host ) const;
00049 bool operator<( const Host& host ) const;
00050
00051
00052 std::string getName() const;
00053
00054
00055 const std::vector<std::string>& getAliases() const;
00056
00057
00058 const std::vector<IpAddress>& getIpAddresses() const;
00059
00060
00061 bool isDefined() const;
00062
00063
00064 static const Host& getLocalhost();
00065
00066
00067 std::ostream& operator<<( std::ostream& stream) const;
00068
00069 protected:
00070
00071 void set( const std::string& name );
00072 void set( const IpAddress& name );
00073 void set( const hostent& host );
00074
00075
00076 static bool find(const std::string& name,struct hostent* data) throw();
00077 static bool find(const IpAddress& address,struct hostent* data) throw();
00078
00079 private:
00080 std::string hostName;
00081 std::vector< std::string > ipAliases;
00082 std::vector< IpAddress > ipAddresses;
00083 static std::auto_ptr<Host> ipLocalhost;
00084 };
00085
00086
00087 #endif // HOST_H_