xref: /MusicPlayer2/MusicPlayer2/MediaLibHelper.h (revision 965ce478a79b0d21e8a6e2ade0490efa175855dd)
1 #pragma once
2 #include "SongInfo.h"
3 
4 #define STR_OTHER_CLASSIFY_TYPE L"eRk0Q6ov"
5 
6 //不区分大小写的字符串比较器
7 struct StringComparerNoCase
8 {
9     bool operator()(const std::wstring& a, const std::wstring& b) const;
10 };
11 
12 class CMediaClassifier
13 {
14 public:
15     enum ClassificationType
16     {
17         CT_ARTIST,
18         CT_ALBUM,
19         CT_GENRE,
20         CT_YEAR,
21         CT_TYPE,
22         CT_BITRATE,
23         CT_RATING,
24         CT_NONE,
25         CT_MAX
26     };
27 
28     typedef std::map<std::wstring, std::vector<SongInfo>, StringComparerNoCase> MediaList;      //定义保存分类结果的map容器,使用不区分大小写的比较器,以实现分类时不区分大小写
29 
30 public:
31     CMediaClassifier(ClassificationType type, bool hide_only_one_classification = false);
32     ~CMediaClassifier();
33 
34     const MediaList& GetMeidaList() const;
35     MediaList& GetMeidaList();
36     void ClassifyMedia();
37     static bool IsStringYear(std::wstring str);
38     void ClearResult();
39     void RemoveFiles(std::vector<SongInfo> songs);      //从结果中删除指定文件
40     void SetHideOnlyOneClassification(bool hide_only_one_classification);
41 
42 private:
43 
44 private:
45     MediaList m_media_list;
46     ClassificationType m_type;
47     bool m_hide_only_one_classification;       //如果为true,则把只有一项的类别归到“其他”里面
48 };
49