db/Print: move code to PrintSongUris()
This commit is contained in:
parent
2cfccc1c34
commit
0505cb8f7e
@ -285,8 +285,11 @@ handle_list(Client &client, Request args, Response &r)
|
|||||||
return CommandResult::ERROR;
|
return CommandResult::ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
PrintUniqueTags(r, client.GetPartition(),
|
if (tagType == LOCATE_TAG_FILE_TYPE)
|
||||||
tagType, group_mask, filter.get());
|
PrintSongUris(r, client.GetPartition(), filter.get());
|
||||||
|
else
|
||||||
|
PrintUniqueTags(r, client.GetPartition(),
|
||||||
|
tagType, group_mask, filter.get());
|
||||||
return CommandResult::OK;
|
return CommandResult::OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -273,6 +273,20 @@ PrintSongURIVisitor(Response &r, const LightSong &song) noexcept
|
|||||||
song_print_uri(r, song);
|
song_print_uri(r, song);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
PrintSongUris(Response &r, Partition &partition,
|
||||||
|
const SongFilter *filter)
|
||||||
|
{
|
||||||
|
const Database &db = partition.GetDatabaseOrThrow();
|
||||||
|
|
||||||
|
const DatabaseSelection selection("", true, filter);
|
||||||
|
|
||||||
|
using namespace std::placeholders;
|
||||||
|
const auto f = std::bind(PrintSongURIVisitor,
|
||||||
|
std::ref(r), _1);
|
||||||
|
db.Visit(selection, f);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
PrintUniqueTag(Response &r, TagType tag_type,
|
PrintUniqueTag(Response &r, TagType tag_type,
|
||||||
const Tag &tag) noexcept
|
const Tag &tag) noexcept
|
||||||
@ -292,22 +306,15 @@ PrintUniqueTags(Response &r, Partition &partition,
|
|||||||
unsigned type, TagMask group_mask,
|
unsigned type, TagMask group_mask,
|
||||||
const SongFilter *filter)
|
const SongFilter *filter)
|
||||||
{
|
{
|
||||||
|
assert(type < TAG_NUM_OF_ITEM_TYPES);
|
||||||
|
|
||||||
const Database &db = partition.GetDatabaseOrThrow();
|
const Database &db = partition.GetDatabaseOrThrow();
|
||||||
|
|
||||||
const DatabaseSelection selection("", true, filter);
|
const DatabaseSelection selection("", true, filter);
|
||||||
|
|
||||||
if (type == LOCATE_TAG_FILE_TYPE) {
|
using namespace std::placeholders;
|
||||||
using namespace std::placeholders;
|
const auto f = std::bind(PrintUniqueTag, std::ref(r),
|
||||||
const auto f = std::bind(PrintSongURIVisitor,
|
(TagType)type, _1);
|
||||||
std::ref(r), _1);
|
db.VisitUniqueTags(selection, (TagType)type,
|
||||||
db.Visit(selection, f);
|
group_mask, f);
|
||||||
} else {
|
|
||||||
assert(type < TAG_NUM_OF_ITEM_TYPES);
|
|
||||||
|
|
||||||
using namespace std::placeholders;
|
|
||||||
const auto f = std::bind(PrintUniqueTag, std::ref(r),
|
|
||||||
(TagType)type, _1);
|
|
||||||
db.VisitUniqueTags(selection, (TagType)type,
|
|
||||||
group_mask, f);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -49,6 +49,10 @@ db_selection_print(Response &r, Partition &partition,
|
|||||||
TagType sort, bool descending,
|
TagType sort, bool descending,
|
||||||
unsigned window_start, unsigned window_end);
|
unsigned window_start, unsigned window_end);
|
||||||
|
|
||||||
|
void
|
||||||
|
PrintSongUris(Response &r, Partition &partition,
|
||||||
|
const SongFilter *filter);
|
||||||
|
|
||||||
void
|
void
|
||||||
PrintUniqueTags(Response &r, Partition &partition,
|
PrintUniqueTags(Response &r, Partition &partition,
|
||||||
unsigned type, TagMask group_mask,
|
unsigned type, TagMask group_mask,
|
||||||
|
Loading…
Reference in New Issue
Block a user