360ebed1fa
Gstreamer includes <errno.h>, which already defines several of these symbols. I rename them to avoid namespace collisions. Perhaps a better solution would be to use the errno.h definitions directly? Signed-off-by: Anna Schumaker <schumaker.anna@gmail.com>
52 lines
1.0 KiB
C++
52 lines
1.0 KiB
C++
/*
|
|
* Copyright 2013 (c) Anna Schumaker.
|
|
*/
|
|
#include <database.h>
|
|
#include <error.h>
|
|
#include <playlist.h>
|
|
|
|
static std::set<unsigned int> empty_set;
|
|
static Database<IndexEntry> playlist_db("playlist.db");
|
|
|
|
void playlist :: init()
|
|
{
|
|
playlist_db.load();
|
|
}
|
|
|
|
void playlist :: add(const std::string &name, unsigned int track_id)
|
|
{
|
|
if ((name == "Banned") || (name == "Favorites")) {
|
|
index_insert(playlist_db, name, track_id);
|
|
playlist_db.save();
|
|
} else
|
|
throw -E_EXIST;
|
|
}
|
|
|
|
void playlist :: del(const std::string &name, unsigned int track_id)
|
|
{
|
|
if ((name == "Banned") || (name == "Favorites")) {
|
|
index_remove(playlist_db, name, track_id);
|
|
playlist_db.save();
|
|
} else
|
|
throw -E_EXIST;
|
|
}
|
|
|
|
const std::set<unsigned int> &playlist :: get_tracks(const std::string &name)
|
|
{
|
|
if ((name == "Banned") || (name == "Favorites")) {
|
|
try {
|
|
return playlist_db.find(name).values;
|
|
} catch (int error) {
|
|
return empty_set;
|
|
}
|
|
}
|
|
throw -E_EXIST;
|
|
}
|
|
|
|
#ifdef CONFIG_TEST
|
|
void playlist :: clear()
|
|
{
|
|
playlist_db.clear();
|
|
}
|
|
#endif /* CONFIG_TEST */
|