LibSWOC++ 1.5.14
Solid Wall of C++
Loading...
Searching...
No Matches
swoc::IP4Srv Class Reference

An IPv4 address and host_order_port, modeled on an SRV type for DNS. More...

#include <IPSrv.h>

Collaboration diagram for swoc::IP4Srv:
Collaboration graph

Public Member Functions

constexpr IP4Srv ()=default
 Default constructor.
 
 IP4Srv (IP4Addr addr, in_port_t port=0)
 
 IP4Srv (IPSrv const &that)
 
 IP4Srv (sockaddr_in const *s)
 
 IP4Srv (swoc::TextView text)
 
constexpr operator IP4Addr const & () const
 Implicit conversion to an address.
 
constexpr IP4Addr const & addr () const
 
in_port_t host_order_port () const
 
in_port_t network_order_port () const
 
bool operator== (self_type that) const
 
bool operator!= (self_type that) const
 
bool operator< (self_type that) const
 
bool operator<= (self_type const &that) const
 
bool operator> (self_type const &that) const
 
bool operator>= (self_type const &that) const
 
bool load (swoc::TextView text)
 
self_typeassign (IP4Addr const &addr)
 
self_typeassign (in_port_t port)
 
self_typeassign (IP4Addr const &addr, in_port_t port)
 
self_typeassign (sockaddr_in const *s)
 

Static Public Member Functions

static constexpr sa_family_t family ()
 

Protected Attributes

IP4Addr _addr
 Address.
 
in_port_t _port = 0
 Port [host order].
 

Detailed Description

An IPv4 address and host_order_port, modeled on an SRV type for DNS.

Definition at line 20 of file IPSrv.h.

Constructor & Destructor Documentation

◆ IP4Srv() [1/4]

swoc::IP4Srv::IP4Srv ( IP4Addr addr,
in_port_t port = 0 )
inlineexplicit

Construct from address and host_order_port.

Parameters
addrThe address.
portThe port in host order, defaults to 0.

Definition at line 404 of file IPSrv.h.

◆ IP4Srv() [2/4]

swoc::IP4Srv::IP4Srv ( IPSrv const & that)
inlineexplicit

Construct from generic.

Parameters
thatThe generic SRV.

If that is not IPv4 the result is a default constructed instance.

Definition at line 405 of file IPSrv.h.

◆ IP4Srv() [3/4]

swoc::IP4Srv::IP4Srv ( sockaddr_in const * s)
inline

Construct from socket address.

Parameters
saSocket address.

Definition at line 46 of file IPSrv.h.

◆ IP4Srv() [4/4]

swoc::IP4Srv::IP4Srv ( swoc::TextView text)
explicit

Construct from a string.

Parameters
textInput text.

If the port is not present it is set to zero.

Definition at line 738 of file swoc_ip.cc.

Member Function Documentation

◆ addr()

IP4Addr const & swoc::IP4Srv::addr ( ) const
inlineconstexpr
Returns
The address.

Definition at line 433 of file IPSrv.h.

◆ assign() [1/4]

auto swoc::IP4Srv::assign ( in_port_t port)
inline

Assign a port.

Parameters
portPort to assign (host order)
Returns
this.

Definition at line 413 of file IPSrv.h.

◆ assign() [2/4]

auto swoc::IP4Srv::assign ( IP4Addr const & addr)
inline

Assign an IPv4 address.

Parameters
addrAddress to assign.
Returns
this

Definition at line 408 of file IPSrv.h.

◆ assign() [3/4]

auto swoc::IP4Srv::assign ( IP4Addr const & addr,
in_port_t port )
inline

Assign an address and port.

Parameters
addrAddress to assign.
portPort to assign (host order).
Returns
this

Definition at line 418 of file IPSrv.h.

◆ assign() [4/4]

auto swoc::IP4Srv::assign ( sockaddr_in const * s)
inline

Assign an address and port from an IPv4 socket address.

Parameters
sA socket address.
Returns
this

Definition at line 424 of file IPSrv.h.

◆ family()

sa_family_t swoc::IP4Srv::family ( )
inlinestaticconstexpr

The protocol family.

Returns
AF_INET
Note
Useful primarily for template classes.

Definition at line 445 of file IPSrv.h.

◆ host_order_port()

in_port_t swoc::IP4Srv::host_order_port ( ) const
inline
Returns
The host_order_port in host order.

Definition at line 437 of file IPSrv.h.

◆ load()

bool swoc::IP4Srv::load ( swoc::TextView text)

Load from a string.

Parameters
textInput string.
Returns
true if text in a valid format, false if not.

Definition at line 743 of file swoc_ip.cc.

◆ network_order_port()

in_port_t swoc::IP4Srv::network_order_port ( ) const
inline
Returns
The host_order_port in network order.

Definition at line 441 of file IPSrv.h.

◆ operator IP4Addr const &()

swoc::IP4Srv::operator IP4Addr const & ( ) const
inlineconstexpr

Implicit conversion to an address.

Definition at line 429 of file IPSrv.h.

◆ operator!=()

bool swoc::IP4Srv::operator!= ( IP4Srv::self_type that) const
inline

Definition at line 454 of file IPSrv.h.

◆ operator<()

bool swoc::IP4Srv::operator< ( IP4Srv::self_type that) const
inline

Definition at line 457 of file IPSrv.h.

◆ operator<=()

bool swoc::IP4Srv::operator<= ( IP4Srv::self_type const & that) const
inline

Definition at line 461 of file IPSrv.h.

◆ operator==()

bool swoc::IP4Srv::operator== ( IP4Srv::self_type that) const
inline

Definition at line 450 of file IPSrv.h.

◆ operator>()

bool swoc::IP4Srv::operator> ( IP4Srv::self_type const & that) const
inline

Definition at line 466 of file IPSrv.h.

◆ operator>=()

bool swoc::IP4Srv::operator>= ( IP4Srv::self_type const & that) const
inline

Definition at line 470 of file IPSrv.h.

Member Data Documentation

◆ _addr

IP4Addr swoc::IP4Srv::_addr
protected

Address.

Definition at line 118 of file IPSrv.h.

◆ _port

in_port_t swoc::IP4Srv::_port = 0
protected

Port [host order].

Definition at line 119 of file IPSrv.h.


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