sources/network/ipaddress.h

changeset 24
e651d02802c0
parent 9
e7a09ceb4505
child 50
874bbfa55da8
equal deleted inserted replaced
23:f7221183a994 24:e651d02802c0
36 36
37 enum WithPort { IP_WITH_PORT, IP_NO_PORT }; 37 enum WithPort { IP_WITH_PORT, IP_NO_PORT };
38 38
39 struct IPAddress 39 struct IPAddress
40 { 40 {
41 class StringParseError
42 {
43 String m_message;
44
45 public:
46 StringParseError (String message) :
47 m_message (message) {}
48
49 inline METHOD
50 what() const throw() -> const char*
51 {
52 return m_message.chars();
53 }
54 };
55
41 unsigned long host; 56 unsigned long host;
42 unsigned short port; 57 unsigned short port;
43 static bool sink;
44 58
45 IPAddress(); 59 IPAddress();
46 IPAddress (unsigned long host, unsigned short port); 60 IPAddress (unsigned long host, unsigned short port);
47 IPAddress (const IPAddress& other); 61 IPAddress (const IPAddress& other);
48 62
54 METHOD operator< (const IPAddress& other) const -> bool; 68 METHOD operator< (const IPAddress& other) const -> bool;
55 inline METHOD operator== (const IPAddress& other) const -> bool; 69 inline METHOD operator== (const IPAddress& other) const -> bool;
56 inline METHOD operator!= (const IPAddress& other) const -> bool; 70 inline METHOD operator!= (const IPAddress& other) const -> bool;
57 inline METHOD operator[] (int n) const -> unsigned char; 71 inline METHOD operator[] (int n) const -> unsigned char;
58 72
59 static METHOD from_string (String input, bool* ok = &sink) -> IPAddress; 73 static METHOD from_string (String input) -> IPAddress;
60 static METHOD resolve (String node, bool* ok = &sink) -> IPAddress; 74 static METHOD resolve (String node) -> IPAddress;
61 }; 75 };
62 76
63 static const unsigned long localhost = 0x7F000001; 77 static const unsigned long localhost = 0x7F000001;
64 78
65 inline METHOD 79 inline METHOD

mercurial