core/tags/artist: Add artist_match_token() function
This is called to check if any string in an artist's token list is prefixed by the given string. Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This commit is contained in:
parent
b643b532d7
commit
a70b27779f
|
@ -94,6 +94,11 @@ int artist_compare(struct artist *lhs, struct artist *rhs)
|
||||||
return string_compare_tokens(lhs->ar_tokens, rhs->ar_tokens);
|
return string_compare_tokens(lhs->ar_tokens, rhs->ar_tokens);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool artist_match_token(struct artist *artist, const gchar *string)
|
||||||
|
{
|
||||||
|
return string_match_token(string, artist->ar_tokens) ||
|
||||||
|
string_match_token(string, artist->ar_alts);
|
||||||
|
}
|
||||||
#ifdef CONFIG_TESTING
|
#ifdef CONFIG_TESTING
|
||||||
const struct db_ops *test_artist_ops() { return &artist_ops; }
|
const struct db_ops *test_artist_ops() { return &artist_ops; }
|
||||||
#endif /* CONFIG_TESTING */
|
#endif /* CONFIG_TESTING */
|
||||||
|
|
|
@ -49,6 +49,9 @@ struct artist *artist_get(const unsigned int);
|
||||||
/* Called to compare two artist tags. */
|
/* Called to compare two artist tags. */
|
||||||
int artist_compare(struct artist *, struct artist *);
|
int artist_compare(struct artist *, struct artist *);
|
||||||
|
|
||||||
|
/* Called to check if an artist has a token that matches the given string. */
|
||||||
|
bool artist_match_token(struct artist *artist, const gchar *);
|
||||||
|
|
||||||
#ifdef CONFIG_TESTING
|
#ifdef CONFIG_TESTING
|
||||||
const struct db_ops *test_artist_ops();
|
const struct db_ops *test_artist_ops();
|
||||||
#endif /* CONFIG_TESTING */
|
#endif /* CONFIG_TESTING */
|
||||||
|
|
|
@ -34,7 +34,11 @@ static void test_artist()
|
||||||
struct file f;
|
struct file f;
|
||||||
|
|
||||||
artist = ARTIST(artist_ops->dbe_alloc("Koji Kondo"));
|
artist = ARTIST(artist_ops->dbe_alloc("Koji Kondo"));
|
||||||
|
|
||||||
test_verify_koji(artist);
|
test_verify_koji(artist);
|
||||||
|
test_equal(artist_match_token(artist, "koji"), (bool)true);
|
||||||
|
test_equal(artist_match_token(artist, "kondo"), (bool)true);
|
||||||
|
test_equal(artist_match_token(artist, "hajime"), (bool)false);
|
||||||
|
|
||||||
file_init(&f, "artist_tag", 0, 0);
|
file_init(&f, "artist_tag", 0, 0);
|
||||||
file_open(&f, OPEN_WRITE);
|
file_open(&f, OPEN_WRITE);
|
||||||
|
|
Loading…
Reference in New Issue