<commit_before>/********************************************************************************
*                                                                               *
*                             IP address container                              *
*                                                                               *
*********************************************************************************
*        Copyright (C) 2003 by <NAME>.   All Rights Reserved.            *
*       NOTE THAT I DO NOT PERMIT ANY OF MY CODE TO BE PROMOTED TO THE GPL      *
*********************************************************************************
* This code is free software; you can redistribute it and/or modify it under    *
* the terms of the GNU Library General Public License v2.1 as published by the  *
* Free Software Foundation EXCEPT that clause 3 does not apply ie; you may not  *
* "upgrade" this code to the GPL without my prior written permission.           *
* Please consult the file "License_Addendum2.txt" accompanying this file.       *
*                                                                               *
* This code is distributed in the hope that it will be useful,                  *
* but WITHOUT ANY WARRANTY; without even the implied warranty of                *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.                          *
*********************************************************************************
* $Id:                                                                          *
********************************************************************************/


#ifndef QHOSTADDRESS_H
#define QHOSTADDRESS_H

#include "fxdefs.h"

namespace FX {

/*! \file QHostAddress.h
\brief Defines classes used to provide an IP address
*/

class FXString;

//! Simple macro creating a FX::QHostAddress containing \c localhost
#define QHOSTADDRESS_LOCALHOST QHostAddress(0x7f000001)

/*! \class QHostAddress
\brief A container holding an IPv4 or IPv6 address (Qt compatible)

This is a Qt compatible IP address container capable of working transparently
with IPv4 and IPv6 addresses. It has no network knowledge and so cannot
be more intelligent than what the IP specification rules permit (eg; it
can't tell if an IPv4 and IPv6 addresses refer to the same machine).

An IPv4 address is 32 bits long whereas IPv6, a substantial improvement
over IPv4, is up to 128 bits long (though it can vary). A discussion of
IP is beyond the scope of this page, there are hundreds of books and RFC's
about the matter which you should consult.

Some mapping though is provided. IPv4 maps to IPv6 where an IPv4 address
\c AA.BB.CC.DD (if the numbers were in hex) becomes in IPv6 
\c fdf8:f53e:61e4::18:AABB:CCDD. Also loopback is treated specially:
127.0.0.1 is equivalent to ::1 and vice versa. In the comparison operators,
0.0.0.0 is treated as being equivalent to loopback.
*/
struct QHostAddressPrivate;
class FXAPIR QHostAddress
{
	QHostAddressPrivate *p;
public:
	//! Constructs a null address
	QHostAddress();
	//! Constructs the specified IPv4 address
	QHostAddress(FXuint ip4addr);
	//! Constructs the specified IPv6 address. Must be in network order.
	QHostAddress(const FXuchar *ip6addr);
	QHostAddress(const QHostAddress &o);
	QHostAddress &operator=(const QHostAddress &o);
	~QHostAddress();
	//! Returns true if both addresses are the same by ruleset
	bool operator==(const QHostAddress &o) const;
	//! Returns true if both addresses are not the same
	bool operator!=(const QHostAddress &o) const { return !(*this==o); }

	//! Sets the contents to the specified IPv4 address
	void setAddress(FXuint ip4addr);
	//! Sets the contents to the specified IPv6 address. Must be in network order.
	void setAddress(const FXuchar *ip6addr);<commit_msg>Added operator!<commit_after>/********************************************************************************
*                                                                               *
*                             IP address container                              *
*                                                                               *
*********************************************************************************
*        Copyright (C) 2003 by <NAME>.   All Rights Reserved.            *
*       NOTE THAT I DO NOT PERMIT ANY OF MY CODE TO BE PROMOTED TO THE GPL      *
*********************************************************************************
* This code is free software; you can redistribute it and/or modify it under    *
* the terms of the GNU Library General Public License v2.1 as published by the  *
* Free Software Foundation EXCEPT that clause 3 does not apply ie; you may not  *
* "upgrade" this code to the GPL without my prior written permission.           *
* Please consult the file "License_Addendum2.txt" accompanying this file.       *
*                                                                               *
* This code is distributed in the hope that it will be useful,                  *
* but WITHOUT ANY WARRANTY; without even the implied warranty of                *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.                          *
*********************************************************************************
* $Id:                                                                          *
********************************************************************************/


#ifndef QHOSTADDRESS_H
#define QHOSTADDRESS_H

#include "fxdefs.h"

namespace FX {

/*! \file QHostAddress.h
\brief Defines classes used to provide an IP address
*/

class FXString;

//! Simple macro creating a FX::QHostAddress containing \c localhost
#define QHOSTADDRESS_LOCALHOST QHostAddress(0x7f000001)

/*! \class QHostAddress
\brief A container holding an IPv4 or IPv6 address (Qt compatible)

This is a Qt compatible IP address container capable of working transparently
with IPv4 and IPv6 addresses. It has no network knowledge and so cannot
be more intelligent than what the IP specification rules permit (eg; it
can't tell if an IPv4 and IPv6 addresses refer to the same machine).

An IPv4 address is 32 bits long whereas IPv6, a substantial improvement
over IPv4, is up to 128 bits long (though it can vary). A discussion of
IP is beyond the scope of this page, there are hundreds of books and RFC's
about the matter which you should consult.

Some mapping though is provided. IPv4 maps to IPv6 where an IPv4 address
\c AA.BB.CC.DD (if the numbers were in hex) becomes in IPv6 
\c fdf8:f53e:61e4::18:AABB:CCDD. Also loopback is treated specially:
127.0.0.1 is equivalent to ::1 and vice versa. In the comparison operators,
0.0.0.0 is treated as being equivalent to loopback.
*/
struct QHostAddressPrivate;
class FXAPIR QHostAddress
{
	QHostAddressPrivate *p;
public:
	//! Constructs a null address
	QHostAddress();
	//! Constructs the specified IPv4 address
	QHostAddress(FXuint ip4addr);
	//! Constructs the specified IPv6 address. Must be in network order.
	QHostAddress(const FXuchar *ip6addr);
	QHostAddress(const QHostAddress &o);
	QHostAddress &operator=(const QHostAddress &o);
	~QHostAddress();
	//! Returns true if the contents is a null address
	bool operator!() const { return isNull(); }
	//! Returns true if both addresses are the same by ruleset
	bool operator==(const QHostAddress &o) const;
	//! Returns true if both addresses are not the same
	bool operator!=(const QHostAddress &o) const { return !(*this==o); }

	//! Sets the contents to the specified IPv4 address
	void setAddress(FXuint ip4addr);
	//! Sets the contents to the specified IPv6 address. Must be in network order.
	void setAddress(const FXuchar *ip6addr);
{'fraction_non_alphanumeric': 0.160910619583495, 'fraction_numerical': 0.0157806234639762, 'mean_word_length': 2.726265060240964, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 4, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 24, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5734329', 'n_tokens_mistral': 1909, 'n_tokens_neox': 1743, 'n_words': 842}