1 /***************************************************************************
2 * Copyright (C) 2008-2016 by Andrzej Rybczak *
3 * electricityispower@gmail.com *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
19 ***************************************************************************/
22 #include "utility/type_conversions.h"
24 NC::Color
charToColor(char c
)
29 return NC::Color::Default
;
31 return NC::Color::Black
;
33 return NC::Color::Red
;
35 return NC::Color::Green
;
37 return NC::Color::Yellow
;
39 return NC::Color::Blue
;
41 return NC::Color::Magenta
;
43 return NC::Color::Cyan
;
45 return NC::Color::White
;
47 return NC::Color::End
;
49 throw std::runtime_error("invalid character");
53 std::string
tagTypeToString(mpd_tag_type tag
)
61 case MPD_TAG_ALBUM_ARTIST
:
62 return "Album Artist";
71 case MPD_TAG_COMPOSER
:
73 case MPD_TAG_PERFORMER
:
84 MPD::MutableSong::SetFunction
tagTypeToSetFunction(mpd_tag_type tag
)
89 return &MPD::MutableSong::setArtist
;
91 return &MPD::MutableSong::setAlbum
;
92 case MPD_TAG_ALBUM_ARTIST
:
93 return &MPD::MutableSong::setAlbumArtist
;
95 return &MPD::MutableSong::setTitle
;
97 return &MPD::MutableSong::setTrack
;
99 return &MPD::MutableSong::setGenre
;
101 return &MPD::MutableSong::setDate
;
102 case MPD_TAG_COMPOSER
:
103 return &MPD::MutableSong::setComposer
;
104 case MPD_TAG_PERFORMER
:
105 return &MPD::MutableSong::setPerformer
;
106 case MPD_TAG_COMMENT
:
107 return &MPD::MutableSong::setComment
;
109 return &MPD::MutableSong::setDisc
;
115 mpd_tag_type
charToTagType(char c
)
120 return MPD_TAG_ARTIST
;
122 return MPD_TAG_ALBUM_ARTIST
;
124 return MPD_TAG_TITLE
;
126 return MPD_TAG_ALBUM
;
130 return MPD_TAG_TRACK
;
132 return MPD_TAG_GENRE
;
134 return MPD_TAG_COMPOSER
;
136 return MPD_TAG_PERFORMER
;
140 return MPD_TAG_COMMENT
;
143 return MPD_TAG_ARTIST
;
147 MPD::Song::GetFunction
charToGetFunction(char c
)
152 return &MPD::Song::getLength
;
154 return &MPD::Song::getDirectory
;
156 return &MPD::Song::getName
;
158 return &MPD::Song::getArtist
;
160 return &MPD::Song::getAlbumArtist
;
162 return &MPD::Song::getTitle
;
164 return &MPD::Song::getAlbum
;
166 return &MPD::Song::getDate
;
168 return &MPD::Song::getTrackNumber
;
170 return &MPD::Song::getTrack
;
172 return &MPD::Song::getGenre
;
174 return &MPD::Song::getComposer
;
176 return &MPD::Song::getPerformer
;
178 return &MPD::Song::getDisc
;
180 return &MPD::Song::getComment
;
182 return &MPD::Song::getPriority
;
188 std::string
itemTypeToString(MPD::Item::Type type
)
193 case MPD::Item::Type::Directory
:
194 result
= "directory";
196 case MPD::Item::Type::Song
:
199 case MPD::Item::Type::Playlist
: