rippled
Public Member Functions | Static Public Member Functions | Private Attributes | Friends | List of all members
beast::IP::Endpoint Class Reference

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

Collaboration diagram for beast::IP::Endpoint:
Collaboration graph
[legend]

Public Member Functions

 Endpoint ()
 Create an unspecified endpoint. More...
 
 Endpoint (Address const &addr, Port port=0)
 Create an endpoint from the address and optional port. More...
 
std::string to_string () const
 Returns a string representing the endpoint. More...
 
Port port () const
 Returns the port number on the endpoint. More...
 
Endpoint at_port (Port port) const
 Returns a new Endpoint with a different port. More...
 
Address const & address () const
 Returns the address portion of this endpoint. More...
 
bool is_v4 () const
 Convenience accessors for the address part. More...
 
bool is_v6 () const
 
const AddressV4 to_v4 () const
 
const AddressV6 to_v6 () const
 

Static Public Member Functions

static std::optional< Endpointfrom_string_checked (std::string const &s)
 Create an Endpoint from a string. More...
 
static Endpoint from_string (std::string const &s)
 

Private Attributes

Address m_addr
 
Port m_port
 

Friends

template<class Hasher >
void hash_append (Hasher &h, Endpoint const &endpoint)
 
bool operator== (Endpoint const &lhs, Endpoint const &rhs)
 Arithmetic comparison. More...
 
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 38 of file IPEndpoint.h.

Constructor & Destructor Documentation

◆ Endpoint() [1/2]

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

Create an unspecified endpoint.

Definition at line 26 of file IPEndpoint.cpp.

◆ Endpoint() [2/2]

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

Create an endpoint from the address and optional port.

Definition at line 30 of file IPEndpoint.cpp.

Member Function Documentation

◆ from_string_checked()

std::optional< Endpoint > beast::IP::Endpoint::from_string_checked ( 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 35 of file IPEndpoint.cpp.

◆ from_string()

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

Definition at line 49 of file IPEndpoint.cpp.

◆ to_string()

std::string beast::IP::Endpoint::to_string ( ) const

Returns a string representing the endpoint.

Definition at line 57 of file IPEndpoint.cpp.

◆ port()

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

Returns the port number on the endpoint.

Definition at line 62 of file IPEndpoint.h.

◆ at_port()

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

Returns a new Endpoint with a different port.

Definition at line 69 of file IPEndpoint.h.

◆ address()

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

Returns the address portion of this endpoint.

Definition at line 76 of file IPEndpoint.h.

◆ is_v4()

bool beast::IP::Endpoint::is_v4 ( ) const

Convenience accessors for the address part.

Definition at line 84 of file IPEndpoint.h.

◆ is_v6()

bool beast::IP::Endpoint::is_v6 ( ) const

Definition at line 89 of file IPEndpoint.h.

◆ to_v4()

const AddressV4 beast::IP::Endpoint::to_v4 ( ) const

Definition at line 94 of file IPEndpoint.h.

◆ to_v6()

const AddressV6 beast::IP::Endpoint::to_v6 ( ) const

Definition at line 99 of file IPEndpoint.h.

Friends And Related Function Documentation

◆ operator==

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

Arithmetic comparison.

Definition at line 78 of file IPEndpoint.cpp.

◆ operator<

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

Definition at line 84 of file IPEndpoint.cpp.

◆ operator!=

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

Definition at line 113 of file IPEndpoint.h.

◆ operator>

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

Definition at line 118 of file IPEndpoint.h.

◆ operator<=

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

Definition at line 123 of file IPEndpoint.h.

◆ operator>=

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

Definition at line 128 of file IPEndpoint.h.

◆ hash_append

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

Definition at line 136 of file IPEndpoint.h.

Member Data Documentation

◆ m_addr

Address beast::IP::Endpoint::m_addr
private

Definition at line 143 of file IPEndpoint.h.

◆ m_port

Port beast::IP::Endpoint::m_port
private

Definition at line 144 of file IPEndpoint.h.