db/UniqueTags, tag/Set, ...: use typedef tag_mask_t

This commit is contained in:
Max Kellermann 2015-08-24 11:53:30 +02:00
parent f3661b19c0
commit f0b58c6f24
14 changed files with 30 additions and 32 deletions

View File

@ -217,7 +217,7 @@ handle_list(Client &client, Request args, Response &r)
} }
SongFilter *filter = nullptr; SongFilter *filter = nullptr;
uint32_t group_mask = 0; tag_mask_t group_mask = 0;
if (args.size == 1) { if (args.size == 1) {
/* for compatibility with < 0.12.0 */ /* for compatibility with < 0.12.0 */
@ -241,7 +241,7 @@ handle_list(Client &client, Request args, Response &r)
return CommandResult::ERROR; return CommandResult::ERROR;
} }
group_mask |= 1u << unsigned(gt); group_mask |= tag_mask_t(1) << unsigned(gt);
args.pop_back(); args.pop_back();
args.pop_back(); args.pop_back();
@ -257,7 +257,7 @@ handle_list(Client &client, Request args, Response &r)
} }
if (tagType < TAG_NUM_OF_ITEM_TYPES && if (tagType < TAG_NUM_OF_ITEM_TYPES &&
group_mask & (1u << tagType)) { group_mask & (tag_mask_t(1) << tagType)) {
delete filter; delete filter;
r.Error(ACK_ERROR_ARG, "Conflicting group"); r.Error(ACK_ERROR_ARG, "Conflicting group");
return CommandResult::ERROR; return CommandResult::ERROR;

View File

@ -223,7 +223,7 @@ PrintUniqueTag(Response &r, TagType tag_type,
bool bool
PrintUniqueTags(Response &r, Partition &partition, PrintUniqueTags(Response &r, Partition &partition,
unsigned type, uint32_t group_mask, unsigned type, tag_mask_t group_mask,
const SongFilter *filter, const SongFilter *filter,
Error &error) Error &error)
{ {

View File

@ -20,10 +20,9 @@
#ifndef MPD_DB_PRINT_H #ifndef MPD_DB_PRINT_H
#define MPD_DB_PRINT_H #define MPD_DB_PRINT_H
#include "tag/Mask.hxx"
#include "Compiler.h" #include "Compiler.h"
#include <stdint.h>
class SongFilter; class SongFilter;
struct DatabaseSelection; struct DatabaseSelection;
struct Partition; struct Partition;
@ -49,7 +48,7 @@ db_selection_print(Response &r, Partition &partition,
bool bool
PrintUniqueTags(Response &r, Partition &partition, PrintUniqueTags(Response &r, Partition &partition,
unsigned type, uint32_t group_mask, unsigned type, tag_mask_t group_mask,
const SongFilter *filter, const SongFilter *filter,
Error &error); Error &error);

View File

@ -22,10 +22,10 @@
#include "Visitor.hxx" #include "Visitor.hxx"
#include "tag/TagType.h" #include "tag/TagType.h"
#include "tag/Mask.hxx"
#include "Compiler.h" #include "Compiler.h"
#include <time.h> #include <time.h>
#include <stdint.h>
struct DatabasePlugin; struct DatabasePlugin;
struct DatabaseStats; struct DatabaseStats;
@ -107,7 +107,7 @@ public:
* Visit all unique tag values. * Visit all unique tag values.
*/ */
virtual bool VisitUniqueTags(const DatabaseSelection &selection, virtual bool VisitUniqueTags(const DatabaseSelection &selection,
TagType tag_type, uint32_t group_mask, TagType tag_type, tag_mask_t group_mask,
VisitTag visit_tag, VisitTag visit_tag,
Error &error) const = 0; Error &error) const = 0;

View File

@ -27,7 +27,7 @@
#include <assert.h> #include <assert.h>
static bool static bool
CollectTags(TagSet &set, TagType tag_type, uint32_t group_mask, CollectTags(TagSet &set, TagType tag_type, tag_mask_t group_mask,
const LightSong &song) const LightSong &song)
{ {
assert(song.tag != nullptr); assert(song.tag != nullptr);
@ -39,7 +39,7 @@ CollectTags(TagSet &set, TagType tag_type, uint32_t group_mask,
bool bool
VisitUniqueTags(const Database &db, const DatabaseSelection &selection, VisitUniqueTags(const Database &db, const DatabaseSelection &selection,
TagType tag_type, uint32_t group_mask, TagType tag_type, tag_mask_t group_mask,
VisitTag visit_tag, VisitTag visit_tag,
Error &error) Error &error)
{ {

View File

@ -22,8 +22,7 @@
#include "Visitor.hxx" #include "Visitor.hxx"
#include "tag/TagType.h" #include "tag/TagType.h"
#include "tag/Mask.hxx"
#include <stdint.h>
class Error; class Error;
class Database; class Database;
@ -31,7 +30,7 @@ struct DatabaseSelection;
bool bool
VisitUniqueTags(const Database &db, const DatabaseSelection &selection, VisitUniqueTags(const Database &db, const DatabaseSelection &selection,
TagType tag_type, uint32_t group_mask, TagType tag_type, tag_mask_t group_mask,
VisitTag visit_tag, VisitTag visit_tag,
Error &error); Error &error);

View File

@ -85,7 +85,7 @@ LazyDatabase::Visit(const DatabaseSelection &selection,
bool bool
LazyDatabase::VisitUniqueTags(const DatabaseSelection &selection, LazyDatabase::VisitUniqueTags(const DatabaseSelection &selection,
TagType tag_type, uint32_t group_mask, TagType tag_type, tag_mask_t group_mask,
VisitTag visit_tag, VisitTag visit_tag,
Error &error) const Error &error) const
{ {

View File

@ -52,7 +52,7 @@ public:
Error &error) const override; Error &error) const override;
virtual bool VisitUniqueTags(const DatabaseSelection &selection, virtual bool VisitUniqueTags(const DatabaseSelection &selection,
TagType tag_type, uint32_t group_mask, TagType tag_type, tag_mask_t group_mask,
VisitTag visit_tag, VisitTag visit_tag,
Error &error) const override; Error &error) const override;

View File

@ -113,7 +113,7 @@ public:
Error &error) const override; Error &error) const override;
virtual bool VisitUniqueTags(const DatabaseSelection &selection, virtual bool VisitUniqueTags(const DatabaseSelection &selection,
TagType tag_type, uint32_t group_mask, TagType tag_type, tag_mask_t group_mask,
VisitTag visit_tag, VisitTag visit_tag,
Error &error) const override; Error &error) const override;
@ -757,7 +757,7 @@ ProxyDatabase::Visit(const DatabaseSelection &selection,
bool bool
ProxyDatabase::VisitUniqueTags(const DatabaseSelection &selection, ProxyDatabase::VisitUniqueTags(const DatabaseSelection &selection,
TagType tag_type, TagType tag_type,
gcc_unused uint32_t group_mask, gcc_unused tag_mask_t group_mask,
VisitTag visit_tag, VisitTag visit_tag,
Error &error) const Error &error) const
{ {

View File

@ -348,7 +348,7 @@ SimpleDatabase::Visit(const DatabaseSelection &selection,
bool bool
SimpleDatabase::VisitUniqueTags(const DatabaseSelection &selection, SimpleDatabase::VisitUniqueTags(const DatabaseSelection &selection,
TagType tag_type, uint32_t group_mask, TagType tag_type, tag_mask_t group_mask,
VisitTag visit_tag, VisitTag visit_tag,
Error &error) const Error &error) const
{ {

View File

@ -121,7 +121,7 @@ public:
Error &error) const override; Error &error) const override;
virtual bool VisitUniqueTags(const DatabaseSelection &selection, virtual bool VisitUniqueTags(const DatabaseSelection &selection,
TagType tag_type, uint32_t group_mask, TagType tag_type, tag_mask_t group_mask,
VisitTag visit_tag, VisitTag visit_tag,
Error &error) const override; Error &error) const override;

View File

@ -94,7 +94,7 @@ public:
Error &error) const override; Error &error) const override;
virtual bool VisitUniqueTags(const DatabaseSelection &selection, virtual bool VisitUniqueTags(const DatabaseSelection &selection,
TagType tag_type, uint32_t group_mask, TagType tag_type, tag_mask_t group_mask,
VisitTag visit_tag, VisitTag visit_tag,
Error &error) const override; Error &error) const override;
@ -723,7 +723,7 @@ UpnpDatabase::Visit(const DatabaseSelection &selection,
bool bool
UpnpDatabase::VisitUniqueTags(const DatabaseSelection &selection, UpnpDatabase::VisitUniqueTags(const DatabaseSelection &selection,
TagType tag, gcc_unused uint32_t group_mask, TagType tag, gcc_unused tag_mask_t group_mask,
VisitTag visit_tag, VisitTag visit_tag,
Error &error) const Error &error) const
{ {

View File

@ -58,16 +58,16 @@ CopyTagItem(TagBuilder &dest, const Tag &src, TagType type)
* Copy all tag items of the types in the mask. * Copy all tag items of the types in the mask.
*/ */
static void static void
CopyTagMask(TagBuilder &dest, const Tag &src, uint32_t mask) CopyTagMask(TagBuilder &dest, const Tag &src, tag_mask_t mask)
{ {
for (unsigned i = 0; i < TAG_NUM_OF_ITEM_TYPES; ++i) for (unsigned i = 0; i < TAG_NUM_OF_ITEM_TYPES; ++i)
if ((mask & (1u << i)) != 0) if ((mask & (tag_mask_t(1) << i)) != 0)
CopyTagItem(dest, src, TagType(i)); CopyTagItem(dest, src, TagType(i));
} }
void void
TagSet::InsertUnique(const Tag &src, TagType type, const char *value, TagSet::InsertUnique(const Tag &src, TagType type, const char *value,
uint32_t group_mask) tag_mask_t group_mask)
{ {
TagBuilder builder; TagBuilder builder;
if (value == nullptr) if (value == nullptr)
@ -85,7 +85,7 @@ TagSet::InsertUnique(const Tag &src, TagType type, const char *value,
bool bool
TagSet::CheckUnique(TagType dest_type, TagSet::CheckUnique(TagType dest_type,
const Tag &tag, TagType src_type, const Tag &tag, TagType src_type,
uint32_t group_mask) tag_mask_t group_mask)
{ {
bool found = false; bool found = false;
@ -101,12 +101,12 @@ TagSet::CheckUnique(TagType dest_type,
void void
TagSet::InsertUnique(const Tag &tag, TagSet::InsertUnique(const Tag &tag,
TagType type, uint32_t group_mask) TagType type, tag_mask_t group_mask)
{ {
static_assert(sizeof(group_mask) * 8 >= TAG_NUM_OF_ITEM_TYPES, static_assert(sizeof(group_mask) * 8 >= TAG_NUM_OF_ITEM_TYPES,
"Mask is too small"); "Mask is too small");
assert((group_mask & (1u << unsigned(type))) == 0); assert((group_mask & (tag_mask_t(1) << unsigned(type))) == 0);
if (!CheckUnique(type, tag, type, group_mask) && if (!CheckUnique(type, tag, type, group_mask) &&
(type != TAG_ALBUM_ARTIST || (type != TAG_ALBUM_ARTIST ||

View File

@ -22,11 +22,11 @@
#include "Compiler.h" #include "Compiler.h"
#include "Tag.hxx" #include "Tag.hxx"
#include "Mask.hxx"
#include <set> #include <set>
#include <string.h> #include <string.h>
#include <stdint.h>
/** /**
* Helper class for #TagSet which compares two #Tag objects. * Helper class for #TagSet which compares two #Tag objects.
@ -59,15 +59,15 @@ struct TagLess {
class TagSet : public std::set<Tag, TagLess> { class TagSet : public std::set<Tag, TagLess> {
public: public:
void InsertUnique(const Tag &tag, void InsertUnique(const Tag &tag,
TagType type, uint32_t group_mask); TagType type, tag_mask_t group_mask);
private: private:
void InsertUnique(const Tag &src, TagType type, const char *value, void InsertUnique(const Tag &src, TagType type, const char *value,
uint32_t group_mask); tag_mask_t group_mask);
bool CheckUnique(TagType dest_type, bool CheckUnique(TagType dest_type,
const Tag &tag, TagType src_type, const Tag &tag, TagType src_type,
uint32_t group_mask); tag_mask_t group_mask);
}; };
#endif #endif