added the moo_ip4adxx_t type and moved c++ functions to it from moo_ip4ad_t
This commit is contained in:
		| @ -38,79 +38,80 @@ typedef struct qse_ip6ad_t qse_ip6ad_t; | |||||||
| struct qse_ip4ad_t | struct qse_ip4ad_t | ||||||
| { | { | ||||||
| 	qse_uint32_t value; | 	qse_uint32_t value; | ||||||
|  | }; | ||||||
|  |  | ||||||
| #if defined(__cplusplus) | #if defined(__cplusplus) | ||||||
| 	bool operator== (const qse_ip4ad_t& peer) const { return this->value == peer.value; } | struct qse_ip4adxx_t: public qse_ip4ad_t | ||||||
| 	bool operator!= (const qse_ip4ad_t& peer) const { return this->value != peer.value; } | { | ||||||
| 	bool operator<  (const qse_ip4ad_t& peer) const { return qse_ntoh32(this->value) < qse_ntoh32(peer.value); } | 	qse_ip4adxx_t (qse_uint32_t v = 0)   | ||||||
| 	bool operator<=  (const qse_ip4ad_t& peer) const { return qse_ntoh32(this->value) <= qse_ntoh32(peer.value); } | 	{ | ||||||
| 	bool operator>  (const qse_ip4ad_t& peer) const { return qse_ntoh32(this->value) > qse_ntoh32(peer.value); } | 		this->value = v; | ||||||
| 	bool operator>=  (const qse_ip4ad_t& peer) const { return qse_ntoh32(this->value) >= qse_ntoh32(peer.value); } | 	} | ||||||
|  |  | ||||||
| 	/* i don't define a constructor so that it can be used within a struct | 	bool operator== (const qse_ip4adxx_t& peer) const { return this->value == peer.value; } | ||||||
| 	 * with no constructor. | 	bool operator!= (const qse_ip4adxx_t& peer) const { return this->value != peer.value; } | ||||||
| 	 *   struct xxx { qse_ip4ad_t addr; }  | 	bool operator<  (const qse_ip4adxx_t& peer) const { return qse_ntoh32(this->value) < qse_ntoh32(peer.value); } | ||||||
| 	 * since xxx doesn't have a constructor, some compilers complain of | 	bool operator<= (const qse_ip4adxx_t& peer) const { return qse_ntoh32(this->value) <= qse_ntoh32(peer.value); } | ||||||
| 	 * ill-formed constructor or deleted default contructor. | 	bool operator>  (const qse_ip4adxx_t& peer) const { return qse_ntoh32(this->value) > qse_ntoh32(peer.value); } | ||||||
| 	 */ | 	bool operator>= (const qse_ip4adxx_t& peer) const { return qse_ntoh32(this->value) >= qse_ntoh32(peer.value); } | ||||||
|  |  | ||||||
| 	qse_ip4ad_t& operator= (qse_ip4ad_t v) | 	qse_ip4adxx_t& operator= (const qse_ip4adxx_t& v) | ||||||
| 	{ | 	{ | ||||||
| 		this->value = v.value; | 		this->value = v.value; | ||||||
| 		return *this; | 		return *this; | ||||||
| 	} | 	} | ||||||
| 	qse_ip4ad_t& operator+= (qse_ip4ad_t v)  | 	qse_ip4adxx_t& operator+= (const qse_ip4adxx_t& v)  | ||||||
| 	{ | 	{ | ||||||
| 		this->value = qse_hton32(qse_ntoh32(this->value) + qse_ntoh32(v.value)); | 		this->value = qse_hton32(qse_ntoh32(this->value) + qse_ntoh32(v.value)); | ||||||
| 		return *this; | 		return *this; | ||||||
| 	} | 	} | ||||||
| 	qse_ip4ad_t& operator-= (qse_ip4ad_t v)  | 	qse_ip4adxx_t& operator-= (const qse_ip4adxx_t& v)  | ||||||
| 	{ | 	{ | ||||||
| 		this->value = qse_hton32(qse_ntoh32(this->value) - qse_ntoh32(v.value)); | 		this->value = qse_hton32(qse_ntoh32(this->value) - qse_ntoh32(v.value)); | ||||||
| 		return *this; | 		return *this; | ||||||
| 	} | 	} | ||||||
| 	qse_ip4ad_t operator+ (qse_ip4ad_t v) const | 	qse_ip4adxx_t operator+ (const qse_ip4adxx_t& v) const | ||||||
| 	{ | 	{ | ||||||
| 		qse_ip4ad_t x; | 		qse_ip4adxx_t x; | ||||||
| 		x.value = qse_hton32(qse_ntoh32(this->value) + qse_ntoh32(v.value)); | 		x.value = qse_hton32(qse_ntoh32(this->value) + qse_ntoh32(v.value)); | ||||||
| 		return x; | 		return x; | ||||||
| 	} | 	} | ||||||
| 	qse_ip4ad_t operator- (qse_ip4ad_t v) const | 	qse_ip4adxx_t operator- (const qse_ip4adxx_t& v) const | ||||||
| 	{ | 	{ | ||||||
| 		qse_ip4ad_t x; | 		qse_ip4adxx_t x; | ||||||
| 		x.value = qse_hton32(qse_ntoh32(this->value) - qse_ntoh32(v.value)); | 		x.value = qse_hton32(qse_ntoh32(this->value) - qse_ntoh32(v.value)); | ||||||
| 		return x; | 		return x; | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	qse_ip4ad_t& operator= (qse_uint32_t v) | 	qse_ip4adxx_t& operator= (qse_uint32_t v) | ||||||
| 	{ | 	{ | ||||||
| 		this->value = qse_hton32(v); | 		this->value = qse_hton32(v); | ||||||
| 		return *this; | 		return *this; | ||||||
| 	} | 	} | ||||||
| 	qse_ip4ad_t& operator+= (qse_uint32_t v)  | 	qse_ip4adxx_t& operator+= (qse_uint32_t v)  | ||||||
| 	{ | 	{ | ||||||
| 		this->value = qse_hton32(qse_ntoh32(this->value) + v); | 		this->value = qse_hton32(qse_ntoh32(this->value) + v); | ||||||
| 		return *this; | 		return *this; | ||||||
| 	} | 	} | ||||||
| 	qse_ip4ad_t& operator-= (qse_uint32_t v)  | 	qse_ip4adxx_t& operator-= (qse_uint32_t v)  | ||||||
| 	{ | 	{ | ||||||
| 		this->value = qse_hton32(qse_ntoh32(this->value) - v); | 		this->value = qse_hton32(qse_ntoh32(this->value) - v); | ||||||
| 		return *this; | 		return *this; | ||||||
| 	} | 	} | ||||||
| 	qse_ip4ad_t operator+ (qse_uint32_t v) const | 	qse_ip4adxx_t operator+ (qse_uint32_t v) const | ||||||
| 	{ | 	{ | ||||||
| 		qse_ip4ad_t x; | 		qse_ip4adxx_t x; | ||||||
| 		x.value = qse_hton32(qse_ntoh32(this->value) + v); | 		x.value = qse_hton32(qse_ntoh32(this->value) + v); | ||||||
| 		return x; | 		return x; | ||||||
| 	} | 	} | ||||||
| 	qse_ip4ad_t operator- (qse_uint32_t v) const | 	qse_ip4adxx_t operator- (qse_uint32_t v) const | ||||||
| 	{ | 	{ | ||||||
| 		qse_ip4ad_t x; | 		qse_ip4adxx_t x; | ||||||
| 		x.value = qse_hton32(qse_ntoh32(this->value) - v); | 		x.value = qse_hton32(qse_ntoh32(this->value) - v); | ||||||
| 		return x; | 		return x; | ||||||
| 	} | 	} | ||||||
| #endif |  | ||||||
| }; | }; | ||||||
|  | #endif | ||||||
|  |  | ||||||
| struct qse_ip6ad_t | struct qse_ip6ad_t | ||||||
| { | { | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user