00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef MPD_TAG_H
00021 #define MPD_TAG_H
00022
00023 #include "gcc.h"
00024
00025 #include <stdint.h>
00026 #include <stddef.h>
00027 #include <stdbool.h>
00028 #include <string.h>
00029
00033 enum tag_type {
00034 TAG_ITEM_ARTIST,
00035 TAG_ITEM_ALBUM,
00036 TAG_ITEM_ALBUM_ARTIST,
00037 TAG_ITEM_TITLE,
00038 TAG_ITEM_TRACK,
00039 TAG_ITEM_NAME,
00040 TAG_ITEM_GENRE,
00041 TAG_ITEM_DATE,
00042 TAG_ITEM_COMPOSER,
00043 TAG_ITEM_PERFORMER,
00044 TAG_ITEM_COMMENT,
00045 TAG_ITEM_DISC,
00046
00047 TAG_MUSICBRAINZ_ARTISTID,
00048 TAG_MUSICBRAINZ_ALBUMID,
00049 TAG_MUSICBRAINZ_ALBUMARTISTID,
00050 TAG_MUSICBRAINZ_TRACKID,
00051
00052 TAG_NUM_OF_ITEM_TYPES
00053 };
00054
00059 extern const char *tag_item_names[];
00060
00066 struct tag_item {
00068 enum tag_type type;
00069
00073 char value[sizeof(long)];
00074 } mpd_packed;
00075
00080 struct tag {
00087 int time;
00088
00090 struct tag_item **items;
00091
00093 unsigned num_items;
00094 };
00095
00099 struct tag *tag_new(void);
00100
00104 void tag_lib_init(void);
00105
00109 void tag_clear_items_by_type(struct tag *tag, enum tag_type type);
00110
00114 void tag_free(struct tag *tag);
00115
00123 void tag_begin_add(struct tag *tag);
00124
00128 void tag_end_add(struct tag *tag);
00129
00138 void tag_add_item_n(struct tag *tag, enum tag_type type,
00139 const char *value, size_t len);
00140
00148 static inline void
00149 tag_add_item(struct tag *tag, enum tag_type type, const char *value)
00150 {
00151 tag_add_item_n(tag, type, value, strlen(value));
00152 }
00153
00157 struct tag *tag_dup(const struct tag *tag);
00158
00165 struct tag *
00166 tag_merge(const struct tag *base, const struct tag *add);
00167
00172 static inline bool
00173 tag_is_empty(const struct tag *tag)
00174 {
00175 return tag->num_items == 0;
00176 }
00177
00181 static inline bool
00182 tag_is_defined(const struct tag *tag)
00183 {
00184 return !tag_is_empty(tag) || tag->time >= 0;
00185 }
00186
00191 const char *
00192 tag_get_value(const struct tag *tag, enum tag_type type);
00193
00198 bool tag_has_type(const struct tag *tag, enum tag_type type);
00199
00204 bool tag_equal(const struct tag *tag1, const struct tag *tag2);
00205
00206 #endif