aboutsummaryrefslogtreecommitdiffstats
path: root/src/tag/ApeTag.cxx
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2015-09-30 22:03:01 +0200
committerMax Kellermann <max@duempel.org>2015-09-30 22:21:46 +0200
commit356c829b767863512da1792c048f6ddbeb8457a3 (patch)
tree7b71365eb164719ddf12d081766520ee4938bc28 /src/tag/ApeTag.cxx
parentffbb5c48ed3edaeb72b26b61637eb3bd1cea9e32 (diff)
downloadmpd-356c829b767863512da1792c048f6ddbeb8457a3.tar.gz
mpd-356c829b767863512da1792c048f6ddbeb8457a3.tar.xz
mpd-356c829b767863512da1792c048f6ddbeb8457a3.zip
util/StringView: new utility class
Diffstat (limited to 'src/tag/ApeTag.cxx')
-rw-r--r--src/tag/ApeTag.cxx16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/tag/ApeTag.cxx b/src/tag/ApeTag.cxx
index 49ae7a036..81318a771 100644
--- a/src/tag/ApeTag.cxx
+++ b/src/tag/ApeTag.cxx
@@ -24,6 +24,7 @@
#include "TagTable.hxx"
#include "TagHandler.hxx"
#include "fs/Path.hxx"
+#include "util/StringView.hxx"
#include <string>
@@ -75,17 +76,18 @@ ForEachValue(const char *value, const char *end, C &&callback)
*/
static bool
tag_ape_import_item(unsigned long flags,
- const char *key, const char *value, size_t value_length,
+ const char *key, StringView value,
const struct tag_handler *handler, void *handler_ctx)
{
/* we only care about utf-8 text tags */
if ((flags & (0x3 << 1)) != 0)
return false;
- const char *const end = value + value_length;
+ const auto begin = value.begin();
+ const auto end = value.end();
if (handler->pair != nullptr)
- ForEachValue(value, end, [handler, handler_ctx,
+ ForEachValue(begin, end, [handler, handler_ctx,
key](const char *_value) {
handler->pair(key, _value, handler_ctx);
});
@@ -94,8 +96,8 @@ tag_ape_import_item(unsigned long flags,
if (type == TAG_NUM_OF_ITEM_TYPES)
return false;
- ForEachValue(value, end, [handler, handler_ctx,
- type](const char *_value) {
+ ForEachValue(begin, end, [handler, handler_ctx,
+ type](const char *_value) {
tag_handler_invoke_tag(handler, handler_ctx,
type, _value);
});
@@ -111,10 +113,8 @@ tag_ape_scan2(Path path_fs,
auto callback = [handler, handler_ctx, &recognized]
(unsigned long flags, const char *key,
- const char *value,
- size_t value_length) {
+ StringView value) {
recognized |= tag_ape_import_item(flags, key, value,
- value_length,
handler, handler_ctx);
return true;
};