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
00100 enum tag_type
00101 tag_name_parse(const char *name);
00102
00109 enum tag_type
00110 tag_name_parse_i(const char *name);
00111
00115 struct tag *tag_new(void);
00116
00120 void tag_lib_init(void);
00121
00125 void tag_clear_items_by_type(struct tag *tag, enum tag_type type);
00126
00130 void tag_free(struct tag *tag);
00131
00139 void tag_begin_add(struct tag *tag);
00140
00144 void tag_end_add(struct tag *tag);
00145
00154 void tag_add_item_n(struct tag *tag, enum tag_type type,
00155 const char *value, size_t len);
00156
00164 static inline void
00165 tag_add_item(struct tag *tag, enum tag_type type, const char *value)
00166 {
00167 tag_add_item_n(tag, type, value, strlen(value));
00168 }
00169
00173 struct tag *tag_dup(const struct tag *tag);
00174
00181 struct tag *
00182 tag_merge(const struct tag *base, const struct tag *add);
00183
00190 struct tag *
00191 tag_merge_replace(struct tag *base, struct tag *add);
00192
00197 static inline bool
00198 tag_is_empty(const struct tag *tag)
00199 {
00200 return tag->num_items == 0;
00201 }
00202
00206 static inline bool
00207 tag_is_defined(const struct tag *tag)
00208 {
00209 return !tag_is_empty(tag) || tag->time >= 0;
00210 }
00211
00216 const char *
00217 tag_get_value(const struct tag *tag, enum tag_type type);
00218
00223 bool tag_has_type(const struct tag *tag, enum tag_type type);
00224
00229 bool tag_equal(const struct tag *tag1, const struct tag *tag2);
00230
00231 #endif