MPD  0.20.18
StickerDatabase.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 /*
21  * This is the sticker database library. It is the backend of all the
22  * sticker code in MPD.
23  *
24  * "Stickers" are pieces of information attached to existing MPD
25  * objects (e.g. song files, directories, albums). Clients can create
26  * arbitrary name/value pairs. MPD itself does not assume any special
27  * meaning in them.
28  *
29  * The goal is to allow clients to share additional (possibly dynamic)
30  * information about songs, which is neither stored on the client (not
31  * available to other clients), nor stored in the song files (MPD has
32  * no write access).
33  *
34  * Client developers should create a standard for common sticker
35  * names, to ensure interoperability.
36  *
37  * Examples: song ratings; statistics; deferred tag writes; lyrics;
38  * ...
39  *
40  */
41 
42 #ifndef MPD_STICKER_DATABASE_HXX
43 #define MPD_STICKER_DATABASE_HXX
44 
45 #include "Match.hxx"
46 #include "Compiler.h"
47 
48 #include <string>
49 
50 class Path;
51 struct Sticker;
52 
58 void
60 
64 void
66 
71 bool
72 sticker_enabled() noexcept;
73 
80 std::string
81 sticker_load_value(const char *type, const char *uri, const char *name);
82 
89 void
90 sticker_store_value(const char *type, const char *uri,
91  const char *name, const char *value);
92 
99 bool
100 sticker_delete(const char *type, const char *uri);
101 
108 bool
109 sticker_delete_value(const char *type, const char *uri, const char *name);
110 
116 void
117 sticker_free(Sticker *sticker);
118 
126 gcc_pure
127 const char *
128 sticker_get_value(const Sticker &sticker, const char *name) noexcept;
129 
137 void
138 sticker_foreach(const Sticker &sticker,
139  void (*func)(const char *name, const char *value,
140  void *user_data),
141  void *user_data);
142 
152 Sticker *
153 sticker_load(const char *type, const char *uri);
154 
165 void
166 sticker_find(const char *type, const char *base_uri, const char *name,
167  StickerOperator op, const char *value,
168  void (*func)(const char *uri, const char *value,
169  void *user_data),
170  void *user_data);
171 
172 #endif
Sticker * sticker_load(const char *type, const char *uri)
Loads the sticker for the specified resource.
void sticker_free(Sticker *sticker)
Frees resources held by the sticker object.
void sticker_global_finish()
Close the sticker database.
void sticker_find(const char *type, const char *base_uri, const char *name, StickerOperator op, const char *value, void(*func)(const char *uri, const char *value, void *user_data), void *user_data)
Finds stickers with the specified name below the specified URI.
bool sticker_delete(const char *type, const char *uri)
Deletes a sticker from the database.
void sticker_store_value(const char *type, const char *uri, const char *name, const char *value)
Sets a sticker value in the specified object.
A path name in the native file system character set.
Definition: Path.hxx:39
std::string sticker_load_value(const char *type, const char *uri, const char *name)
Returns one value from an object&#39;s sticker record.
#define gcc_const
Definition: Compiler.h:109
StickerOperator
Definition: Match.hxx:23
gcc_pure const char * sticker_get_value(const Sticker &sticker, const char *name) noexcept
Determines a single value in a sticker.
gcc_const bool sticker_enabled() noexcept
Returns true if the sticker database is configured and available.
void sticker_global_init(Path path)
Opens the sticker database.
bool sticker_delete_value(const char *type, const char *uri, const char *name)
Deletes a sticker value.
#define gcc_pure
Definition: Compiler.h:116
const Storage const char * uri
void sticker_foreach(const Sticker &sticker, void(*func)(const char *name, const char *value, void *user_data), void *user_data)
Iterates over all sticker items in a sticker.
const Partition const char * name
Definition: Count.hxx:34