a50d8f6e0a
This allows me to have a std::pair<> as a key if needed. Signed-off-by: Anna Schumaker <schumaker.anna@gmail.com>
47 lines
959 B
C++
47 lines
959 B
C++
/*
|
|
* Copyright 2013 (c) Anna Schumaker.
|
|
*/
|
|
#include <database.h>
|
|
#include <group.h>
|
|
|
|
static std::set<unsigned int> empty_set;
|
|
Database<IndexEntry, const std::string> group_index("");
|
|
|
|
void group :: add(const std::string &name, unsigned int track_id)
|
|
{
|
|
if ((name == "All Music") || (name == "Library") || (name == "Banned")) {
|
|
try {
|
|
index_insert(group_index, name, track_id);
|
|
} catch (...) {
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
|
|
void group :: del(const std::string &name, unsigned int track_id)
|
|
{
|
|
if ((name == "All Music") || (name == "Library") || (name == "Banned")) {
|
|
try {
|
|
index_remove(group_index, name, track_id);
|
|
} catch (...) {
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
|
|
void group :: list(std::list<std::string> &res)
|
|
{
|
|
res.push_back("All Music");
|
|
res.push_back("Library");
|
|
res.push_back("Banned");
|
|
}
|
|
|
|
const std::set<unsigned int> &group :: get_tracks(const std::string &name)
|
|
{
|
|
try {
|
|
return group_index.find(name).values;
|
|
} catch (...) {
|
|
return empty_set;
|
|
}
|
|
}
|