diff -r 53c2aecb9704 -r 08ccaf26cffd sources/network/ipaddress.cpp --- a/sources/network/ipaddress.cpp Thu Jul 23 00:16:47 2015 +0300 +++ b/sources/network/ipaddress.cpp Thu Jul 23 01:52:04 2015 +0300 @@ -38,15 +38,12 @@ # include #endif -#include -#include -#include -#include +BEGIN_ZFC_NAMESPACE #ifdef _WIN32 -using AddrInfo = ADDRINFOA; +typedef ADDRINFOA AddrInfo; #else -using AddrInfo = struct addrinfo; +typedef struct addrinfo AddrInfo; #endif // ----------------------------------------------------------------------------- @@ -69,12 +66,11 @@ // ----------------------------------------------------------------------------- // -METHOD -IPAddress::to_string (WithPort withport) const -> String +String IPAddress::to_string (WithPort withport) const { String val; - if (withport == IP_WITH_PORT) + if (withport == WITH_PORT) val.sprintf ("%u.%u.%u.%u:%u", octet (0), octet (1), octet (2), octet (3), port); else val.sprintf ("%u.%u.%u.%u", octet (0), octet (1), octet (2), octet (3)); @@ -84,16 +80,14 @@ // ----------------------------------------------------------------------------- // -METHOD -IPAddress::octet (int n) const -> unsigned char +unsigned char IPAddress::octet (int n) const { return (host >> ((3 - n) * 8)) & 0xFF; } // ----------------------------------------------------------------------------- // -METHOD -IPAddress::set_octet (int n, unsigned char oct) -> void +void IPAddress::set_octet (int n, unsigned char oct) { // TODO: make a big-endian version host &= ~(0xFF << (3 - n) * 8); @@ -102,8 +96,7 @@ // ----------------------------------------------------------------------------- // -METHOD -IPAddress::compare (const IPAddress& other) const -> bool +bool IPAddress::compare (const IPAddress& other) const { for (int i = 0; i < 4; ++i) { @@ -123,8 +116,7 @@ // ----------------------------------------------------------------------------- // -METHOD -IPAddress::operator< (const IPAddress& other) const -> bool +bool IPAddress::operator< (const IPAddress& other) const { for (int i = 0; i < 4; ++i) { @@ -137,8 +129,7 @@ // ----------------------------------------------------------------------------- // -METHOD -IPAddress::to_sockaddr_in() const -> sockaddr_in +sockaddr_in IPAddress::to_sockaddr_in() const { sockaddr_in claddr; memset (&claddr, 0, sizeof claddr); @@ -150,8 +141,7 @@ // ----------------------------------------------------------------------------- // -STATIC METHOD -IPAddress::from_string (String input) -> IPAddress +IPAddress IPAddress::from_string (String input) { unsigned int parts[4]; int colonpos = input.find (":"); @@ -171,15 +161,14 @@ } if (colonpos != -1) - value.port = input.mid (colonpos + 1, -1).to_int(); + value.port = (unsigned short) input.mid (colonpos + 1, -1).to_int(); return value; } // ----------------------------------------------------------------------------- // -STATIC METHOD -IPAddress::resolve (String node) -> IPAddress +IPAddress IPAddress::resolve (String node) { AddrInfo hints; AddrInfo* lookup; @@ -197,3 +186,5 @@ freeaddrinfo (lookup); return result; } + +END_ZFC_NAMESPACE \ No newline at end of file