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 "song/LightSong.hxx"
#include "client/Response.hxx"
#include <fmt/format.h>
/**
* Send detailed information about a range of songs in the queue to a
* client.
@@ -38,12 +40,12 @@ queue_print_song_info(Response &r, const Queue &queue,
unsigned position)
{
song_print_info(r, queue.Get(position));
r.Format("Pos: %u\nId: %u\n",
position, queue.PositionToId(position));
r.Fmt(FMT_STRING("Pos: {}\nId: {}\n"),
position, queue.PositionToId(position));
uint8_t priority = queue.GetPriorityAtPosition(position);
if (priority != 0)
r.Format("Prio: %u\n", priority);
r.Fmt(FMT_STRING("Prio: {}\n"), priority);
}
void
@@ -65,7 +67,7 @@ queue_print_uris(Response &r, const Queue &queue,
assert(end <= queue.GetLength());
for (unsigned i = start; i < end; ++i) {
r.Format("%i:", i);
r.Fmt(FMT_STRING("{}:"), i);
song_print_uri(r, queue.Get(i));
}
}
@@ -93,8 +95,8 @@ queue_print_changes_position(Response &r, const Queue &queue,
for (unsigned i = start; i < end; i++)
if (queue.IsNewerAtPosition(i, version))
r.Format("cpos: %i\nId: %i\n",
i, queue.PositionToId(i));
r.Fmt(FMT_STRING("cpos: {}\nId: {}\n"),
i, queue.PositionToId(i));
}
void