Instance: add GetDatabaseOrThrow()
This commit is contained in:
@@ -113,9 +113,7 @@ PrintSongCount(Response &r, const Partition &partition, const char *name,
|
||||
TagType group,
|
||||
Error &error)
|
||||
{
|
||||
const Database *db = partition.GetDatabase(error);
|
||||
if (db == nullptr)
|
||||
return false;
|
||||
const Database &db = partition.GetDatabaseOrThrow();
|
||||
|
||||
const DatabaseSelection selection(name, true, filter);
|
||||
|
||||
@@ -127,7 +125,7 @@ PrintSongCount(Response &r, const Partition &partition, const char *name,
|
||||
using namespace std::placeholders;
|
||||
const auto f = std::bind(stats_visitor_song, std::ref(stats),
|
||||
_1);
|
||||
if (!db->Visit(selection, f, error))
|
||||
if (!db.Visit(selection, f, error))
|
||||
return false;
|
||||
|
||||
PrintSearchStats(r, stats);
|
||||
@@ -140,7 +138,7 @@ PrintSongCount(Response &r, const Partition &partition, const char *name,
|
||||
using namespace std::placeholders;
|
||||
const auto f = std::bind(GroupCountVisitor, std::ref(map),
|
||||
group, _1);
|
||||
if (!db->Visit(selection, f, error))
|
||||
if (!db.Visit(selection, f, error))
|
||||
return false;
|
||||
|
||||
Print(r, group, map);
|
||||
|
@@ -155,9 +155,7 @@ db_selection_print(Response &r, Partition &partition,
|
||||
unsigned window_start, unsigned window_end,
|
||||
Error &error)
|
||||
{
|
||||
const Database *db = partition.GetDatabase(error);
|
||||
if (db == nullptr)
|
||||
return false;
|
||||
const Database &db = partition.GetDatabaseOrThrow();
|
||||
|
||||
unsigned i = 0;
|
||||
|
||||
@@ -182,7 +180,7 @@ db_selection_print(Response &r, Partition &partition,
|
||||
return !in_window || s(song, error2);
|
||||
};
|
||||
|
||||
return db->Visit(selection, d, s, p, error);
|
||||
return db.Visit(selection, d, s, p, error);
|
||||
}
|
||||
|
||||
bool
|
||||
@@ -226,9 +224,7 @@ PrintUniqueTags(Response &r, Partition &partition,
|
||||
const SongFilter *filter,
|
||||
Error &error)
|
||||
{
|
||||
const Database *db = partition.GetDatabase(error);
|
||||
if (db == nullptr)
|
||||
return false;
|
||||
const Database &db = partition.GetDatabaseOrThrow();
|
||||
|
||||
const DatabaseSelection selection("", true, filter);
|
||||
|
||||
@@ -236,15 +232,15 @@ PrintUniqueTags(Response &r, Partition &partition,
|
||||
using namespace std::placeholders;
|
||||
const auto f = std::bind(PrintSongURIVisitor,
|
||||
std::ref(r), std::ref(partition), _1);
|
||||
return db->Visit(selection, f, error);
|
||||
return db.Visit(selection, f, error);
|
||||
} else {
|
||||
assert(type < TAG_NUM_OF_ITEM_TYPES);
|
||||
|
||||
using namespace std::placeholders;
|
||||
const auto f = std::bind(PrintUniqueTag, std::ref(r),
|
||||
(TagType)type, _1);
|
||||
return db->VisitUniqueTags(selection, (TagType)type,
|
||||
group_mask,
|
||||
f, error);
|
||||
return db.VisitUniqueTags(selection, (TagType)type,
|
||||
group_mask,
|
||||
f, error);
|
||||
}
|
||||
}
|
||||
|
@@ -41,11 +41,9 @@ bool
|
||||
AddFromDatabase(Partition &partition, const DatabaseSelection &selection,
|
||||
Error &error)
|
||||
{
|
||||
const Database *db = partition.instance.GetDatabase(error);
|
||||
if (db == nullptr)
|
||||
return false;
|
||||
const Database &db = partition.instance.GetDatabaseOrThrow();
|
||||
|
||||
using namespace std::placeholders;
|
||||
const auto f = std::bind(AddToQueue, std::ref(partition), _1);
|
||||
return db->Visit(selection, f, error);
|
||||
return db.Visit(selection, f, error);
|
||||
}
|
||||
|
Reference in New Issue
Block a user