sources/network/ipaddress.h

changeset 88
08ccaf26cffd
parent 73
07dda51a7a8e
child 109
e4966d7e615d
--- a/sources/network/ipaddress.h	Thu Jul 23 00:16:47 2015 +0300
+++ b/sources/network/ipaddress.h	Thu Jul 23 01:52:04 2015 +0300
@@ -34,10 +34,21 @@
 struct sockaddr;
 struct sockaddr_in;
 
-enum WithPort { IP_WITH_PORT, IP_NO_PORT };
+BEGIN_ZFC_NAMESPACE
 
 struct IPAddress
 {
+	enum
+	{
+		LOCALHOST = 0x7f000001
+	};
+
+	enum WithPort
+	{
+		WITH_PORT,
+		NO_PORT
+	};
+
 	class StringParseError : public std::exception
 	{
 		String m_message;
@@ -46,8 +57,7 @@
 		StringParseError (String message) :
 			m_message (message) {}
 
-		inline METHOD
-		what() const throw() -> const char*
+		const char* what() const throw()
 		{
 			return m_message.chars();
 		}
@@ -60,36 +70,18 @@
 	IPAddress (unsigned long host, unsigned short port);
 	IPAddress (const IPAddress& other);
 
-	       METHOD compare (const IPAddress& other) const -> bool;
-	       METHOD octet (int n) const -> unsigned char;
-	       METHOD set_octet (int n, unsigned char oct) -> void;
-	       METHOD to_string (WithPort withport = IP_NO_PORT) const -> String;
-	       METHOD to_sockaddr_in() const -> sockaddr_in;
-	       METHOD operator< (const IPAddress& other) const -> bool;
-	inline METHOD operator== (const IPAddress& other) const -> bool;
-	inline METHOD operator!= (const IPAddress& other) const -> bool;
-	inline METHOD operator[] (int n) const -> unsigned char;
+	bool compare (const IPAddress& other) const;
+	unsigned char octet (int n) const;
+	void set_octet (int n, unsigned char oct);
+	String to_string (WithPort withport = NO_PORT) const;
+	sockaddr_in to_sockaddr_in() const;
+	bool operator< (const IPAddress& other) const;
+	bool operator== (const IPAddress& other) const { return compare (other); }
+	bool operator!= (const IPAddress& other) const { return not compare (other); }
+	unsigned char operator[] (int n) const { return octet (n); }
 
-	static METHOD from_string (String input) -> IPAddress;
-	static METHOD resolve (String node) -> IPAddress;
+	static IPAddress from_string (String input);
+	static IPAddress resolve (String node);
 };
 
-static const unsigned long localhost = 0x7F000001;
-
-inline METHOD
-IPAddress::operator[] (int n) const -> unsigned char
-{
-	return octet (n);
-}
-
-inline METHOD
-IPAddress::operator== (const IPAddress& other) const -> bool
-{
-	return compare (other);
-}
-
-inline METHOD
-IPAddress::operator!= (const IPAddress& other) const -> bool
-{
-	return not operator== (other);
-}
+END_ZFC_NAMESPACE

mercurial