MPD 0.20.6

- Main Page
- Namespaces
- Data Structures
- Files

- File List
- Globals

TagHandler.hxx
Go to the documentation of this file.
1 /*
2 * Copyright 2003-2017 The Music Player Daemon Project
3 * http://www.musicpd.org
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 */
19
20 #ifndef MPD_TAG_HANDLER_HXX
21 #define MPD_TAG_HANDLER_HXX
22
23 #include "check.h"
24 #include "TagType.h"
25 #include "Chrono.hxx"
26
27 #include <assert.h>
28
32 struct TagHandler {
38 void (*duration)(SongTime duration, void *ctx);
39
46 void (*tag)(TagType type, const char *value, void *ctx);
47
52 void (*pair)(const char *key, const char *value, void *ctx);
53 };
54
55 static inline void
56 tag_handler_invoke_duration(const TagHandler &handler, void *ctx,
57 SongTime duration)
58 {
59 if (handler.duration != nullptr)
60 handler.duration(duration, ctx);
61 }
62
63 static inline void
64 tag_handler_invoke_tag(const TagHandler &handler, void *ctx,
65 TagType type, const char *value)
66 {
67 assert((unsigned)type < TAG_NUM_OF_ITEM_TYPES);
68 assert(value != nullptr);
69
70 if (handler.tag != nullptr)
71 handler.tag(type, value, ctx);
72 }
73
74 static inline void
75 tag_handler_invoke_pair(const TagHandler &handler, void *ctx,
76 const char *name, const char *value)
77 {
78 assert(name != nullptr);
79 assert(value != nullptr);
80
81 if (handler.pair != nullptr)
82 handler.pair(name, value, ctx);
83 }
84
89 extern const TagHandler add_tag_handler;
90
96 extern const TagHandler full_tag_handler;
97
98 #endif
check.h
TagHandler::tag
void(* tag)(TagType type, const char *value, void *ctx)
A tag has been read.
Definition: TagHandler.hxx:46
Chrono.hxx
SongTime
A time stamp within a song.
Definition: Chrono.hxx:31
TagHandler
A callback table for receiving metadata of a song.
Definition: TagHandler.hxx:32
add_tag_handler
const TagHandler add_tag_handler
This TagHandler implementation adds tag values to a TagBuilder object (casted from the context pointe...
tag_handler_invoke_pair
static void tag_handler_invoke_pair(const TagHandler &handler, void *ctx, const char *name, const char *value)
Definition: TagHandler.hxx:75
full_tag_handler
const TagHandler full_tag_handler
This TagHandler implementation adds tag values to a TagBuilder object (casted from the context pointe...
tag_handler_invoke_duration
static void tag_handler_invoke_duration(const TagHandler &handler, void *ctx, SongTime duration)
Definition: TagHandler.hxx:56
TagHandler::duration
void(* duration)(SongTime duration, void *ctx)
Declare the duration of a song.
Definition: TagHandler.hxx:38
TagType
TagType
Codes for the type of a tag item.
Definition: TagType.h:30
TagHandler::pair
void(* pair)(const char *key, const char *value, void *ctx)
A name-value pair has been read.
Definition: TagHandler.hxx:52
TagType.h
tag_handler_invoke_tag
static void tag_handler_invoke_tag(const TagHandler &handler, void *ctx, TagType type, const char *value)
Definition: TagHandler.hxx:64
TAG_NUM_OF_ITEM_TYPES
Definition: TagType.h:60
name
const Partition const char * name
Definition: Count.hxx:34