xref: /MusicPlayer2/MusicPlayer2/CueFile.h (revision dd6bf2b0c9461553c798b899dfd7fa664f31fe6e)
1 #pragma once
2 #include "SongInfo.h"
3 #include "Common.h"
4 
5 class CCueFile
6 {
7 public:
8     CCueFile(const std::wstring& file_path);
9     CCueFile();
10     ~CCueFile();
11 
12     // 使用移动语义覆盖参数song_list,调用后此CCueFile对象不再可用
13     void MoveToSongList(vector<SongInfo>& song_list);
14     std::vector<SongInfo>& GetAnalysisResult();
15 
16     //将所有cue音轨保存到cue文件
17     //如果file_path为空,则保存到m_file_path
18     bool Save(std::wstring file_path = std::wstring());
19 
20     //从解析结果中获取一个音轨信息
21     SongInfo& GetTrackInfo(const std::wstring& audio_path, int track);
22 
23     const std::map<std::wstring, std::wstring>& GetCuePropertyMap() const;
24     const std::map<std::wstring, std::wstring>& GetTrackPropertyMap(const std::wstring& audio_path, int track);
25 
26 private:
27     void DoAnalysis();
28     static wstring GetCommand(const wstring& str_contents, const wstring& str, size_t pos = 0);
29 
30     //查找str_contents中的所有属性,并添加到property_map中
31     static void FindAllProperty(const wstring& str_contents, std::map<std::wstring, std::wstring>& property_map);
32 
33 private:
34     std::wstring m_file_path;
35     std::wstring m_file_content_wcs;
36     CodeType m_code_type{ CodeType::AUTO };
37     std::vector<SongInfo> m_result;
38     std::map<std::wstring, std::wstring> m_cue_property_map;        //保存整个cue共享的属性
39     std::map<std::wstring, std::map<int, std::map<std::wstring, std::wstring>>> m_track_property_maps;  //保存cue中每个音频文件每个音轨的属性
40 };
41 
42