lib/yajl: use std::span instead of ConstBuffer
This commit is contained in:
parent
020c9b41cc
commit
baff5e5594
@ -30,11 +30,10 @@
|
||||
#ifndef YAJL_GEN_HXX
|
||||
#define YAJL_GEN_HXX
|
||||
|
||||
#include "util/ConstBuffer.hxx"
|
||||
|
||||
#include <yajl/yajl_gen.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <span>
|
||||
#include <string_view>
|
||||
|
||||
namespace Yajl {
|
||||
@ -89,12 +88,12 @@ public:
|
||||
yajl_gen_array_close(gen);
|
||||
}
|
||||
|
||||
ConstBuffer<char> GetBuffer() const noexcept {
|
||||
std::span<const char> 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};
|
||||
}
|
||||
|
@ -28,7 +28,6 @@
|
||||
*/
|
||||
|
||||
#include "ResponseParser.hxx"
|
||||
#include "util/ConstBuffer.hxx"
|
||||
|
||||
void
|
||||
YajlResponseParser::OnData(std::span<const std::byte> data)
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user