KanoopCommonQt 2.1.1
Kanoop foundational Qt utility library
Loading...
Searching...
No Matches
AddressHelper Class Reference

AddressHelper. More...

#include <addresshelper.h>

Static Public Member Functions

static bool tryParseAddressPort (const QString &addressString, QString &address, quint16 &port)
 Parse a combined "address:port" string into its components.
 
static bool tryParseAddressPort (const QString &addressString, QHostAddress &address, quint16 &port)
 Parse a combined "address:port" string into a QHostAddress and port.
 
static QHostAddress resolveIPv4Address (const QString &hostName)
 Resolve a hostname to its IPv4 address.
 
static QHostAddress getLocalIP ()
 Get the local machine's primary IPv4 address.
 
static QHostAddress getLocalIP (const QStringList &allowedInterfaces)
 Get the local machine's IPv4 address, filtered by allowed interface names.
 

Detailed Description

AddressHelper.

Some static helper methods for address resolution and parsing

Stephen Punak, July 08 2019

Static helper methods for network address resolution and parsing.

Definition at line 17 of file addresshelper.h.

Member Function Documentation

◆ getLocalIP() [1/2]

static QHostAddress AddressHelper::getLocalIP ( )
static

Get the local machine's primary IPv4 address.

Returns
The local IPv4 QHostAddress

◆ getLocalIP() [2/2]

static QHostAddress AddressHelper::getLocalIP ( const QStringList &  allowedInterfaces)
static

Get the local machine's IPv4 address, filtered by allowed interface names.

Parameters
allowedInterfacesList of interface name patterns to consider
Returns
The matching local IPv4 QHostAddress

◆ resolveIPv4Address()

static QHostAddress AddressHelper::resolveIPv4Address ( const QString &  hostName)
static

Resolve a hostname to its IPv4 address.

Parameters
hostNameHostname or IP address string to resolve
Returns
Resolved QHostAddress, or QHostAddress() on failure

◆ tryParseAddressPort() [1/2]

static bool AddressHelper::tryParseAddressPort ( const QString &  addressString,
QHostAddress &  address,
quint16 &  port 
)
static

Parse a combined "address:port" string into a QHostAddress and port.

Parameters
addressStringCombined address and port string (e.g. "192.168.1.1:8080")
addressOutput QHostAddress receiving the parsed address
portOutput variable receiving the port number
Returns
true if parsing succeeded, false otherwise

◆ tryParseAddressPort() [2/2]

static bool AddressHelper::tryParseAddressPort ( const QString &  addressString,
QString &  address,
quint16 &  port 
)
static

Parse a combined "address:port" string into its components.

Parameters
addressStringCombined address and port string (e.g. "192.168.1.1:8080")
addressOutput string receiving the address portion
portOutput variable receiving the port number
Returns
true if parsing succeeded, false otherwise

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