Commit 60c077c7 authored by Max Kellermann's avatar Max Kellermann

tag/Settings: add function IsTagEnabled() wrapping access to ignore_tag_items[]

parent 7aaa4dda
...@@ -27,7 +27,7 @@ void ...@@ -27,7 +27,7 @@ void
tag_print_types(Response &r) tag_print_types(Response &r)
{ {
for (unsigned i = 0; i < TAG_NUM_OF_ITEM_TYPES; i++) for (unsigned i = 0; i < TAG_NUM_OF_ITEM_TYPES; i++)
if (!ignore_tag_items[i]) if (IsTagEnabled(i))
r.Format("tagtype: %s\n", tag_item_names[i]); r.Format("tagtype: %s\n", tag_item_names[i]);
} }
......
...@@ -58,7 +58,7 @@ db_save_internal(BufferedOutputStream &os, const Directory &music_root) ...@@ -58,7 +58,7 @@ db_save_internal(BufferedOutputStream &os, const Directory &music_root)
os.Format("%s%s\n", DIRECTORY_FS_CHARSET, GetFSCharset()); os.Format("%s%s\n", DIRECTORY_FS_CHARSET, GetFSCharset());
for (unsigned i = 0; i < TAG_NUM_OF_ITEM_TYPES; ++i) for (unsigned i = 0; i < TAG_NUM_OF_ITEM_TYPES; ++i)
if (!ignore_tag_items[i]) if (IsTagEnabled(i))
os.Format(DB_TAG_PREFIX "%s\n", tag_item_names[i]); os.Format(DB_TAG_PREFIX "%s\n", tag_item_names[i]);
os.Format("%s\n", DIRECTORY_INFO_END); os.Format("%s\n", DIRECTORY_INFO_END);
...@@ -142,7 +142,7 @@ db_load_internal(TextFile &file, Directory &music_root, Error &error) ...@@ -142,7 +142,7 @@ db_load_internal(TextFile &file, Directory &music_root, Error &error)
} }
for (unsigned i = 0; i < TAG_NUM_OF_ITEM_TYPES; ++i) { for (unsigned i = 0; i < TAG_NUM_OF_ITEM_TYPES; ++i) {
if (!ignore_tag_items[i] && !tags[i]) { if (IsTagEnabled(i) && !tags[i]) {
error.Set(db_domain, error.Set(db_domain,
"Tag list mismatch, " "Tag list mismatch, "
"discarding database file"); "discarding database file");
......
...@@ -110,7 +110,7 @@ TagSet::InsertUnique(const Tag &tag, ...@@ -110,7 +110,7 @@ TagSet::InsertUnique(const Tag &tag,
if (!CheckUnique(type, tag, type, group_mask) && if (!CheckUnique(type, tag, type, group_mask) &&
(type != TAG_ALBUM_ARTIST || (type != TAG_ALBUM_ARTIST ||
ignore_tag_items[TAG_ALBUM_ARTIST] || !IsTagEnabled(TAG_ALBUM_ARTIST) ||
/* fall back to "Artist" if no "AlbumArtist" was found */ /* fall back to "Artist" if no "AlbumArtist" was found */
!CheckUnique(type, tag, TAG_ARTIST, group_mask))) !CheckUnique(type, tag, TAG_ARTIST, group_mask)))
InsertUnique(tag, type, nullptr, group_mask); InsertUnique(tag, type, nullptr, group_mask);
......
...@@ -220,7 +220,7 @@ TagBuilder::AddItem(TagType type, const char *value, size_t length) ...@@ -220,7 +220,7 @@ TagBuilder::AddItem(TagType type, const char *value, size_t length)
assert(value != nullptr); assert(value != nullptr);
#endif #endif
if (length == 0 || ignore_tag_items[type]) if (length == 0 || !IsTagEnabled(type))
return; return;
AddItemInternal(type, value, length); AddItemInternal(type, value, length);
......
...@@ -21,9 +21,28 @@ ...@@ -21,9 +21,28 @@
#define MPD_TAG_SETTINGS_H #define MPD_TAG_SETTINGS_H
#include "TagType.h" #include "TagType.h"
#include "Compiler.h"
#include <stdbool.h> #include <stdbool.h>
extern bool ignore_tag_items[TAG_NUM_OF_ITEM_TYPES]; extern bool ignore_tag_items[TAG_NUM_OF_ITEM_TYPES];
#ifdef __cplusplus
gcc_const
static inline bool
IsTagEnabled(unsigned tag)
{
return !ignore_tag_items[tag];
}
gcc_const
static inline bool
IsTagEnabled(TagType tag)
{
return IsTagEnabled(unsigned(tag));
}
#endif
#endif #endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment