diff options
author | Fabio Alessandrelli <fabio.alessandrelli@gmail.com> | 2017-01-17 09:22:56 +0100 |
---|---|---|
committer | Fabio Alessandrelli <fabio.alessandrelli@gmail.com> | 2017-01-23 20:15:20 +0100 |
commit | 98a7e2b4e09791705cd9dfd4d13611bc02fe47d4 (patch) | |
tree | 71b2de60c2871bec73915dfb1e1036c172fbee78 /core/io/ip_address.h | |
parent | e4b9b37ccf8495be674bc15cf0bf9d76fe94e6be (diff) | |
download | redot-engine-98a7e2b4e09791705cd9dfd4d13611bc02fe47d4.tar.gz |
Convert validity checks of IP_Address to is_valid method.
Diffstat (limited to 'core/io/ip_address.h')
-rw-r--r-- | core/io/ip_address.h | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/core/io/ip_address.h b/core/io/ip_address.h index 87f32b0ac2..3e86e0bcba 100644 --- a/core/io/ip_address.h +++ b/core/io/ip_address.h @@ -41,6 +41,8 @@ private: uint32_t field32[4]; }; + bool valid; + protected: void _parse_ipv6(const String& p_string); void _parse_ipv4(const String& p_string, int p_start, uint8_t* p_ret); @@ -48,12 +50,16 @@ protected: public: //operator Variant() const; bool operator==(const IP_Address& p_ip) const { + if (p_ip.valid != valid) return false; + if (!valid) return false; for (int i=0; i<4; i++) if (field32[i] != p_ip.field32[i]) return false; return true; } bool operator!=(const IP_Address& p_ip) const { + if (p_ip.valid != valid) return true; + if (!valid) return true; for (int i=0; i<4; i++) if (field32[i] != p_ip.field32[i]) return true; @@ -61,6 +67,7 @@ public: } void clear(); + bool is_valid() const {return valid;} bool is_ipv4() const; const uint8_t *get_ipv4() const; void set_ipv4(const uint8_t *p_ip); |