<commit_before>/**
 *  Ip.h
 *
 *  Ip address class
 *
 *  @copyright 2014 Copernica BV
 */

/**
 *  Set up namespace
 */
namespace React { namespace Net {

/**
 *  Ip address class
 */
class Ip
{
private:
    /**
     *  IP version, can be 4 or 6
     *  @var    char
     */
    char _version = 4;
    
    /**
     *  Union with the actual IP address
     *  @var    union
     */
    union IP {
        // alternatives
        Ipv4 v4;
        Ipv6 v6;
        
        // constructors
        IP() : v4() {}
        IP(const Ipv4 &ip) : v4(ip) {}
        IP(const Ipv6 &ip) : v6(ip) {}
        IP(const Ip &ip) { 
            if (ip._version == 4) v4 = ip._ip.v4;
            if (ip._version == 6) v6 = ip._ip.v6;
        }
        
        // destructor
        ~IP() {}
        
        // assignment operators
        IP &operator=(const Ipv4 &ip) { v4 = ip; return *this; }
        IP &operator=(const Ipv6 &ip) { v6 = ip; return *this; }
    } _ip;

public:
    /**
     *  Empty constructor
     */
    Ip() {}
    
    /**
     *  Constructor based on an other IP address
     *  @param  ip  ip address to copy
     */
    Ip(const Ipv4 &ip) : _version(4), _ip(ip) {}
    Ip(const Ipv6 &ip) : _version(6), _ip(ip) {}
    Ip(const Ip &ip) : _version(ip._version), _ip(ip) {}

    /**
     *  Constructor based on string
     *  @param  ip  textual representation of ip address
     */
    Ip(const char *ip) : Ip(Ipv4(ip))
    {
        // if IP is already valid, we use that
        if (valid()) return;
        
        // try parsing as Ipv6<commit_msg>Added move constructors to React::Net::Ip<commit_after>/**
 *  Ip.h
 *
 *  Ip address class
 *
 *  @copyright 2014 Copernica BV
 */

/**
 *  Set up namespace
 */
namespace React { namespace Net {

/**
 *  Ip address class
 */
class Ip
{
private:
    /**
     *  IP version, can be 4 or 6
     *  @var    char
     */
    char _version = 4;
    
    /**
     *  Union with the actual IP address
     *  @var    union
     */
    union IP {
        // alternatives
        Ipv4 v4;
        Ipv6 v6;
        
        // constructors
        IP() : v4() {}
        IP(const Ipv4 &ip) : v4(ip) {}
        IP(const Ipv6 &ip) : v6(ip) {}
        IP(const Ip &ip) { 
            if (ip._version == 4) v4 = ip._ip.v4;
            if (ip._version == 6) v6 = ip._ip.v6;
        }
        
        // destructor
        ~IP() {}
        
        // assignment operators
        IP &operator=(const Ipv4 &ip) { v4 = ip; return *this; }
        IP &operator=(const Ipv6 &ip) { v6 = ip; return *this; }
    } _ip;

public:
    /**
     *  Empty constructor
     */
    Ip() {}
    
    /**
     *  Constructor based on an other IP address
     *  @param  ip  ip address to copy
     */
    Ip(const Ipv4 &ip) : _version(4), _ip(ip) {}
    Ip(Ipv4 &&ip) : _version(4), _ip(std::move(ip)) {}
    Ip(const Ipv6 &ip) : _version(6), _ip(ip) {}
    Ip(Ipv6 &&ip) : _version(6), _ip(std::move(ip)) {}
    Ip(const Ip &ip) : _version(ip._version), _ip(ip) {}

    /**
     *  Constructor based on string
     *  @param  ip  textual representation of ip address
     */
    Ip(const char *ip) : Ip(Ipv4(ip))
    {
        // if IP is already valid, we use that
        if (valid()) return;
        
        // try parsing as Ipv6
{'fraction_non_alphanumeric': 0.1430317848410758, 'fraction_numerical': 0.02078239608801956, 'mean_word_length': 1.5352439969016267, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6766599', 'n_tokens_mistral': 1202, 'n_tokens_neox': 1151, 'n_words': 323}