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_ARTIST,
00035 TAG_ARTIST_SORT,
00036 TAG_ALBUM,
00037 TAG_ALBUM_ARTIST,
00038 TAG_ALBUM_ARTIST_SORT,
00039 TAG_TITLE,
00040 TAG_TRACK,
00041 TAG_NAME,
00042 TAG_GENRE,
00043 TAG_DATE,
00044 TAG_COMPOSER,
00045 TAG_PERFORMER,
00046 TAG_COMMENT,
00047 TAG_DISC,
00048
00049 TAG_MUSICBRAINZ_ARTISTID,
00050 TAG_MUSICBRAINZ_ALBUMID,
00051 TAG_MUSICBRAINZ_ALBUMARTISTID,
00052 TAG_MUSICBRAINZ_TRACKID,
00053
00054 TAG_NUM_OF_ITEM_TYPES
00055 };
00056
00061 extern const char *tag_item_names[];
00062
00068 struct tag_item {
00070 enum tag_type type;
00071
00075 char value[sizeof(long)];
00076 } gcc_packed;
00077
00082 struct tag {
00089 int time;
00090
00095 bool has_playlist;
00096
00098 struct tag_item **items;
00099
00101 unsigned num_items;
00102 };
00103
00108 enum tag_type
00109 tag_name_parse(const char *name);
00110
00117 enum tag_type
00118 tag_name_parse_i(const char *name);
00119
00123 struct tag *tag_new(void);
00124
00128 void tag_lib_init(void);
00129
00133 void tag_clear_items_by_type(struct tag *tag, enum tag_type type);
00134
00138 void tag_free(struct tag *tag);
00139
00147 void tag_begin_add(struct tag *tag);
00148
00152 void tag_end_add(struct tag *tag);
00153
00162 void tag_add_item_n(struct tag *tag, enum tag_type type,
00163 const char *value, size_t len);
00164
00172 static inline void
00173 tag_add_item(struct tag *tag, enum tag_type type, const char *value)
00174 {
00175 tag_add_item_n(tag, type, value, strlen(value));
00176 }
00177
00181 struct tag *tag_dup(const struct tag *tag);
00182
00189 struct tag *
00190 tag_merge(const struct tag *base, const struct tag *add);
00191
00198 struct tag *
00199 tag_merge_replace(struct tag *base, struct tag *add);
00200
00205 static inline bool
00206 tag_is_empty(const struct tag *tag)
00207 {
00208 return tag->num_items == 0;
00209 }
00210
00214 static inline bool
00215 tag_is_defined(const struct tag *tag)
00216 {
00217 return !tag_is_empty(tag) || tag->time >= 0;
00218 }
00219
00224 const char *
00225 tag_get_value(const struct tag *tag, enum tag_type type);
00226
00231 bool tag_has_type(const struct tag *tag, enum tag_type type);
00232
00237 bool tag_equal(const struct tag *tag1, const struct tag *tag2);
00238
00239 #endif