| Line |   | 
|---|
| 1 |  | 
|---|
| 2 | /*! | 
|---|
| 3 |  * @file ip.h | 
|---|
| 4 |  * | 
|---|
| 5 |  * @brief the ip class is used to transform strings to ip's and backwards | 
|---|
| 6 |  * it can also be used to | 
|---|
| 7 |  * | 
|---|
| 8 |  */ | 
|---|
| 9 |  | 
|---|
| 10 | #ifndef __IP_H__ | 
|---|
| 11 | #define __IP_H__ | 
|---|
| 12 |  | 
|---|
| 13 | #include <string> | 
|---|
| 14 |  | 
|---|
| 15 | #include "netdefs.h" | 
|---|
| 16 |  | 
|---|
| 17 |  | 
|---|
| 18 | //! A class to handle time itself | 
|---|
| 19 | class IP | 
|---|
| 20 | { | 
|---|
| 21 |   public: | 
|---|
| 22 |     /// CONSTRUCTORS | 
|---|
| 23 |     IP(); | 
|---|
| 24 |     IP(int ip, int port); | 
|---|
| 25 |     IP(const std::string& ip, bool resolve = true); | 
|---|
| 26 |     IP(const std::string& ip, int port = -1, bool resolve = true); | 
|---|
| 27 |     IP(const IPaddress& ip); | 
|---|
| 28 |     IP(const IP& ip); | 
|---|
| 29 |  | 
|---|
| 30 |     /// OPERATORS | 
|---|
| 31 |     const IP& operator=(const IP& ip); | 
|---|
| 32 |     bool operator==(const IP& ip); | 
|---|
| 33 |  | 
|---|
| 34 |     /// RETRIVEAL | 
|---|
| 35 |     /** @returns the IP */ | 
|---|
| 36 |     int ip() const { return this->_ip; }; | 
|---|
| 37 |     /** @returns the Port */ | 
|---|
| 38 |     short port() const { return this->_port; }; | 
|---|
| 39 |  | 
|---|
| 40 |     int ipPart(unsigned int part) const; | 
|---|
| 41 |     std::string ipString() const; | 
|---|
| 42 |  | 
|---|
| 43 |     void debug() const; | 
|---|
| 44 |  | 
|---|
| 45 |   public: | 
|---|
| 46 |     /// SETUP | 
|---|
| 47 |     static IP stringToIP(const std::string& ip, int port = -1, bool resolve = true); | 
|---|
| 48 |  | 
|---|
| 49 |     static std::string ipToString(const IPaddress& ipaddr); | 
|---|
| 50 |     static std::string ipToString(int ip, int port = -1); | 
|---|
| 51 |  | 
|---|
| 52 |  | 
|---|
| 53 |     static void setDefaultPort(short defaultPort); | 
|---|
| 54 |     static short defaultPort(short defaultPort) { return IP::_defaultPort; }; | 
|---|
| 55 |  | 
|---|
| 56 |   private: | 
|---|
| 57 |     int           _ip;           //!< The IP in int form. | 
|---|
| 58 |     short         _port;         //!< The Port number of the IP | 
|---|
| 59 |  | 
|---|
| 60 |  | 
|---|
| 61 |     static short  _defaultPort;  //!< Default Port | 
|---|
| 62 | }; | 
|---|
| 63 |  | 
|---|
| 64 | #endif /* __IP_H__ */ | 
|---|
       
      
      Note: See 
TracBrowser
        for help on using the repository browser.