sources/network/ipaddress.h

branch
protocol5
changeset 106
7b156b764d11
parent 88
08ccaf26cffd
child 109
e4966d7e615d
--- a/sources/network/ipaddress.h	Sat Jan 09 02:35:00 2016 +0200
+++ b/sources/network/ipaddress.h	Sat Jan 09 17:41:21 2016 +0200
@@ -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