diff options
| author | manuel <manuel@mausz.at> | 2020-10-19 00:52:24 +0200 |
|---|---|---|
| committer | manuel <manuel@mausz.at> | 2020-10-19 00:52:24 +0200 |
| commit | be933ef2241d79558f91796cc5b3a161f72ebf9c (patch) | |
| tree | fe3ab2f130e20c99001f2d7a81d610c78c96a3f4 /xbmc/utils/LabelFormatter.h | |
| parent | 5f8335c1e49ce108ef3481863833c98efa00411b (diff) | |
| download | kodi-pvr-build-be933ef2241d79558f91796cc5b3a161f72ebf9c.tar.gz kodi-pvr-build-be933ef2241d79558f91796cc5b3a161f72ebf9c.tar.bz2 kodi-pvr-build-be933ef2241d79558f91796cc5b3a161f72ebf9c.zip | |
sync with upstream
Diffstat (limited to 'xbmc/utils/LabelFormatter.h')
| -rw-r--r-- | xbmc/utils/LabelFormatter.h | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/xbmc/utils/LabelFormatter.h b/xbmc/utils/LabelFormatter.h new file mode 100644 index 0000000..a10eae6 --- /dev/null +++ b/xbmc/utils/LabelFormatter.h | |||
| @@ -0,0 +1,76 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2005-2018 Team Kodi | ||
| 3 | * This file is part of Kodi - https://kodi.tv | ||
| 4 | * | ||
| 5 | * SPDX-License-Identifier: GPL-2.0-or-later | ||
| 6 | * See LICENSES/README.md for more information. | ||
| 7 | */ | ||
| 8 | |||
| 9 | #pragma once | ||
| 10 | |||
| 11 | #include <string> | ||
| 12 | #include <vector> | ||
| 13 | |||
| 14 | namespace MUSIC_INFO | ||
| 15 | { | ||
| 16 | class CMusicInfoTag; | ||
| 17 | } | ||
| 18 | |||
| 19 | class CFileItem; // forward | ||
| 20 | |||
| 21 | struct LABEL_MASKS | ||
| 22 | { | ||
| 23 | LABEL_MASKS(const std::string& strLabelFile="", const std::string& strLabel2File="", const std::string& strLabelFolder="", const std::string& strLabel2Folder="") : | ||
| 24 | m_strLabelFile(strLabelFile), | ||
| 25 | m_strLabel2File(strLabel2File), | ||
| 26 | m_strLabelFolder(strLabelFolder), | ||
| 27 | m_strLabel2Folder(strLabel2Folder) | ||
| 28 | {} | ||
| 29 | std::string m_strLabelFile; | ||
| 30 | std::string m_strLabel2File; | ||
| 31 | std::string m_strLabelFolder; | ||
| 32 | std::string m_strLabel2Folder; | ||
| 33 | }; | ||
| 34 | |||
| 35 | class CLabelFormatter | ||
| 36 | { | ||
| 37 | public: | ||
| 38 | CLabelFormatter(const std::string &mask, const std::string &mask2); | ||
| 39 | |||
| 40 | void FormatLabel(CFileItem *item) const; | ||
| 41 | void FormatLabel2(CFileItem *item) const; | ||
| 42 | void FormatLabels(CFileItem *item) const // convenient shorthand | ||
| 43 | { | ||
| 44 | FormatLabel(item); | ||
| 45 | FormatLabel2(item); | ||
| 46 | } | ||
| 47 | |||
| 48 | bool FillMusicTag(const std::string &fileName, MUSIC_INFO::CMusicInfoTag *tag) const; | ||
| 49 | |||
| 50 | private: | ||
| 51 | class CMaskString | ||
| 52 | { | ||
| 53 | public: | ||
| 54 | CMaskString(const std::string &prefix, char content, const std::string &postfix) : | ||
| 55 | m_prefix(prefix), | ||
| 56 | m_postfix(postfix), | ||
| 57 | m_content(content) | ||
| 58 | {}; | ||
| 59 | std::string m_prefix; | ||
| 60 | std::string m_postfix; | ||
| 61 | char m_content; | ||
| 62 | }; | ||
| 63 | |||
| 64 | // functions for assembling the mask vectors | ||
| 65 | void AssembleMask(unsigned int label, const std::string &mask); | ||
| 66 | void SplitMask(unsigned int label, const std::string &mask); | ||
| 67 | |||
| 68 | // functions for retrieving content based on our mask vectors | ||
| 69 | std::string GetContent(unsigned int label, const CFileItem *item) const; | ||
| 70 | std::string GetMaskContent(const CMaskString &mask, const CFileItem *item) const; | ||
| 71 | void FillMusicMaskContent(const char mask, const std::string &value, MUSIC_INFO::CMusicInfoTag *tag) const; | ||
| 72 | |||
| 73 | std::vector<std::string> m_staticContent[2]; | ||
| 74 | std::vector<CMaskString> m_dynamicContent[2]; | ||
| 75 | bool m_hideFileExtensions; | ||
| 76 | }; | ||
