client/Response: add method Fmt() based on libfmt

This commit is contained in:
Max Kellermann
2021-05-21 20:35:29 +02:00
parent a9c704b76e
commit 0440c41cba
27 changed files with 241 additions and 195 deletions

View File

@@ -25,6 +25,8 @@
#include "util/ConstBuffer.hxx"
#include "Partition.hxx"
#include <fmt/format.h>
#include <cassert>
#include <set>
#include <string>
@@ -85,7 +87,7 @@ handle_channels(Client &client, [[maybe_unused]] Request args, Response &r)
}
for (const auto &channel : channels)
r.Format("channel: %s\n", channel.c_str());
r.Fmt(FMT_STRING("channel: {}\n"), channel);
return CommandResult::OK;
}
@@ -97,8 +99,8 @@ handle_read_messages(Client &client,
assert(args.empty());
client.ConsumeMessages([&r](const auto &msg){
r.Format("channel: %s\nmessage: %s\n",
msg.GetChannel(), msg.GetMessage());
r.Fmt(FMT_STRING("channel: {}\nmessage: {}\n"),
msg.GetChannel(), msg.GetMessage());
});
return CommandResult::OK;