Symple module

Address

The [Address]({#ref structicy_1_1smpl_1_1Address #}) structure is an endpoint identifier for a peer on the network.

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

ReturnNameDescription
std::stringuser
std::stringid

user

std::string user

id

std::string id

Public Methods

ReturnNameDescription
AddressConstructs an empty (invalid) address.
AddressParses an address string of the form user|id.
AddressConstructs an address from explicit user and session ID components.
boolparseParses an address string of the form user|id. Populates the user and id fields.
boolvalid constReturns true if at least one of user or id is non-empty.
voidprint constWrites the address in user|id format to the given stream.
std::stringtoString constReturns the address as a string in user|id format.
booloperator== constCompares two addresses for equality (both user and id must match).
booloperator== constCompares 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


Address

Address(const std::string & user, const std::string & id)

Constructs an address from explicit user and session ID components.

Parameters

  • user User identifier.

  • id Session ID.


parse

bool parse(std::string_view addr)

Parses an address string of the form user|id. Populates the user and id fields.

Parameters

Returns

True if the result is a valid address.


valid

const

bool valid() const

Returns true if at least one of user or id is non-empty.


print

const

void print(std::ostream & os) const

Writes the address in user|id format to the given stream.

Parameters

  • os Output stream.

toString

const

std::string toString() const

Returns the address as a string in user|id format.

Returns

Serialised address string.


operator==

const

bool operator==(const Address & r) const

Compares two addresses for equality (both user and id must match).

Parameters


operator==

const

bool operator==(const std::string & r) const

Compares this address against a string in user|id format without allocating.

Parameters

  • r String to compare against.