core/tags/album: Convert file to C

Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This commit is contained in:
Anna Schumaker 2015-11-11 09:15:25 -05:00
parent ad48d24533
commit 5309ea5931
6 changed files with 25 additions and 29 deletions

View File

@ -1,9 +1,7 @@
/**
/*
* Copyright 2014 (c) Anna Schumaker.
*/
extern "C" {
#include <core/string.h>
}
#include <core/tags/album.h>
@ -16,7 +14,7 @@ static gchar *__album_key(const gchar *name, unsigned int year)
static struct album *__album_alloc(gchar *name, unsigned int year)
{
struct album *album = new struct album;
struct album *album = g_malloc(sizeof(struct album));
dbe_init(&album->al_dbe, album);
album->al_year = year;
@ -41,7 +39,7 @@ static void album_free(struct db_entry *dbe)
{
g_free(ALBUM(dbe)->al_name);
g_free(ALBUM(dbe)->al_lower);
delete ALBUM(dbe);
g_free(ALBUM(dbe));
}
static gchar *album_key(struct db_entry *dbe)

View File

@ -1,7 +1,9 @@
/**
* Copyright 2014 (c) Anna Schumaker.
*/
extern "C" {
#include <core/tags/album.h>
}
#include <core/tags/artist.h>
#include <core/tags/genre.h>
#include <core/tags/library.h>

View File

@ -1,25 +1,21 @@
/**
/*
* Copyright 2014 (c) Anna Schumaker.
*
* The album tag is used to store the name and year of albums
* added to the tag database.
*
* When writing an album tag to disk, write out the album_year field
* followed by the album_name on the same line:
*
* ... 1998 Hyrule Symphony
* ... 2006 Twilight Princess
* ... 2011 Skyward Sword
*/
#ifndef OCARINA_CORE_TAGS_ALBUM_H
#define OCARINA_CORE_TAGS_ALBUM_H
extern "C" {
#include <core/database.h>
}
#include <string>
/**
* The Album tag is used to store the name and year of albums
* added to the tag database.
*
* When writing an Album tag to disk, write out the _year field and
* then call GenericTag to write anything else.
*
* ... << year1 << GenericTag::write()
* ... << year2 << GenericTag::write()
* ... << year3 << GenericTag::write()
*/
struct album {
unsigned int al_year; /* This album's year. */
gchar *al_name; /* This album's name. */

View File

@ -7,9 +7,9 @@
extern "C" {
#include <core/database.h>
#include <core/date.h>
#include <core/tags/album.h>
}
#include <core/tags/artist.h>
#include <core/tags/album.h>
#include <core/tags/genre.h>
#include <core/tags/library.h>

View File

@ -11,8 +11,8 @@ def TagTest(name, source):
Alias("tests/core/tags", run)
return run
res = [ TagTest("artist", "artist.cpp") ]
res += [ TagTest("album", "album.cpp") ]
res = [ TagTest("album", "album.c") ]
res += [ TagTest("artist", "artist.cpp") ]
res += [ TagTest("genre", "genre.cpp") ]
res += [ TagTest("library", "library.cpp") ]

View File

@ -1,8 +1,8 @@
/**
/*
* Copyright 2014 (c) Anna Schumaker.
*/
#include <core/tags/album.h>
#include "../test.h"
#include <tests/test.h>
static void test_verify_empty(struct album *album)
{
@ -26,7 +26,7 @@ static void test_album()
{
const struct db_ops *album_ops = test_album_ops();
struct album *album;
file f;
struct file f;
album = ALBUM(album_ops->dbe_alloc("1998/Hyrule Symphony"));
test_verify_hyrule(album);
@ -76,9 +76,9 @@ static void test_album_db()
test_verify_hyrule(album);
test_equal(album_find("Hyrule Symphony", 1998), album);
test_equal(album_get(0), album);
test_equal(album_get(1), (struct album *)NULL);
test_equal((void *)album_find("Hyrule Symphony", 1998), (void *)album);
test_equal((void *)album_get(0), (void *)album);
test_equal((void *)album_get(1), (void *)NULL);
db_init(&album_db, "album.db", false, album_ops);
db_load(&album_db);