OpenVPN 3 Core Library
Loading...
Searching...
No Matches
openvpn::IP::RangeType< ADDR > Class Template Reference

designed to represent and manage a range of IP addresses. More...

#include <range.hpp>

Classes

class  Iterator
 allow easy navigation through a series of IP addresses More...
 

Public Member Functions

 RangeType ()
 Default constructor for RangeType.
 
 RangeType (const ADDR &start, const std::size_t extent)
 Constructor for RangeType with specified start address and extent.
 
Iterator begin () const
 Get an iterator pointing to the beginning of the range.
 
Iterator end () const
 Get an iterator pointing to the end of the range.
 
Iterator iterator () const
 Get an iterator for the range.
 
bool defined () const
 Check if the range is defined (non-empty).
 
const ADDR & start () const
 Get the starting address of the range.
 
std::size_t extent () const
 Get the extent (size) of the range.
 
RangeType pull_front (std::size_t extent)
 Remove and return a new range from the front of this range.
 
std::string to_string () const
 Convert the range to a string representation.
 

Private Attributes

ADDR start_
 
std::size_t extent_
 

Detailed Description

template<typename ADDR>
class openvpn::IP::RangeType< ADDR >

designed to represent and manage a range of IP addresses.

designed to represent and manage a range of IP addresses. This class is particularly useful for networking applications that need to work with blocks of IP addresses.

The purpose of this code is to provide a flexible and efficient way to handle ranges of IP addresses. It allows users to create, manipulate, and iterate over these ranges. The class is templated, which means it can work with different types of IP addresses (IPv4 or IPv6) as long as they conform to the expected interface.

The main inputs for this class are a starting address (of type ADDR) and an extent (the number of addresses in the range). These are typically provided when constructing a RangeType object. The class also has a default constructor that creates an empty range.

As for outputs, the class provides various methods to access information about the range. For example, you can get the starting address, the extent of the range, check if the range is defined (non-empty), and convert the range to a string representation.

The RangeType class achieves its purpose through a combination of data storage and methods for manipulation and access. It stores the start address and the extent of the range as private member variables. The class then provides public methods to interact with this data in useful ways.

One of the key features of this class is its iterator functionality. The Iterator inner class allows users to easily traverse the range of IP addresses. This is particularly useful for operations that need to process each address in the range individually.

An important piece of logic in this class is the pull_front method. This method allows you to remove a specified number of addresses from the front of the range and return them as a new RangeType object. This can be useful for dividing a large range into smaller chunks.

The class also includes methods for converting the range to a string representation, which can be helpful for debugging or displaying the range to users.

Template Parameters
ADDRThe address type

Definition at line 64 of file range.hpp.

Constructor & Destructor Documentation

◆ RangeType() [1/2]

template<typename ADDR >
openvpn::IP::RangeType< ADDR >::RangeType ( )
inline

Default constructor for RangeType.

Definition at line 295 of file range.hpp.

◆ RangeType() [2/2]

template<typename ADDR >
openvpn::IP::RangeType< ADDR >::RangeType ( const ADDR &  start,
const std::size_t  extent 
)
inline

Constructor for RangeType with specified start address and extent.

Parameters
startThe starting address of the range.
extentThe number of addresses in the range.

Definition at line 301 of file range.hpp.

Member Function Documentation

◆ begin()

template<typename ADDR >
RangeType< ADDR >::Iterator openvpn::IP::RangeType< ADDR >::begin ( ) const
inline

Get an iterator pointing to the beginning of the range.

Returns
Iterator to the first address in the range.

Definition at line 307 of file range.hpp.

◆ defined()

template<typename ADDR >
bool openvpn::IP::RangeType< ADDR >::defined ( ) const
inline

Check if the range is defined (non-empty).

Returns
true if the range is defined, false otherwise.

Definition at line 328 of file range.hpp.

Here is the caller graph for this function:

◆ end()

template<typename ADDR >
RangeType< ADDR >::Iterator openvpn::IP::RangeType< ADDR >::end ( ) const
inline

Get an iterator pointing to the end of the range.

Returns
Iterator to one past the last address in the range.

Definition at line 313 of file range.hpp.

◆ extent()

template<typename ADDR >
std::size_t openvpn::IP::RangeType< ADDR >::extent ( ) const
inline

Get the extent (size) of the range.

Returns
The number of addresses in the range.

Definition at line 340 of file range.hpp.

◆ iterator()

template<typename ADDR >
RangeType< ADDR >::Iterator openvpn::IP::RangeType< ADDR >::iterator ( ) const
inline

Get an iterator for the range.

Returns
Iterator to the first address in the range.
Note
This method is equivalent to begin().

Definition at line 322 of file range.hpp.

◆ pull_front()

template<typename ADDR >
RangeType< ADDR > openvpn::IP::RangeType< ADDR >::pull_front ( std::size_t  extent)
inline

Remove and return a new range from the front of this range.

Parameters
extentThe number of addresses to remove from the front.
Returns
A new RangeType object containing the removed addresses.
Note
This operation modifies the original range.

Definition at line 346 of file range.hpp.

Here is the caller graph for this function:

◆ start()

template<typename ADDR >
const ADDR & openvpn::IP::RangeType< ADDR >::start ( ) const
inline

Get the starting address of the range.

Returns
Constant reference to the starting address.

Definition at line 334 of file range.hpp.

◆ to_string()

template<typename ADDR >
std::string openvpn::IP::RangeType< ADDR >::to_string ( ) const
inline

Convert the range to a string representation.

Returns
A string describing the range.

Definition at line 357 of file range.hpp.

Here is the caller graph for this function:

Member Data Documentation

◆ extent_

template<typename ADDR >
std::size_t openvpn::IP::RangeType< ADDR >::extent_
private

Definition at line 134 of file range.hpp.

◆ start_

template<typename ADDR >
ADDR openvpn::IP::RangeType< ADDR >::start_
private

Definition at line 133 of file range.hpp.


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