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

View File

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

View File

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

View File

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

View File

@ -27,7 +27,7 @@
#include <assert.h>
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)
{
assert(song.tag != nullptr);
@ -39,7 +39,7 @@ CollectTags(TagSet &set, TagType tag_type, uint32_t group_mask,
bool
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,
Error &error)
{

View File

@ -22,8 +22,7 @@
#include "Visitor.hxx"
#include "tag/TagType.h"
#include <stdint.h>
#include "tag/Mask.hxx"
class Error;
class Database;
@ -31,7 +30,7 @@ struct DatabaseSelection;
bool
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,
Error &error);

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -94,7 +94,7 @@ public:
Error &error) const override;
virtual bool VisitUniqueTags(const DatabaseSelection &selection,
TagType tag_type, uint32_t group_mask,
TagType tag_type, tag_mask_t group_mask,
VisitTag visit_tag,
Error &error) const override;
@ -723,7 +723,7 @@ UpnpDatabase::Visit(const DatabaseSelection &selection,
bool
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,
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.
*/
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)
if ((mask & (1u << i)) != 0)
if ((mask & (tag_mask_t(1) << i)) != 0)
CopyTagItem(dest, src, TagType(i));
}
void
TagSet::InsertUnique(const Tag &src, TagType type, const char *value,
uint32_t group_mask)
tag_mask_t group_mask)
{
TagBuilder builder;
if (value == nullptr)
@ -85,7 +85,7 @@ TagSet::InsertUnique(const Tag &src, TagType type, const char *value,
bool
TagSet::CheckUnique(TagType dest_type,
const Tag &tag, TagType src_type,
uint32_t group_mask)
tag_mask_t group_mask)
{
bool found = false;
@ -101,12 +101,12 @@ TagSet::CheckUnique(TagType dest_type,
void
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,
"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) &&
(type != TAG_ALBUM_ARTIST ||

View File

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