library: Clean up database entry creation
Passing the TagLib :: Tag pointer is much easier and cuts down on extra arguments to each constructor. Signed-off-by: Anna Schumaker <schumaker.anna@gmail.com>
This commit is contained in:
parent
3f943aa1d6
commit
846810fa2f
|
@ -7,6 +7,8 @@
|
|||
#include <database.h>
|
||||
#include <string>
|
||||
|
||||
#include <taglib/tag.h>
|
||||
|
||||
namespace library
|
||||
{
|
||||
|
||||
|
@ -24,7 +26,7 @@ namespace library
|
|||
std:: string name;
|
||||
|
||||
Artist();
|
||||
Artist(const std :: string &);
|
||||
Artist(TagLib :: Tag *);
|
||||
void read(File &);
|
||||
void write(File &);
|
||||
#ifdef CONFIG_DEBUG
|
||||
|
@ -41,7 +43,7 @@ namespace library
|
|||
unsigned int artist_id;
|
||||
|
||||
Album();
|
||||
Album(const std :: string &, unsigned int, unsigned int);
|
||||
Album(TagLib :: Tag *, unsigned int);
|
||||
void read(File &);
|
||||
void write(File &);
|
||||
#ifdef CONFIG_DEBUG
|
||||
|
@ -56,7 +58,7 @@ namespace library
|
|||
std:: string name;
|
||||
|
||||
Genre();
|
||||
Genre(const std :: string &);
|
||||
Genre(TagLib :: Tag *);
|
||||
void read(File &);
|
||||
void write(File &);
|
||||
#ifdef CONFIG_DEBUG
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
#include <library.h>
|
||||
|
||||
#include <glib.h>
|
||||
#include <taglib/tag.h>
|
||||
#include <taglib/fileref.h>
|
||||
|
||||
static Database<library :: Artist> artist_db("artist.db", DB_UNIQUE);
|
||||
|
@ -23,8 +22,8 @@ library :: Artist :: Artist()
|
|||
{
|
||||
}
|
||||
|
||||
library :: Artist :: Artist(const std::string &artist_name)
|
||||
: name(artist_name)
|
||||
library :: Artist :: Artist(TagLib :: Tag *tag)
|
||||
: name(tag->artist().to8Bit(true))
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -60,9 +59,8 @@ library :: Album :: Album()
|
|||
{
|
||||
}
|
||||
|
||||
library :: Album :: Album(const std :: string &album_name, unsigned int album_year,
|
||||
unsigned int artist)
|
||||
: name(album_name), year(album_year), artist_id(artist)
|
||||
library :: Album :: Album(TagLib :: Tag *tag, unsigned int artist)
|
||||
: name(tag->album().to8Bit(true)), year(tag->year()), artist_id(artist)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -104,8 +102,8 @@ library :: Genre :: Genre()
|
|||
{
|
||||
}
|
||||
|
||||
library :: Genre :: Genre(const std::string &artist_name)
|
||||
: name(artist_name)
|
||||
library :: Genre :: Genre(TagLib :: Tag *tag)
|
||||
: name(tag->genre().to8Bit(true))
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -193,9 +191,9 @@ static void read_tags(unsigned int lib_id, const std :: string &path)
|
|||
}
|
||||
|
||||
tag = ref.tag();
|
||||
artist_id = artist_db.insert(library :: Artist(tag->artist().to8Bit(true)));
|
||||
album_db.insert(library :: Album(tag->album().to8Bit(true), tag->year(), artist_id));
|
||||
genre_db.insert(library :: Genre(tag->genre().to8Bit(true)));
|
||||
artist_id = artist_db.insert(tag);
|
||||
album_db.insert(library :: Album(tag, artist_id));
|
||||
genre_db.insert(library :: Genre(tag));
|
||||
}
|
||||
|
||||
static void process_path(unsigned int lib_id, const std :: string &dir,
|
||||
|
|
Loading…
Reference in New Issue