1 #ifndef HOSTADDRESS_P_H
2 #define HOSTADDRESS_P_H
4 #include "api/api_global.h"
14 inline IPv6Address(void) { memset(&data, 0, sizeof(uint8_t)*16); }
16 // data access (no bounds checking)
17 inline uint8_t& operator[](size_t index) { return data[index]; }
18 inline uint8_t operator[](size_t index) const { return data[index]; }
28 enum NetworkProtocol { UnknownNetworkProtocol = -1
36 explicit HostAddress(const uint32_t ip4Address);
37 explicit HostAddress(const uint8_t* ip6Address);
38 explicit HostAddress(const IPv6Address& ip6Address);
39 explicit HostAddress(const std::string& address);
40 HostAddress(const HostAddress& other);
43 // HostAddress interface
46 bool HasIPAddress(void) const; // returns whether string address could be converted to IP address
47 bool IsNull(void) const;
49 uint32_t GetIPv4Address(void) const;
50 IPv6Address GetIPv6Address(void) const;
51 std::string GetIPString(void) const;
52 HostAddress::NetworkProtocol GetProtocol(void) const;
54 void SetAddress(const uint32_t ip4Address);
55 void SetAddress(const uint8_t* ip6Address);
56 void SetAddress(const IPv6Address& ip6Address);
57 void SetAddress(const std::string& address);
59 // HostAddress comparison operators
61 bool operator==(const HostAddress& other) const;
62 bool operator!=(const HostAddress& other) const { return !( operator==(other) ); }
63 bool operator<(const HostAddress& other) const;
67 bool ParseAddress(void);
71 HostAddress::NetworkProtocol m_protocol;
72 uint32_t m_ip4Address;
73 IPv6Address m_ip6Address;
74 std::string m_ipString;
75 bool m_hasIpAddress; // true until string passed in, then signifies whether string was an IP
78 } // namespace Internal
79 } // namespace BamTools
81 #endif // HOSTADDRESS_P_H