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

#include <IPRange.h>

Collaboration diagram for swoc::IPRangeView:
Collaboration graph

Public Member Functions

 IPRangeView ()=default
 Default constructor - invalid view.
 
bool operator== (IPRange const &r) const
 Compare to a range.
 
bool valid () const
 
bool empty () const
 
self_typeclear ()
 Reset to invalid view.
 
self_typeassign (IP4Range const &r)
 Update the view.
 
self_typeassign (IP6Range const &r)
 Update the view.
 
bool is_ip4 () const
 
bool is_ip6 () const
 
bool is (sa_family_t family) const
 
bool contains (IPAddr const &addr) const
 
bool contains (IP6Addr const &addr) const
 
bool contains (IP4Addr const &addr) const
 
IP4Range const & ip4 () const
 
IP6Range const & ip6 () const
 
IPAddr min () const
 
IPAddr max () const
 
bool operator== (self_type const &that) const
 Equality.
 
bool operator!= (self_type const &that) const
 Inequality.
 
IPRange::NetSource networks () const
 

Protected Attributes

storage_type _raw = {std::monostate()}
 Storage for the view pointer.
 
sa_family_t _family = AF_UNSPEC
 Range address family.
 

Detailed Description

View of a range.

The point of this is IPRange is really a union on top of IP4Range and IP6Range therefore using it requires copying. A view enable using an IPv4 or IPv6 range as a generic range without the copy. This is useful in situations where performance is critical.

Used primarily for iterator implementation where the ranges are stored in family specific ranges in the container. The iterator can use this to provide access as an IPRange without a copying every iteration.

Note
An earlier implementation used references and updated those to achieve this same effect but that appeared to confusion the optimizer and odd effects would happen at higher optimization levels (in particular, iterators would appear to not actually increment even thought the increment code was invoked).

Definition at line 604 of file IPRange.h.

Member Function Documentation

◆ assign() [1/2]

auto swoc::IPRangeView::assign ( IP4Range const & r)
inline

Update the view.

Definition at line 2072 of file IPRange.h.

◆ assign() [2/2]

auto swoc::IPRangeView::assign ( IP6Range const & r)
inline

Update the view.

Definition at line 2079 of file IPRange.h.

◆ clear()

auto swoc::IPRangeView::clear ( )
inline

Reset to invalid view.

Definition at line 2005 of file IPRange.h.

◆ contains() [1/3]

bool swoc::IPRangeView::contains ( IP4Addr const & addr) const
inline

Test if an address is in the range.

Parameters
addrAddress to test.
Returns
true if in this range, false if not.

Definition at line 2114 of file IPRange.h.

◆ contains() [2/3]

bool swoc::IPRangeView::contains ( IP6Addr const & addr) const
inline

Test if an address is in the range.

Parameters
addrAddress to test.
Returns
true if in this range, false if not.

Definition at line 2110 of file IPRange.h.

◆ contains() [3/3]

bool swoc::IPRangeView::contains ( IPAddr const & addr) const
inline

Test if an address is in the range.

Parameters
addrAddress to test.
Returns
true if in this range, false if not.

Definition at line 2100 of file IPRange.h.

◆ empty()

bool swoc::IPRangeView::empty ( ) const
inline

Definition at line 2011 of file IPRange.h.

◆ ip4()

IP4Range const & swoc::IPRangeView::ip4 ( ) const
inline
Returns
Reference to the viewed IPv4 range.

Definition at line 2057 of file IPRange.h.

◆ ip6()

IP6Range const & swoc::IPRangeView::ip6 ( ) const
inline
Returns
Reference to the viewd IPv6 range.

Definition at line 2062 of file IPRange.h.

◆ is()

bool swoc::IPRangeView::is ( sa_family_t family) const
inline

Check if this range is the IP address family.

Parameters
familyIP address family.
Returns
true if this is family, false if not.

Definition at line 2032 of file IPRange.h.

◆ is_ip4()

bool swoc::IPRangeView::is_ip4 ( ) const
inline
Returns
true if this is an IPv4 range.

Definition at line 2022 of file IPRange.h.

◆ is_ip6()

bool swoc::IPRangeView::is_ip6 ( ) const
inline
Returns
true if this is an IPv6 range.

Definition at line 2027 of file IPRange.h.

◆ max()

IPAddr swoc::IPRangeView::max ( ) const
inline
Returns
The maximum value in the range.

Definition at line 2096 of file IPRange.h.

◆ min()

IPAddr swoc::IPRangeView::min ( ) const
inline

Forwarding methods.

Returns
The minimum address in the range.

Definition at line 2091 of file IPRange.h.

◆ networks()

IPRange::NetSource swoc::IPRangeView::networks ( ) const
inline

Generate a list of networks covering this range.

Returns
A network generator.
See also
IPRange::networks

Definition at line 706 of file IPRange.h.

◆ operator!=()

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

Inequality.

Definition at line 2086 of file IPRange.h.

◆ operator==() [1/2]

bool swoc::IPRangeView::operator== ( IPRange const & r) const

Compare to a range.

Definition at line 1244 of file swoc_ip.cc.

◆ operator==() [2/2]

bool swoc::IPRangeView::operator== ( IPRangeView::self_type const & that) const

Equality.

Definition at line 1257 of file swoc_ip.cc.

◆ valid()

bool swoc::IPRangeView::valid ( ) const
inline
Returns
true if there is no valid view to a range.

Definition at line 2067 of file IPRange.h.

Member Data Documentation

◆ _family

sa_family_t swoc::IPRangeView::_family = AF_UNSPEC
protected

Range address family.

Definition at line 714 of file IPRange.h.

◆ _raw

storage_type swoc::IPRangeView::_raw = {std::monostate()}
protected

Storage for the view pointer.

Definition at line 713 of file IPRange.h.


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