Address
Address
#include <icy/symple/address.h>The Address structure is an endpoint identifier for a peer on the network. The format is like so: user|id
Public Attributes
user
std::string userid
std::string idPublic Methods
| Return | Name | Description |
|---|---|---|
Address | Constructs an empty (invalid) address. | |
Address | Parses an address string of the form user|id. | |
Address | Constructs an address from explicit user and session ID components. | |
bool | parse | Parses an address string of the form user|id. Populates the user and id fields. |
bool | valid const | Returns true if at least one of user or id is non-empty. |
void | print const | Writes the address in user|id format to the given stream. |
std::string | toString const | Returns the address as a string in user|id format. |
bool | operator== const | Compares two addresses for equality (both user and id must match). |
bool | operator== const | Compares this address against a string in user|id format without allocating. |
Address
Address()Constructs an empty (invalid) address.
Address
Address(std::string_view addr)Parses an address string of the form user|id.
Parameters
addrAddress string to parse.
Address
Address(const std::string & user, const std::string & id)Constructs an address from explicit user and session ID components.
Parameters
userUser identifier.idSession ID.
parse
bool parse(std::string_view addr)Parses an address string of the form user|id. Populates the user and id fields.
Parameters
addrAddress string to parse.
Returns
True if the result is a valid address.
valid
const
bool valid() constReturns true if at least one of user or id is non-empty.
const
void print(std::ostream & os) constWrites the address in user|id format to the given stream.
Parameters
osOutput stream.
toString
const
std::string toString() constReturns the address as a string in user|id format.
Returns
Serialised address string.
operator==
const
bool operator==(const Address & r) constCompares two addresses for equality (both user and id must match).
Parameters
rAddress to compare against.
operator==
const
bool operator==(const std::string & r) constCompares this address against a string in user|id format without allocating.
Parameters
rString to compare against.
