1 /* vi:set ts=8 sts=8 sw=8: 2 * 3 * PMS <<Practical Music Search>> 4 * Copyright (C) 2006-2010 Kim Tore Jensen 5 * 6 * This program is free software: you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation, either version 3 of the License, or 9 * (at your option) any later version. 10 * 11 * This program is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with this program. If not, see <http://www.gnu.org/licenses/>. 18 * 19 * 20 * field.h - format a song using field variables 21 * 22 */ 23 24 #ifndef _PMS_FIELD_H_ 25 #define _PMS_FIELD_H_ 26 27 #include <string> 28 #include <vector> 29 #include "song.h" 30 #include "color.h" 31 32 /* 33 * Insertable items and items in playlist 34 */ 35 typedef enum 36 { 37 EINVALID = -1, 38 39 /* Field types are present both in library view and topbar view */ 40 FIELD_NUM, 41 FIELD_FILE, 42 FIELD_ARTIST, 43 FIELD_ARTISTSORT, 44 FIELD_ALBUMARTIST, 45 FIELD_ALBUMARTISTSORT, 46 FIELD_TITLE, 47 FIELD_ALBUM, 48 FIELD_TRACK, 49 FIELD_TRACKSHORT, 50 FIELD_TIME, 51 FIELD_DATE, 52 FIELD_YEAR, 53 FIELD_NAME, 54 FIELD_GENRE, 55 FIELD_COMPOSER, 56 FIELD_PERFORMER, 57 FIELD_DISC, 58 FIELD_COMMENT, 59 60 /* Conditionals */ 61 COND_IFCURSONG, 62 COND_IFPLAYING, 63 COND_IFPAUSED, 64 COND_IFSTOPPED, 65 COND_ELSE, 66 COND_ENDIF, 67 68 /* These types are only available to the topbar */ 69 REPEAT, 70 RANDOM, 71 MANUALPROGRESSION, 72 MUTE, 73 REPEATSHORT, 74 RANDOMSHORT, 75 MANUALPROGRESSIONSHORT, 76 MUTESHORT, 77 TIME_ELAPSED, 78 TIME_REMAINING, 79 PLAYSTATE, 80 PROGRESSBAR, 81 PROGRESSPERCENTAGE, 82 VOLUME, 83 LIBRARYSIZE, 84 LISTSIZE, 85 QUEUESIZE, 86 LIVEQUEUESIZE, 87 88 /* Audio properties */ 89 BITRATE, 90 SAMPLERATE, 91 BITS, 92 CHANNELS, 93 94 /* Misc */ 95 LITERALPERCENT 96 97 } 98 Item; 99 100 101 /* 102 * Formatter class formats a song into names, i.e: 103 * 104 * format(song, "%artist% - %album%"); 105 * returns 106 * "U2 - Beautiful Day" 107 * 108 */ 109 class Formatter 110 { 111 private: 112 string fm; 113 114 Item nextitem(string, int *, int *); 115 string evalconditionals(string); 116 117 public: 118 string format(Song *, string, unsigned int &, colortable_fields *, bool = false); 119 string format(Song *, Item, unsigned int &, colortable_fields *, bool = false); 120 string format(Song *, Item, bool = false); 121 color * getcolor(Item, colortable_fields *); 122 vector<Item> * multiformat_item(string); 123 Item field_to_item(string); 124 long item_to_match(Item); 125 }; 126 127 128 #endif /* _PMS_FIELD_H_ */ 129