Commit 993f8d6a authored by Max Kellermann's avatar Max Kellermann

db/Print: pass RangeArg to db_selection_print()

parent 68f824a1
...@@ -113,7 +113,7 @@ handle_match(Client &client, Request args, Response &r, bool fold_case) ...@@ -113,7 +113,7 @@ handle_match(Client &client, Request args, Response &r, bool fold_case)
db_selection_print(r, client.GetPartition(), db_selection_print(r, client.GetPartition(),
selection, true, false, selection, true, false,
sort, descending, sort, descending,
window.start, window.end); window);
return CommandResult::OK; return CommandResult::OK;
} }
......
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
#include "TimePrint.hxx" #include "TimePrint.hxx"
#include "TagPrint.hxx" #include "TagPrint.hxx"
#include "client/Response.hxx" #include "client/Response.hxx"
#include "protocol/RangeArg.hxx"
#include "Partition.hxx" #include "Partition.hxx"
#include "song/DetachedSong.hxx" #include "song/DetachedSong.hxx"
#include "song/Filter.hxx" #include "song/Filter.hxx"
...@@ -180,7 +181,7 @@ db_selection_print(Response &r, Partition &partition, ...@@ -180,7 +181,7 @@ db_selection_print(Response &r, Partition &partition,
const DatabaseSelection &selection, const DatabaseSelection &selection,
bool full, bool base, bool full, bool base,
TagType sort, bool descending, TagType sort, bool descending,
unsigned window_start, unsigned window_end) RangeArg window)
{ {
const Database &db = partition.GetDatabaseOrThrow(); const Database &db = partition.GetDatabaseOrThrow();
...@@ -199,10 +200,10 @@ db_selection_print(Response &r, Partition &partition, ...@@ -199,10 +200,10 @@ db_selection_print(Response &r, Partition &partition,
: VisitPlaylist(); : VisitPlaylist();
if (sort == TAG_NUM_OF_ITEM_TYPES) { if (sort == TAG_NUM_OF_ITEM_TYPES) {
if (window_start > 0 || if (window.start > 0 ||
window_end < (unsigned)std::numeric_limits<int>::max()) window.end < (unsigned)std::numeric_limits<int>::max())
s = [s, window_start, window_end, &i](const LightSong &song){ s = [s, window, &i](const LightSong &song){
const bool in_window = i >= window_start && i < window_end; const bool in_window = i >= window.start && i < window.end;
++i; ++i;
if (in_window) if (in_window)
s(song); s(song);
...@@ -242,15 +243,15 @@ db_selection_print(Response &r, Partition &partition, ...@@ -242,15 +243,15 @@ db_selection_print(Response &r, Partition &partition,
b.GetTag()); b.GetTag());
}); });
if (window_end < songs.size()) if (window.end < songs.size())
songs.erase(std::next(songs.begin(), window_end), songs.erase(std::next(songs.begin(), window.end),
songs.end()); songs.end());
if (window_start >= songs.size()) if (window.start >= songs.size())
return; return;
songs.erase(songs.begin(), songs.erase(songs.begin(),
std::next(songs.begin(), window_start)); std::next(songs.begin(), window.start));
for (const auto &song : songs) for (const auto &song : songs)
s((LightSong)song); s((LightSong)song);
...@@ -264,7 +265,7 @@ db_selection_print(Response &r, Partition &partition, ...@@ -264,7 +265,7 @@ db_selection_print(Response &r, Partition &partition,
{ {
db_selection_print(r, partition, selection, full, base, db_selection_print(r, partition, selection, full, base,
TAG_NUM_OF_ITEM_TYPES, false, TAG_NUM_OF_ITEM_TYPES, false,
0, std::numeric_limits<int>::max()); RangeArg::All());
} }
static void static void
......
...@@ -26,6 +26,7 @@ enum TagType : uint8_t; ...@@ -26,6 +26,7 @@ enum TagType : uint8_t;
class TagMask; class TagMask;
class SongFilter; class SongFilter;
struct DatabaseSelection; struct DatabaseSelection;
struct RangeArg;
struct Partition; struct Partition;
class Response; class Response;
...@@ -47,7 +48,7 @@ db_selection_print(Response &r, Partition &partition, ...@@ -47,7 +48,7 @@ db_selection_print(Response &r, Partition &partition,
const DatabaseSelection &selection, const DatabaseSelection &selection,
bool full, bool base, bool full, bool base,
TagType sort, bool descending, TagType sort, bool descending,
unsigned window_start, unsigned window_end); RangeArg window);
void void
PrintSongUris(Response &r, Partition &partition, PrintSongUris(Response &r, Partition &partition,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment