summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/command/DatabaseCommands.cxx9
-rw-r--r--src/db/DatabasePrint.cxx25
-rw-r--r--src/db/DatabasePrint.hxx13
-rw-r--r--src/db/Selection.cxx2
-rw-r--r--src/db/Selection.hxx18
5 files changed, 33 insertions, 34 deletions
diff --git a/src/command/DatabaseCommands.cxx b/src/command/DatabaseCommands.cxx
index 50024a71e..09c2612b4 100644
--- a/src/command/DatabaseCommands.cxx
+++ b/src/command/DatabaseCommands.cxx
@@ -107,12 +107,13 @@ handle_match(Client &client, Request args, Response &r, bool fold_case)
}
filter.Optimize();
- const DatabaseSelection selection("", true, &filter);
+ DatabaseSelection selection("", true, &filter);
+ selection.window = window;
+ selection.sort = sort;
+ selection.descending = descending;
db_selection_print(r, client.GetPartition(),
- selection, true, false,
- sort, descending,
- window);
+ selection, true, false);
return CommandResult::OK;
}
diff --git a/src/db/DatabasePrint.cxx b/src/db/DatabasePrint.cxx
index 018f3f126..047dd5d18 100644
--- a/src/db/DatabasePrint.cxx
+++ b/src/db/DatabasePrint.cxx
@@ -1,5 +1,5 @@
/*
- * Copyright 2003-2017 The Music Player Daemon Project
+ * Copyright 2003-2018 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
@@ -179,9 +179,7 @@ CompareTags(TagType type, bool descending, const Tag &a, const Tag &b) noexcept
void
db_selection_print(Response &r, Partition &partition,
const DatabaseSelection &selection,
- bool full, bool base,
- TagType sort, bool descending,
- RangeArg window)
+ bool full, bool base)
{
const Database &db = partition.GetDatabaseOrThrow();
@@ -197,9 +195,11 @@ db_selection_print(Response &r, Partition &partition,
std::ref(r), base, _1, _2)
: VisitPlaylist();
- if (sort == TAG_NUM_OF_ITEM_TYPES) {
+ const auto window = selection.window;
+
+ if (selection.sort == TAG_NUM_OF_ITEM_TYPES) {
unsigned i = 0;
- if (!window.IsAll())
+ if (!selection.window.IsAll())
s = [s, window, &i](const LightSong &song){
if (window.Contains(i++))
s(song);
@@ -223,6 +223,9 @@ db_selection_print(Response &r, Partition &partition,
db.Visit(selection, d, collect_songs, p);
}
+ const auto sort = selection.sort;
+ const auto descending = selection.descending;
+
if (sort == TagType(SORT_TAG_LAST_MODIFIED))
std::stable_sort(songs.begin(), songs.end(),
[descending](const DetachedSong &a, const DetachedSong &b){
@@ -254,16 +257,6 @@ db_selection_print(Response &r, Partition &partition,
}
}
-void
-db_selection_print(Response &r, Partition &partition,
- const DatabaseSelection &selection,
- bool full, bool base)
-{
- db_selection_print(r, partition, selection, full, base,
- TAG_NUM_OF_ITEM_TYPES, false,
- RangeArg::All());
-}
-
static void
PrintSongURIVisitor(Response &r, const LightSong &song) noexcept
{
diff --git a/src/db/DatabasePrint.hxx b/src/db/DatabasePrint.hxx
index 1a553545a..85670686c 100644
--- a/src/db/DatabasePrint.hxx
+++ b/src/db/DatabasePrint.hxx
@@ -1,5 +1,5 @@
/*
- * Copyright 2003-2017 The Music Player Daemon Project
+ * Copyright 2003-2018 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
@@ -39,17 +39,6 @@ db_selection_print(Response &r, Partition &partition,
const DatabaseSelection &selection,
bool full, bool base);
-/**
- * @param sort the sort tag; TAG_NUM_OF_ITEM_TYPES means don't sort;
- * LOCATE_TAG_MODIFIED_SINCE means sort by file modification time
- */
-void
-db_selection_print(Response &r, Partition &partition,
- const DatabaseSelection &selection,
- bool full, bool base,
- TagType sort, bool descending,
- RangeArg window);
-
void
PrintSongUris(Response &r, Partition &partition,
const SongFilter *filter);
diff --git a/src/db/Selection.cxx b/src/db/Selection.cxx
index abfc814a0..a7f61286c 100644
--- a/src/db/Selection.cxx
+++ b/src/db/Selection.cxx
@@ -1,5 +1,5 @@
/*
- * Copyright 2003-2017 The Music Player Daemon Project
+ * Copyright 2003-2018 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
diff --git a/src/db/Selection.hxx b/src/db/Selection.hxx
index 7b4e3f5ca..a9727de17 100644
--- a/src/db/Selection.hxx
+++ b/src/db/Selection.hxx
@@ -1,5 +1,5 @@
/*
- * Copyright 2003-2017 The Music Player Daemon Project
+ * Copyright 2003-2018 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
@@ -20,6 +20,8 @@
#ifndef MPD_DATABASE_SELECTION_HXX
#define MPD_DATABASE_SELECTION_HXX
+#include "protocol/RangeArg.hxx"
+#include "tag/Type.h"
#include "util/Compiler.h"
#include <string>
@@ -36,6 +38,20 @@ struct DatabaseSelection {
const SongFilter *filter;
+ RangeArg window = RangeArg::All();
+
+ /**
+ * Sort the result by the given tag. #TAG_NUM_OF_ITEM_TYPES
+ * means don't sort. #SORT_TAG_LAST_MODIFIED sorts by
+ * "Last-Modified" (not technically a tag).
+ */
+ TagType sort = TAG_NUM_OF_ITEM_TYPES;
+
+ /**
+ * If #sort is set, this flag can reverse the sort order.
+ */
+ bool descending = false;
+
/**
* Recursively search all sub directories?
*/