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

#include <IPRange.h>

Inheritance diagram for swoc::IP4Range:
Inheritance graph
Collaboration diagram for swoc::IP4Range:
Collaboration graph

Classes

class  NetSource
 

Public Member Functions

constexpr IP4Range ()=default
 Default constructor, invalid range.
 
 IP4Range (IP4Addr const &addr, IPMask const &mask)
 Construct from an network expressed as addr and mask.
 
 IP4Range (super_type const &r)
 
 IP4Range (string_view const &text)
 
self_typeassign (IP4Addr const &addr, IPMask const &mask)
 < Import super class constructors.
 
bool load (string_view text)
 < Import assign methods.
 
IPMask network_mask () const
 
sa_family_t family () const
 
NetSource networks () const
 
self_typeassign (metric_type const &min, metric_type const &max)
 
self_typeassign (metric_type const &value)
 
- Public Member Functions inherited from swoc::DiscreteRange< IP4Addr >
constexpr DiscreteRange ()
 
constexpr DiscreteRange (IP4Addr const &value)
 
constexpr DiscreteRange (IP4Addr const &min, IP4Addr const &max)
 
bool empty () const
 
self_typeassign (metric_type const &min, metric_type const &max)
 
self_typeassign (metric_type const &value)
 
self_typeassign_min (metric_type const &min)
 
self_typeassign_max (metric_type const &max)
 
self_typeclip_max ()
 
metric_type const & min () const
 
metric_type const & max () const
 
bool operator== (self_type const &that) const
 Equality.
 
bool operator!= (self_type const &that) const
 Inequality.
 
bool contains (metric_type const &value) const
 
bool has_intersection_with (self_type const &that) const
 
self_type intersection (self_type const &that) const
 
bool is_adjacent_to (self_type const &that) const
 
bool is_left_adjacent_to (self_type const &that) const
 
bool has_union (self_type const &that) const
 
bool is_superset_of (self_type const &that) const
 
bool is_subset_of (self_type const &that) const
 
bool is_strict_superset_of (self_type const &that) const
 
bool is_strict_subset_of (self_type const &that) const
 
Relation relationship (self_type const &that) const
 
EdgeRelation left_edge_relationship (self_type const &that) const
 
self_type hull (self_type const &that) const
 
bool is_singleton () const
 Check if the interval is exactly one element.
 
bool operator! () const
 
 operator bool () const
 
bool is_maximal () const
 
self_typeoperator&= (self_type const &that)
 
self_typeoperator|= (self_type const &that)
 
self_typeclear ()
 Make the range empty.
 
constexpr DiscreteRange ()
 
constexpr DiscreteRange (IP4Addr const &value)
 
constexpr DiscreteRange (IP4Addr const &min, IP4Addr const &max)
 
bool empty () const
 
self_typeassign (metric_type const &min, metric_type const &max)
 
self_typeassign (metric_type const &value)
 
self_typeassign_min (metric_type const &min)
 
self_typeassign_max (metric_type const &max)
 
self_typeclip_max ()
 
metric_type const & min () const
 
metric_type const & max () const
 
bool operator== (self_type const &that) const
 Equality.
 
bool operator!= (self_type const &that) const
 Inequality.
 
bool contains (metric_type const &value) const
 
bool has_intersection_with (self_type const &that) const
 
self_type intersection (self_type const &that) const
 
bool is_adjacent_to (self_type const &that) const
 
bool is_left_adjacent_to (self_type const &that) const
 
bool has_union (self_type const &that) const
 
bool is_superset_of (self_type const &that) const
 
bool is_subset_of (self_type const &that) const
 
bool is_strict_superset_of (self_type const &that) const
 
bool is_strict_subset_of (self_type const &that) const
 
Relation relationship (self_type const &that) const
 
EdgeRelation left_edge_relationship (self_type const &that) const
 
self_type hull (self_type const &that) const
 
bool is_singleton () const
 Check if the interval is exactly one element.
 
bool operator! () const
 
 operator bool () const
 
bool is_maximal () const
 
self_typeoperator&= (self_type const &that)
 
self_typeoperator|= (self_type const &that)
 
self_typeclear ()
 Make the range empty.
 

Additional Inherited Members

- Public Types inherited from swoc::DiscreteRange< IP4Addr >
using metric_type
 Export metric type.
 
using Relation
 Import type for convenience.
 
using EdgeRelation
 Import type for convenience.
 
- Protected Attributes inherited from swoc::DiscreteRange< IP4Addr >
IP4Addr _min
 The minimum value in the interval.
 
IP4Addr _max
 the maximum value in the interval
 
IP4Addr _min
 The minimum value in the interval.
 
IP4Addr _max
 the maximum value in the interval
 

Detailed Description

An inclusive range of IPv4 addresses.

Definition at line 26 of file IPRange.h.

Constructor & Destructor Documentation

◆ IP4Range() [1/3]

swoc::IP4Range::IP4Range ( swoc::IP4Addr const & addr,
swoc::IPMask const & mask )

Construct from an network expressed as addr and mask.

Definition at line 932 of file swoc_ip.cc.

◆ IP4Range() [2/3]

swoc::IP4Range::IP4Range ( super_type const & r)
inline

Construct from super type.

Definition at line 40 of file IPRange.h.

◆ IP4Range() [3/3]

swoc::IP4Range::IP4Range ( string_view const & text)
inline

Construct range from text.

Parameters
textRange text.
See also
IP4Range::load

This results in an empty range if text is not a valid string. If this should be checked, use load.

See also
load

Definition at line 1892 of file IPRange.h.

Member Function Documentation

◆ assign() [1/3]

IP4Range & swoc::IP4Range::assign ( swoc::IP4Addr const & addr,
swoc::IPMask const & mask )

< Import super class constructors.

Set this range.

Parameters
addrMinimum address.
maskCIDR mask to compute maximum adddress from addr.
Returns
this

Definition at line 937 of file swoc_ip.cc.

◆ assign() [2/3]

self_type & swoc::DiscreteRange< IP4Addr >::assign ( metric_type const & min,
metric_type const & max )

Update the range.

Parameters
minNew minimum value.
maxNew maximum value.
Returns
this.

◆ assign() [3/3]

self_type & swoc::DiscreteRange< IP4Addr >::assign ( metric_type const & value)

Update the range.

Parameters
valueThe new minimum and maximum value.
Returns
this.

The range will contain the single value value.

◆ family()

sa_family_t swoc::IP4Range::family ( ) const
inline
Returns
The range family.

Definition at line 87 of file IPRange.h.

◆ load()

bool swoc::IP4Range::load ( string_view text)

< Import assign methods.

Assign to this range from text.

Parameters
textRange text.

The text must be in one of three formats.

  • A dashed range, "addr1-addr2"
  • A singleton, "addr". This is treated as if it were "addr-addr", a range of size 1.
  • CIDR notation, "addr/cidr" where "cidr" is a number from 0 to the number of bits in the address.

Definition at line 954 of file swoc_ip.cc.

◆ network_mask()

IPMask swoc::IP4Range::network_mask ( ) const

Compute the mask for this as a network.

Returns
If this is a network, the mask for that network. Otherwise an invalid mask.
See also
IPMask::is_valid

Definition at line 983 of file swoc_ip.cc.

◆ networks()

auto swoc::IP4Range::networks ( ) const
inline

Generate a list of networks covering this range.

Returns
A network generator.

The returned object can be used as an iterator, or as a container to iterating over the unique minimal set of networks that cover this range.

void (IP4Range const& range) {
for ( auto const& net : range ) {
net.addr(); // network address.
net.mask(); // network mask;
}
}
constexpr IP4Range()=default
Default constructor, invalid range.

Definition at line 1897 of file IPRange.h.


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