Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9307 in orxonox.OLD for branches


Ignore:
Timestamp:
Jul 17, 2006, 2:39:18 PM (18 years ago)
Author:
bensch
Message:

comments

Location:
branches/proxy/src/lib
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/proxy/src/lib/network/ip.cc

    r9306 r9307  
    1010#include "substring.h"
    1111
     12/**
     13 * @brief default constructor
     14 */
    1215IP::IP()
    1316{
     
    1720
    1821
     22/**
     23 * @brief constructor from ip and port
     24 * @param ip the IP
     25 * @param port the Port
     26 * @return self
     27 */
    1928IP::IP(int ip, int port)
    2029{
     
    2534
    2635
     36/**
     37 * @brief constructor from a String
     38 * @param ip the IP as a String.
     39 * @return self
     40 */
    2741IP::IP(const std::string& ip)
    2842{
     
    3145
    3246
     47/**
     48 * @brief constructor from an SDL net structure IPaddress
     49 * @param ip the ip.
     50 * @return self
     51 */
    3352IP::IP(const IPaddress& ip)
    3453{
     
    3857
    3958
     59/**
     60 * @brief copy constructor.
     61 * @param ip the IP to copy.
     62 * @return self
     63 */
    4064IP::IP(const IP& ip)
    4165{
     
    4670
    4771
     72/**
     73 * @brief copy operator
     74 * @param ip the IP to copy.
     75 * @return self.
     76 */
    4877const IP& IP::operator=(const IP& ip)
    4978{
     
    5584
    5685
     86/**
     87 * @brief comparison operator
     88 * @param ip the IP to compare
     89 * @return true if ip _and_ port match.
     90 */
    5791bool IP::operator==(const IP& ip)
    5892{
     
    6296
    6397/**
    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.
    66101 */
    67102IP IP::stringToIP(const std::string& ip)
     
    85120}
    86121
     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 */
    87128int IP::ipPart(unsigned int part) const
    88129{
     
    104145
    105146
     147/**
     148 * @return the Ip as a string.
     149 */
    106150std::string IP::ipString() const
    107151{
     
    110154
    111155
     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 */
    112161std::string IP::ipToString(const IPaddress& ipaddr)
    113162{
    114163  int ip = SDLNet_Read32 (ipaddr.host);
    115   return ipToString(ip);
     164  return ipToString(ip, ipaddr.port);
    116165}
    117166
     
    120169
    121170
    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 */
     177std::string IP::ipToString(int ip, int port)
    123178{
    124179  MultiType part0((int) (ip & 0xFF000000) >> 24);
     
    127182  MultiType part3((int) (ip & 0x000000FF) );
    128183
     184  std::string addr = part0.getString() + "." + part1.getString() + "." +
     185                     part2.getString() + "." + part3.getString();
    129186
    130   return part0.getString() + "." + part1.getString() + "." +
    131          part2.getString() + "." + part3.getString();
     187  if (port != -1)
     188    addr += MultiType(port).getString();
     189  return addr;
    132190}
    133191
  • branches/proxy/src/lib/network/ip.h

    r9306 r9307  
    4343
    4444    static std::string ipToString(const IPaddress& ipaddr);
    45     static std::string ipToString(int ip);
     45    static std::string ipToString(int ip, int port = -1);
    4646
    4747  private:
  • branches/proxy/src/lib/util/executor/functor_list.h

    r8894 r9307  
    135135
    136136  //! mixed values:
     137  FUNCTOR_LIST(2)(l_STRING, l_INT);
    137138  FUNCTOR_LIST(2)(l_STRING, l_FLOAT);
    138139  FUNCTOR_LIST(2)(l_UINT, l_LONG);
Note: See TracChangeset for help on using the changeset viewer.