diff --git a/include/sockpp/inet6_address.h b/include/sockpp/inet6_address.h index 27e0201..bd73121 100644 --- a/include/sockpp/inet6_address.h +++ b/include/sockpp/inet6_address.h @@ -227,7 +227,7 @@ class inet6_address : public sock_address * @return A string representation of the address in the form * '[address]:port' */ - std::string to_string() const; + std::string to_string() const override; }; // -------------------------------------------------------------------------- diff --git a/include/sockpp/inet_address.h b/include/sockpp/inet_address.h index 602f665..ec2d76e 100644 --- a/include/sockpp/inet_address.h +++ b/include/sockpp/inet_address.h @@ -219,7 +219,7 @@ class inet_address : public sock_address * @return A string representation of the address in the form * 'address:port' */ - std::string to_string() const; + std::string to_string() const override; }; // -------------------------------------------------------------------------- diff --git a/include/sockpp/sock_address.h b/include/sockpp/sock_address.h index 863a8ba..92569ea 100644 --- a/include/sockpp/sock_address.h +++ b/include/sockpp/sock_address.h @@ -94,6 +94,14 @@ class sock_address auto p = sockaddr_ptr(); return p ? p->sa_family : AF_UNSPEC; } + + /** + * Gets a printable string for the address. + * @return A string representation of the address + */ + virtual std::string to_string() const { + return std::string(); + } }; ///////////////////////////////////////////////////////////////////////////// diff --git a/include/sockpp/unix_address.h b/include/sockpp/unix_address.h index 30e8de7..c36425e 100644 --- a/include/sockpp/unix_address.h +++ b/include/sockpp/unix_address.h @@ -169,7 +169,7 @@ class unix_address : public sock_address * @return A string representation of the address in the form * "unix:" */ - std::string to_string() const { + std::string to_string() const override { return std::string("unix:") + std::string(addr_.sun_path); } };