From 1a516cf3c0abadcb0086d9fcdbc6f86550b2b336 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Tue, 19 Feb 2019 12:43:16 +0100 Subject: [PATCH] net/AllocatedSocketAddress: add method GetLocalRaw() --- src/net/AllocatedSocketAddress.cxx | 9 ++++++++- src/net/AllocatedSocketAddress.hxx | 12 +++++++++--- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/net/AllocatedSocketAddress.cxx b/src/net/AllocatedSocketAddress.cxx index f3632ca3c..02cbb67d7 100644 --- a/src/net/AllocatedSocketAddress.cxx +++ b/src/net/AllocatedSocketAddress.cxx @@ -1,5 +1,5 @@ /* - * Copyright (C) 2012-2017 Max Kellermann + * Copyright 2012-2019 Max Kellermann * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -29,6 +29,7 @@ #include "config.h" #include "AllocatedSocketAddress.hxx" +#include "util/StringView.hxx" #include @@ -70,6 +71,12 @@ AllocatedSocketAddress::SetSize(size_type new_size) noexcept #ifdef HAVE_UN +StringView +AllocatedSocketAddress::GetLocalRaw() const noexcept +{ + return SocketAddress(*this).GetLocalRaw(); +} + void AllocatedSocketAddress::SetLocal(const char *path) noexcept { diff --git a/src/net/AllocatedSocketAddress.hxx b/src/net/AllocatedSocketAddress.hxx index 10f61624a..2bd6b372d 100644 --- a/src/net/AllocatedSocketAddress.hxx +++ b/src/net/AllocatedSocketAddress.hxx @@ -1,5 +1,5 @@ /* - * Copyright (C) 2012-2017 Max Kellermann + * Copyright 2012-2019 Max Kellermann * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -27,8 +27,8 @@ * OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef ALLOCATED_SOCKET_ADDRESS_HPP -#define ALLOCATED_SOCKET_ADDRESS_HPP +#ifndef ALLOCATED_SOCKET_ADDRESS_HXX +#define ALLOCATED_SOCKET_ADDRESS_HXX #include "SocketAddress.hxx" #include "Features.hxx" @@ -140,6 +140,12 @@ public: } #ifdef HAVE_UN + /** + * @see SocketAddress::GetLocalRaw() + */ + gcc_pure + StringView GetLocalRaw() const noexcept; + /** * Make this a "local" address (UNIX domain socket). If the path * begins with a '@', then the rest specifies an "abstract" local