aboutsummaryrefslogtreecommitdiffstats
path: root/src/output
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2014-07-12 17:22:39 +0200
committerMax Kellermann <max@duempel.org>2014-07-12 17:22:39 +0200
commit41a7203c28d2cc7550f1bb05f767950d388326cd (patch)
tree0b0970bbaf06b66ec0c0b3a50d90b3f6ef65dd20 /src/output
parent543a58bb874be8a510d54e91a37797b0c71b1160 (diff)
downloadmpd-41a7203c28d2cc7550f1bb05f767950d388326cd.tar.gz
mpd-41a7203c28d2cc7550f1bb05f767950d388326cd.tar.xz
mpd-41a7203c28d2cc7550f1bb05f767950d388326cd.zip
Tag: add class const_iterator and methods begin(), end()
Enables using range-based "for".
Diffstat (limited to 'src/output')
-rw-r--r--src/output/plugins/RoarOutputPlugin.cxx12
-rw-r--r--src/output/plugins/ShoutOutputPlugin.cxx8
2 files changed, 11 insertions, 9 deletions
diff --git a/src/output/plugins/RoarOutputPlugin.cxx b/src/output/plugins/RoarOutputPlugin.cxx
index ac4dd8a4e..ae6bdf1b1 100644
--- a/src/output/plugins/RoarOutputPlugin.cxx
+++ b/src/output/plugins/RoarOutputPlugin.cxx
@@ -374,20 +374,22 @@ RoarOutput::SendTag(const Tag &tag)
vals[0].key = const_cast<char *>("LENGTH");
vals[0].value = timebuf;
- for (unsigned i = 0; i < tag.num_items && cnt < 32; i++)
- {
+ for (const auto &item : tag) {
+ if (cnt >= 32)
+ break;
+
bool is_uuid = false;
- const char *key = roar_tag_convert(tag.items[i]->type,
+ const char *key = roar_tag_convert(item.type,
&is_uuid);
if (key != nullptr) {
vals[cnt].key = const_cast<char *>(key);
if (is_uuid) {
snprintf(uuid_buf[cnt], sizeof(uuid_buf[0]), "{UUID}%s",
- tag.items[i]->value);
+ item.value);
vals[cnt].value = uuid_buf[cnt];
} else {
- vals[cnt].value = tag.items[i]->value;
+ vals[cnt].value = const_cast<char *>(item.value);
}
cnt++;
diff --git a/src/output/plugins/ShoutOutputPlugin.cxx b/src/output/plugins/ShoutOutputPlugin.cxx
index a16c8fecd..0341e1cf7 100644
--- a/src/output/plugins/ShoutOutputPlugin.cxx
+++ b/src/output/plugins/ShoutOutputPlugin.cxx
@@ -470,13 +470,13 @@ shout_tag_to_metadata(const Tag *tag, char *dest, size_t size)
artist[0] = 0;
title[0] = 0;
- for (unsigned i = 0; i < tag->num_items; i++) {
- switch (tag->items[i]->type) {
+ for (const auto &item : *tag) {
+ switch (item.type) {
case TAG_ARTIST:
- strncpy(artist, tag->items[i]->value, size);
+ strncpy(artist, item.value, size);
break;
case TAG_TITLE:
- strncpy(title, tag->items[i]->value, size);
+ strncpy(title, item.value, size);
break;
default: