JUCE  v5.1.1-3-g1a0b28c73
JUCE API
IPAddress Class Reference

Represents an IP address. More...

#include <juce_IPAddress.h>

Collaboration diagram for IPAddress:

Classes

union  ByteUnion
 Union used to split a 16-bit unsigned integer into 2 8-bit unsigned integers or vice-versa. More...
 

Public Member Functions

 IPAddress (bool IPv6=false) noexcept
 Creates a null address - 0.0.0.0 (IPv4) or ::, (IPv6) More...
 
 IPAddress (const uint8 bytes[], bool IPv6=false) noexcept
 Creates an IPv4 or IPv6 address by reading 4 or 16 bytes from an array. More...
 
 IPAddress (const uint16 bytes[8]) noexcept
 Creates an IPv6 address from an array of 8 16-bit integers. More...
 
 IPAddress (uint8 address1, uint8 address2, uint8 address3, uint8 address4) noexcept
 Creates an IPv4 address from 4 bytes. More...
 
 IPAddress (uint16 address1, uint16 address2, uint16 address3, uint16 address4, uint16 address5, uint16 address6, uint16 address7, uint16 address8) noexcept
 Creates an IPv6 address from 8 16-bit integers. More...
 
 IPAddress (uint32 asNativeEndian32Bit) noexcept
 Creates an IPv4 address from a packed 32-bit integer, where the MSB is the first number in the address, and the LSB is the last. More...
 
 IPAddress (const String &address)
 Parses a string IP address of the form "1.2.3.4" (IPv4) or "1:2:3:4:5:6:7:8" (IPv6). More...
 
bool operator!= (const IPAddress &other) const noexcept
 
bool operator== (const IPAddress &other) const noexcept
 
String toString () const
 Returns a dot- or colon-separated string in the form "1.2.3.4" (IPv4) or "1:2:3:4:5:6:7:8" (IPv6). More...
 

Static Public Member Functions

static IPAddress any (bool IPv6=false) noexcept
 Returns an IPv4 or IPv6 address meaning "any", equivalent to 0.0.0.0 (IPv4) or ::, (IPv6) More...
 
static IPAddress broadcast () noexcept
 Returns an IPv4 address meaning "broadcast" (255.255.255.255) More...
 
static void findAllAddresses (Array< IPAddress > &results, bool includeIPv6=false)
 Populates a list of all the IP addresses that this machine is using. More...
 
static String getFormattedAddress (const String &unformattedAddress)
 Returns a formatted version of the provided IPv6 address conforming to RFC 5952 with leading zeros suppressed, lower case characters, and double-colon notation used to represent contiguous 16-bit fields of zeros. More...
 
static IPAddress local (bool IPv6=false) noexcept
 Returns an IPv4 or IPv6 address meaning "localhost", equivalent to 127.0.0.1 (IPv4) or ::1 (IPv6) More...
 

Public Attributes

uint8 address [16]
 The elements of the IP address. More...
 
bool isIPv6
 

Private Member Functions

void zeroUnusedBytes ()
 Method used to zero the remaining bytes of the address array when creating IPv4 addresses. More...
 

Detailed Description

Represents an IP address.

Constructor & Destructor Documentation

◆ IPAddress() [1/7]

IPAddress::IPAddress ( bool  IPv6 = false)
noexcept

Creates a null address - 0.0.0.0 (IPv4) or ::, (IPv6)

Parameters
IPv6if true indicates that this is an IPv6 address

◆ IPAddress() [2/7]

IPAddress::IPAddress ( const uint8  bytes[],
bool  IPv6 = false 
)
explicitnoexcept

Creates an IPv4 or IPv6 address by reading 4 or 16 bytes from an array.

Parameters
bytesThe array containing the bytes to read.
IPv6if true indicates that 16 bytes should be read instead of 4.

◆ IPAddress() [3/7]

IPAddress::IPAddress ( const uint16  bytes[8])
explicitnoexcept

Creates an IPv6 address from an array of 8 16-bit integers.

Parameters
bytesThe array containing the bytes to read.

◆ IPAddress() [4/7]

IPAddress::IPAddress ( uint8  address1,
uint8  address2,
uint8  address3,
uint8  address4 
)
noexcept

Creates an IPv4 address from 4 bytes.

◆ IPAddress() [5/7]

IPAddress::IPAddress ( uint16  address1,
uint16  address2,
uint16  address3,
uint16  address4,
uint16  address5,
uint16  address6,
uint16  address7,
uint16  address8 
)
noexcept

Creates an IPv6 address from 8 16-bit integers.

◆ IPAddress() [6/7]

IPAddress::IPAddress ( uint32  asNativeEndian32Bit)
explicitnoexcept

Creates an IPv4 address from a packed 32-bit integer, where the MSB is the first number in the address, and the LSB is the last.

◆ IPAddress() [7/7]

IPAddress::IPAddress ( const String address)
explicit

Parses a string IP address of the form "1.2.3.4" (IPv4) or "1:2:3:4:5:6:7:8" (IPv6).

Member Function Documentation

◆ any()

static IPAddress IPAddress::any ( bool  IPv6 = false)
staticnoexcept

Returns an IPv4 or IPv6 address meaning "any", equivalent to 0.0.0.0 (IPv4) or ::, (IPv6)

◆ broadcast()

static IPAddress IPAddress::broadcast ( )
staticnoexcept

Returns an IPv4 address meaning "broadcast" (255.255.255.255)

◆ findAllAddresses()

static void IPAddress::findAllAddresses ( Array< IPAddress > &  results,
bool  includeIPv6 = false 
)
static

Populates a list of all the IP addresses that this machine is using.

◆ getFormattedAddress()

static String IPAddress::getFormattedAddress ( const String unformattedAddress)
static

Returns a formatted version of the provided IPv6 address conforming to RFC 5952 with leading zeros suppressed, lower case characters, and double-colon notation used to represent contiguous 16-bit fields of zeros.

Parameters
unformattedAddressthe IPv6 address to be formatted

◆ local()

static IPAddress IPAddress::local ( bool  IPv6 = false)
staticnoexcept

Returns an IPv4 or IPv6 address meaning "localhost", equivalent to 127.0.0.1 (IPv4) or ::1 (IPv6)

◆ operator!=()

bool IPAddress::operator!= ( const IPAddress other) const
noexcept

◆ operator==()

bool IPAddress::operator== ( const IPAddress other) const
noexcept

◆ toString()

String IPAddress::toString ( ) const

Returns a dot- or colon-separated string in the form "1.2.3.4" (IPv4) or "1:2:3:4:5:6:7:8" (IPv6).

◆ zeroUnusedBytes()

void IPAddress::zeroUnusedBytes ( )
inlineprivate

Method used to zero the remaining bytes of the address array when creating IPv4 addresses.

Member Data Documentation

◆ address

uint8 IPAddress::address[16]

The elements of the IP address.

◆ isIPv6

bool IPAddress::isIPv6

The documentation for this class was generated from the following file: