From baff5e5594023b23529ff90e2cd9f0f6c6041cd2 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Mon, 4 Jul 2022 18:34:11 +0200 Subject: [PATCH] lib/yajl: use std::span instead of ConstBuffer --- src/lib/yajl/Gen.hxx | 7 +++---- src/lib/yajl/ResponseParser.cxx | 1 - src/output/plugins/snapcast/SnapcastOutputPlugin.cxx | 4 ++-- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/lib/yajl/Gen.hxx b/src/lib/yajl/Gen.hxx index 14ea7ec7e..0fd60253b 100644 --- a/src/lib/yajl/Gen.hxx +++ b/src/lib/yajl/Gen.hxx @@ -30,11 +30,10 @@ #ifndef YAJL_GEN_HXX #define YAJL_GEN_HXX -#include "util/ConstBuffer.hxx" - #include #include +#include #include namespace Yajl { @@ -89,12 +88,12 @@ public: yajl_gen_array_close(gen); } - ConstBuffer GetBuffer() const noexcept { + std::span GetBuffer() const noexcept { const unsigned char *buf; size_t len; auto status = yajl_gen_get_buf(gen, &buf, &len); if (status != yajl_gen_status_ok) - return nullptr; + return {}; return {(const char *)buf, len}; } diff --git a/src/lib/yajl/ResponseParser.cxx b/src/lib/yajl/ResponseParser.cxx index 09042a265..a2649ce57 100644 --- a/src/lib/yajl/ResponseParser.cxx +++ b/src/lib/yajl/ResponseParser.cxx @@ -28,7 +28,6 @@ */ #include "ResponseParser.hxx" -#include "util/ConstBuffer.hxx" void YajlResponseParser::OnData(std::span data) diff --git a/src/output/plugins/snapcast/SnapcastOutputPlugin.cxx b/src/output/plugins/snapcast/SnapcastOutputPlugin.cxx index fd5a6fee6..d6e883b35 100644 --- a/src/output/plugins/snapcast/SnapcastOutputPlugin.cxx +++ b/src/output/plugins/snapcast/SnapcastOutputPlugin.cxx @@ -30,6 +30,7 @@ #include "event/Call.hxx" #include "util/Domain.hxx" #include "util/DeleteDisposer.hxx" +#include "util/SpanCast.hxx" #include "config/Net.hxx" #ifdef HAVE_ZEROCONF @@ -277,8 +278,7 @@ ToJson(const Tag &tag) noexcept gen.CloseMap(); - const auto result = gen.GetBuffer(); - return {(const char *)result.data, result.size}; + return std::string{ToStringView(gen.GetBuffer())}; } #endif