LIBWIRE
Next-generation C++17 networking library.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Public Member Functions | Public Attributes | Static Public Attributes | List of all members
libwire::endpoint Struct Reference

#include <endpoint.hpp>

Public Member Functions

 endpoint (const address &addr, uint16_t port)
 
 endpoint (const std::string_view &str) noexcept(!LIBWIRE_EXCEPTIONS_ENABLED_BOOL)
 Parse endpoint information from string representation. More...
 
bool is_invalid () const noexcept
 Returns true if endpoint struct have invalid contents because of c-tor failure. More...
 
bool operator!= (const endpoint &rhs) const noexcept
 
bool operator== (const endpoint &rhs) const noexcept
 
std::string to_string () const noexcept
 Convert endpoint type to string representation. More...
 

Public Attributes

address addr
 
uint16_t port
 

Static Public Attributes

static const endpoint invalid
 

Detailed Description

Definition at line 29 of file endpoint.hpp.

Constructor & Destructor Documentation

libwire::endpoint::endpoint ( const address addr,
uint16_t  port 
)
libwire::endpoint::endpoint ( const std::string_view &  str)
noexcept

Parse endpoint information from string representation.

Input should have following format: "IP:PORT" (IPv4) or "[IP]:PORT" (IPv6).

If exceptions are enabled - will throw std::invalid_argument, otherwise constructed address will have is_invalid() = true.

Member Function Documentation

bool libwire::endpoint::is_invalid ( ) const
noexcept

Returns true if endpoint struct have invalid contents because of c-tor failure.

Note
Invalid values can be safetly used as a "null" endpoint.
bool libwire::endpoint::operator!= ( const endpoint rhs) const
noexcept
bool libwire::endpoint::operator== ( const endpoint rhs) const
noexcept
std::string libwire::endpoint::to_string ( ) const
noexcept

Convert endpoint type to string representation.

Result format is "IP:PORT" for IPv4 and "[IP]:PORT" for IPv6.

Member Data Documentation

address libwire::endpoint::addr

Definition at line 30 of file endpoint.hpp.

const endpoint libwire::endpoint::invalid
static

Definition at line 63 of file endpoint.hpp.

uint16_t libwire::endpoint::port

Definition at line 31 of file endpoint.hpp.