Changeset 9307 in orxonox.OLD for branches/proxy/src/lib/network/ip.cc
- Timestamp:
- Jul 17, 2006, 2:39:18 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/proxy/src/lib/network/ip.cc
r9306 r9307 10 10 #include "substring.h" 11 11 12 /** 13 * @brief default constructor 14 */ 12 15 IP::IP() 13 16 { … … 17 20 18 21 22 /** 23 * @brief constructor from ip and port 24 * @param ip the IP 25 * @param port the Port 26 * @return self 27 */ 19 28 IP::IP(int ip, int port) 20 29 { … … 25 34 26 35 36 /** 37 * @brief constructor from a String 38 * @param ip the IP as a String. 39 * @return self 40 */ 27 41 IP::IP(const std::string& ip) 28 42 { … … 31 45 32 46 47 /** 48 * @brief constructor from an SDL net structure IPaddress 49 * @param ip the ip. 50 * @return self 51 */ 33 52 IP::IP(const IPaddress& ip) 34 53 { … … 38 57 39 58 59 /** 60 * @brief copy constructor. 61 * @param ip the IP to copy. 62 * @return self 63 */ 40 64 IP::IP(const IP& ip) 41 65 { … … 46 70 47 71 72 /** 73 * @brief copy operator 74 * @param ip the IP to copy. 75 * @return self. 76 */ 48 77 const IP& IP::operator=(const IP& ip) 49 78 { … … 55 84 56 85 86 /** 87 * @brief comparison operator 88 * @param ip the IP to compare 89 * @return true if ip _and_ port match. 90 */ 57 91 bool IP::operator==(const IP& ip) 58 92 { … … 62 96 63 97 /** 64 * @returns The retrieved IP 65 * 98 * @brief converts a String into an IP Object. 99 * @param ip The string holding an IP. 100 * @return a constructed IP. 66 101 */ 67 102 IP IP::stringToIP(const std::string& ip) … … 85 120 } 86 121 122 123 /** 124 * @brief if you want to have a specific part of an IP 125 * @param part the n'th part of the IP addr (splitted by '.'). 126 * @return the amount held in the designated part. 127 */ 87 128 int IP::ipPart(unsigned int part) const 88 129 { … … 104 145 105 146 147 /** 148 * @return the Ip as a string. 149 */ 106 150 std::string IP::ipString() const 107 151 { … … 110 154 111 155 156 /** 157 * @brief converts an IPaddress struct into a String. 158 * @param ipaddr the IP address as a SDL_net struct. 159 * @return the string retrieved from the IP. 160 */ 112 161 std::string IP::ipToString(const IPaddress& ipaddr) 113 162 { 114 163 int ip = SDLNet_Read32 (ipaddr.host); 115 return ipToString(ip );164 return ipToString(ip, ipaddr.port); 116 165 } 117 166 … … 120 169 121 170 122 std::string IP::ipToString(int ip) 171 /** 172 * converts a IP into a String (without port). 173 * @param ip the IP to put into the string. 174 * @param port -1 if not wanted 175 * @return the string of the ip. 176 */ 177 std::string IP::ipToString(int ip, int port) 123 178 { 124 179 MultiType part0((int) (ip & 0xFF000000) >> 24); … … 127 182 MultiType part3((int) (ip & 0x000000FF) ); 128 183 184 std::string addr = part0.getString() + "." + part1.getString() + "." + 185 part2.getString() + "." + part3.getString(); 129 186 130 return part0.getString() + "." + part1.getString() + "." + 131 part2.getString() + "." + part3.getString(); 187 if (port != -1) 188 addr += MultiType(port).getString(); 189 return addr; 132 190 } 133 191
Note: See TracChangeset
for help on using the changeset viewer.