sP2P c++ STL *nix API  1.2
NAT traversal and peer-to-peer networking API providing all utilities needed to build peer-to-peer application straigth out of box
 All Classes Functions Variables Typedefs Enumerations Enumerator
IPAddress.h
1 /*
2 #################################################################################################
3 # sP2P NAT Traversal/Peer-To-Peer networking API
4 #
5 # This file is part of comercial product. You can not use it in any way, redistribute it
6 # in any way and/or modify it in any way unless you get right to do so.
7 #
8 # Use licence can only be acquired from:
9 # ---------------------------------------------------
10 # AS-CAL,raziskave in razvoj, d.o.o.
11 # Kongresni trg 9, 1000 Ljubljana - Slovenia
12 # Company ID: 3913147000
13 # ---------------------------------------------------
14 # , or product legal successor.
15 #
16 #################################################################################################
17 # Ivan Milic
18 # HOLEST Engineering
19 # www.holest.com
20 # Belgrade, Serbia
21 # January, 2013
22 ##################################################################################################
23 */
24 
25 
26 
27 #ifndef __IPADDRESS_H
28 #define __IPADDRESS_H
29 #include "Uninetwork.h"
30 #include "Common.h"
31 #include <string>
32 
33 namespace sp2plib{
34 
35 class SP2P_API IP4Address{
36 public:
37 
39  IP4Address();
40 
43  IP4Address(sp2plib::UInt32 i4Adr);
44 
47  IP4Address(const char *s4Address);
48 
50  ~IP4Address();
51 
54  sp2plib::UInt32 Get();
55 
58  void Set(sp2plib::UInt32 value);
59 
62  void Set(in_addr value);
63 
67  static IP4Address* new_Parse(char* str_address);
68 
71  void Parse(char* str_address);
72 
73 
74 
83  static IP4Address* new_ParseFromBytes(unsigned char* byte_array,int startIndex = 0);
84 
88  void ParseFromBytes(unsigned char* byte_array,int startIndex = 0);
89 
91  ::std::string ToString();
92 
96  void ToByteArray(unsigned char* buffer,int startIndex = 0);
97 
98  //Injects data from this object into sockaddr_in structure
99  //void As_sockaddr_in(sockaddr_in &adr);
100 
104  void As_sockaddr_in(sockaddr_in &adr, sp2plib::UInt16 Port);
105 
108  static IP4Address &ANY();
109 
113  static bool IsIP4AddressFormat(const char *s_adr);
114 
118  IP4Address& operator=(const IP4Address &rhs);
119 
123  IP4Address& operator=(const sp2plib::UInt32 &rhs);
124 
128  bool operator==(const IP4Address &other) const;
129 
133  bool operator!=(const IP4Address &other) const;
134 
135 private:
136  sp2plib::UInt32 _Address;
137  static IP4Address _ANY;
138 
139 };
140 
141 }
142 
143 #endif
144