From 4fcfb3c85194f4c2ef1081b19d1c7bfa6dfa0250 Mon Sep 17 00:00:00 2001 From: Andrzej Rybczak Date: Sun, 26 Mar 2017 10:59:55 +0200 Subject: [PATCH] Add conversion from GetFunction to tag type --- src/format.h | 10 +++++++--- src/utility/type_conversions.cpp | 30 ++++++++++++++++++++++++++++++ src/utility/type_conversions.h | 4 ++++ 3 files changed, 41 insertions(+), 3 deletions(-) diff --git a/src/format.h b/src/format.h index 06001efe..03dd121e 100644 --- a/src/format.h +++ b/src/format.h @@ -60,9 +60,13 @@ private: unsigned m_delimiter; }; -template using SongTagMap = std::vector< - std::pair > ->; +template +using SongTagMap = std::vector< + std::pair< + SongTag, + std::basic_string + > + >; enum class Result { Empty, Missing, Ok }; diff --git a/src/utility/type_conversions.cpp b/src/utility/type_conversions.cpp index 67c63550..6e460e5a 100644 --- a/src/utility/type_conversions.cpp +++ b/src/utility/type_conversions.cpp @@ -199,6 +199,36 @@ MPD::Song::GetFunction charToGetFunction(char c) } } +boost::optional getFunctionToTagType(MPD::Song::GetFunction f) +{ + if (f == &MPD::Song::getArtist) + return MPD_TAG_ARTIST; + else if (f == &MPD::Song::getTitle) + return MPD_TAG_TITLE; + else if (f == &MPD::Song::getAlbum) + return MPD_TAG_ALBUM; + else if (f == &MPD::Song::getAlbumArtist) + return MPD_TAG_ALBUM_ARTIST; + else if (f == &MPD::Song::getTrack) + return MPD_TAG_TRACK; + else if (f == &MPD::Song::getDate) + return MPD_TAG_DATE; + else if (f == &MPD::Song::getGenre) + return MPD_TAG_GENRE; + else if (f == &MPD::Song::getComposer) + return MPD_TAG_COMPOSER; + else if (f == &MPD::Song::getPerformer) + return MPD_TAG_PERFORMER; + else if (f == &MPD::Song::getComment) + return MPD_TAG_COMMENT; + else if (f == &MPD::Song::getDisc) + return MPD_TAG_DISC; + else if (f == &MPD::Song::getComment) + return MPD_TAG_COMMENT; + else + return boost::none; +} + std::string itemTypeToString(MPD::Item::Type type) { std::string result; diff --git a/src/utility/type_conversions.h b/src/utility/type_conversions.h index 3f97ef19..43c1da9b 100644 --- a/src/utility/type_conversions.h +++ b/src/utility/type_conversions.h @@ -21,6 +21,8 @@ #ifndef NCMPCPP_UTILITY_TYPE_CONVERSIONS_H #define NCMPCPP_UTILITY_TYPE_CONVERSIONS_H +#include + #include "curses/window.h" #include "mpdpp.h" #include "mutable_song.h" @@ -36,6 +38,8 @@ MPD::MutableSong::SetFunction tagTypeToSetFunction(mpd_tag_type tag); mpd_tag_type charToTagType(char c); MPD::Song::GetFunction charToGetFunction(char c); +boost::optional getFunctionToTagType(MPD::Song::GetFunction f); + std::string itemTypeToString(MPD::Item::Type type); #endif // NCMPCPP_UTILITY_TYPE_CONVERSIONS_H