xrpld
Loading...
Searching...
No Matches
beast::IP::Endpoint Class Reference

A version-independent IP address and port combination. More...

#include <IPEndpoint.h>

Collaboration diagram for beast::IP::Endpoint:

Public Member Functions

 Endpoint ()
 Create an unspecified endpoint.
 Endpoint (Address addr, Port port=0)
 Create an endpoint from the address and optional port.
std::string toString () const
 Returns a string representing the endpoint.
Port port () const
 Returns the port number on the endpoint.
Endpoint atPort (Port port) const
 Returns a new Endpoint with a different port.
Address const & address () const
 Returns the address portion of this endpoint.
bool isV4 () const
 Convenience accessors for the address part.
bool isV6 () const
AddressV4 toV4 () const
AddressV6 toV6 () const

Static Public Member Functions

static std::optional< EndpointfromStringChecked (std::string const &s)
 Create an Endpoint from a string.
static Endpoint fromString (std::string const &s)

Private Attributes

Address addr_
Port port_

Friends

template<class Hasher>
void hash_append (Hasher &h, Endpoint const &endpoint)
bool operator== (Endpoint const &lhs, Endpoint const &rhs)
 Arithmetic comparison.
bool operator< (Endpoint const &lhs, Endpoint const &rhs)
bool operator!= (Endpoint const &lhs, Endpoint const &rhs)
bool operator> (Endpoint const &lhs, Endpoint const &rhs)
bool operator<= (Endpoint const &lhs, Endpoint const &rhs)
bool operator>= (Endpoint const &lhs, Endpoint const &rhs)

Detailed Description

A version-independent IP address and port combination.

Definition at line 16 of file IPEndpoint.h.

Constructor & Destructor Documentation

◆ Endpoint() [1/2]

beast::IP::Endpoint::Endpoint ( )

Create an unspecified endpoint.

Definition at line 19 of file IPEndpoint.cpp.

◆ Endpoint() [2/2]

beast::IP::Endpoint::Endpoint ( Address addr,
Port port = 0 )
explicit

Create an endpoint from the address and optional port.

Definition at line 23 of file IPEndpoint.cpp.

Member Function Documentation

◆ fromStringChecked()

std::optional< Endpoint > beast::IP::Endpoint::fromStringChecked ( std::string const & s)
static

Create an Endpoint from a string.

If the port is omitted, the endpoint will have a zero port.

Returns
An optional endpoint; will be std::nullopt on failure

Definition at line 28 of file IPEndpoint.cpp.

◆ fromString()

Endpoint beast::IP::Endpoint::fromString ( std::string const & s)
static

Definition at line 42 of file IPEndpoint.cpp.

◆ toString()

std::string beast::IP::Endpoint::toString ( ) const
nodiscard

Returns a string representing the endpoint.

Definition at line 50 of file IPEndpoint.cpp.

◆ port()

Port beast::IP::Endpoint::port ( ) const
nodiscard

Returns the port number on the endpoint.

Definition at line 40 of file IPEndpoint.h.

◆ atPort()

Endpoint beast::IP::Endpoint::atPort ( Port port) const
nodiscard

Returns a new Endpoint with a different port.

Definition at line 47 of file IPEndpoint.h.

◆ address()

Address const & beast::IP::Endpoint::address ( ) const
nodiscard

Returns the address portion of this endpoint.

Definition at line 54 of file IPEndpoint.h.

◆ isV4()

bool beast::IP::Endpoint::isV4 ( ) const
nodiscard

Convenience accessors for the address part.

Definition at line 62 of file IPEndpoint.h.

◆ isV6()

bool beast::IP::Endpoint::isV6 ( ) const
nodiscard

Definition at line 67 of file IPEndpoint.h.

◆ toV4()

AddressV4 beast::IP::Endpoint::toV4 ( ) const
nodiscard

Definition at line 72 of file IPEndpoint.h.

◆ toV6()

AddressV6 beast::IP::Endpoint::toV6 ( ) const
nodiscard

Definition at line 77 of file IPEndpoint.h.

◆ operator==

bool operator== ( Endpoint const & lhs,
Endpoint const & rhs )
friend

Arithmetic comparison.

Definition at line 71 of file IPEndpoint.cpp.

◆ operator<

bool operator< ( Endpoint const & lhs,
Endpoint const & rhs )
friend

Definition at line 76 of file IPEndpoint.cpp.

◆ operator!=

bool operator!= ( Endpoint const & lhs,
Endpoint const & rhs )
friend

Definition at line 91 of file IPEndpoint.h.

◆ operator>

bool operator> ( Endpoint const & lhs,
Endpoint const & rhs )
friend

Definition at line 96 of file IPEndpoint.h.

◆ operator<=

bool operator<= ( Endpoint const & lhs,
Endpoint const & rhs )
friend

Definition at line 100 of file IPEndpoint.h.

◆ operator>=

bool operator>= ( Endpoint const & lhs,
Endpoint const & rhs )
friend

Definition at line 106 of file IPEndpoint.h.

◆ hash_append

template<class Hasher>
void hash_append ( Hasher & h,
Endpoint const & endpoint )
friend

Definition at line 114 of file IPEndpoint.h.

Member Data Documentation

◆ addr_

Address beast::IP::Endpoint::addr_
private

Definition at line 121 of file IPEndpoint.h.

◆ port_

Port beast::IP::Endpoint::port_
private

Definition at line 122 of file IPEndpoint.h.