00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef MPD_TAG_HANDLER_H
00021 #define MPD_TAG_HANDLER_H
00022
00023 #include "check.h"
00024 #include "tag.h"
00025
00026 #include <assert.h>
00027
00031 struct tag_handler {
00037 void (*duration)(unsigned seconds, void *ctx);
00038
00045 void (*tag)(enum tag_type type, const char *value, void *ctx);
00046
00051 void (*pair)(const char *key, const char *value, void *ctx);
00052 };
00053
00054 static inline void
00055 tag_handler_invoke_duration(const struct tag_handler *handler, void *ctx,
00056 unsigned seconds)
00057 {
00058 assert(handler != NULL);
00059
00060 if (handler->duration != NULL)
00061 handler->duration(seconds, ctx);
00062 }
00063
00064 static inline void
00065 tag_handler_invoke_tag(const struct tag_handler *handler, void *ctx,
00066 enum tag_type type, const char *value)
00067 {
00068 assert(handler != NULL);
00069 assert((unsigned)type < TAG_NUM_OF_ITEM_TYPES);
00070 assert(value != NULL);
00071
00072 if (handler->tag != NULL)
00073 handler->tag(type, value, ctx);
00074 }
00075
00076 static inline void
00077 tag_handler_invoke_pair(const struct tag_handler *handler, void *ctx,
00078 const char *name, const char *value)
00079 {
00080 assert(handler != NULL);
00081 assert(name != NULL);
00082 assert(value != NULL);
00083
00084 if (handler->pair != NULL)
00085 handler->pair(name, value, ctx);
00086 }
00087
00092 extern const struct tag_handler add_tag_handler;
00093
00099 extern const struct tag_handler full_tag_handler;
00100
00101 #endif