db/{Count,Print}: use tag_print(), eliminate duplicate code

This commit is contained in:
Max Kellermann 2017-02-07 18:31:30 +01:00
parent a3e28c2d1a
commit 17097d96b7
3 changed files with 6 additions and 5 deletions

View File

@ -41,7 +41,7 @@ void
tag_print_values(Response &r, const Tag &tag) tag_print_values(Response &r, const Tag &tag)
{ {
for (const auto &i : tag) for (const auto &i : tag)
r.Format("%s: %s\n", tag_item_names[i.type], i.value); tag_print(r, i.type, i.value);
} }
void void

View File

@ -25,6 +25,7 @@
#include "client/Response.hxx" #include "client/Response.hxx"
#include "LightSong.hxx" #include "LightSong.hxx"
#include "tag/Tag.hxx" #include "tag/Tag.hxx"
#include "TagPrint.hxx"
#include <functional> #include <functional>
#include <map> #include <map>
@ -57,7 +58,7 @@ Print(Response &r, TagType group, const TagCountMap &m)
assert(unsigned(group) < TAG_NUM_OF_ITEM_TYPES); assert(unsigned(group) < TAG_NUM_OF_ITEM_TYPES);
for (const auto &i : m) { for (const auto &i : m) {
r.Format("%s: %s\n", tag_item_names[group], i.first.c_str()); tag_print(r, group, i.first.c_str());
PrintSearchStats(r, i.second); PrintSearchStats(r, i.second);
} }
} }

View File

@ -23,6 +23,7 @@
#include "SongFilter.hxx" #include "SongFilter.hxx"
#include "SongPrint.hxx" #include "SongPrint.hxx"
#include "TimePrint.hxx" #include "TimePrint.hxx"
#include "TagPrint.hxx"
#include "client/Response.hxx" #include "client/Response.hxx"
#include "Partition.hxx" #include "Partition.hxx"
#include "tag/Tag.hxx" #include "tag/Tag.hxx"
@ -192,12 +193,11 @@ PrintUniqueTag(Response &r, TagType tag_type,
{ {
const char *value = tag.GetValue(tag_type); const char *value = tag.GetValue(tag_type);
assert(value != nullptr); assert(value != nullptr);
r.Format("%s: %s\n", tag_item_names[tag_type], value); tag_print(r, tag_type, value);
for (const auto &item : tag) for (const auto &item : tag)
if (item.type != tag_type) if (item.type != tag_type)
r.Format("%s: %s\n", tag_print(r, item.type, item.value);
tag_item_names[item.type], item.value);
} }
void void