From 06f898cc1240a29b293de0e97ad95a4fdc971254 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Tue, 30 Jul 2013 20:11:57 +0200 Subject: tag: convert to C++ --- src/input/CurlInputPlugin.cxx | 28 +++++++++++++--------------- src/input/DespotifyInputPlugin.cxx | 11 +++++------ src/input/RewindInputPlugin.cxx | 5 +++-- 3 files changed, 21 insertions(+), 23 deletions(-) (limited to 'src/input') diff --git a/src/input/CurlInputPlugin.cxx b/src/input/CurlInputPlugin.cxx index fe944b752..33bacffc5 100644 --- a/src/input/CurlInputPlugin.cxx +++ b/src/input/CurlInputPlugin.cxx @@ -23,7 +23,7 @@ #include "InputStream.hxx" #include "InputPlugin.hxx" #include "conf.h" -#include "tag.h" +#include "Tag.hxx" #include "IcyMetaDataParser.hxx" #include "event/MultiSocketMonitor.hxx" #include "event/Loop.hxx" @@ -160,7 +160,7 @@ struct input_curl { /** the tag object ready to be requested via input_stream_tag() */ - struct tag *tag; + Tag *tag; GError *postponed_error; @@ -696,8 +696,8 @@ curl_total_buffer_size(const struct input_curl *c) input_curl::~input_curl() { - if (tag != NULL) - tag_free(tag); + delete tag; + g_free(meta_name); input_curl_easy_free_indirect(this); @@ -720,11 +720,11 @@ input_curl_check(struct input_stream *is, GError **error_r) return success; } -static struct tag * +static Tag * input_curl_tag(struct input_stream *is) { struct input_curl *c = (struct input_curl *)is; - struct tag *tag = c->tag; + Tag *tag = c->tag; c->tag = NULL; return tag; @@ -798,16 +798,15 @@ read_from_buffer(IcyMetaDataParser &icy, std::list &buffers, static void copy_icy_tag(struct input_curl *c) { - struct tag *tag = c->icy.ReadTag(); + Tag *tag = c->icy.ReadTag(); if (tag == NULL) return; - if (c->tag != NULL) - tag_free(c->tag); + delete c->tag; - if (c->meta_name != NULL && !tag_has_type(tag, TAG_NAME)) - tag_add_item(tag, TAG_NAME, c->meta_name); + if (c->meta_name != NULL && !tag->HasType(TAG_NAME)) + tag->AddItem(TAG_NAME, c->meta_name); c->tag = tag; } @@ -931,11 +930,10 @@ input_curl_headerfunction(void *ptr, size_t size, size_t nmemb, void *stream) g_free(c->meta_name); c->meta_name = g_strndup(value, end - value); - if (c->tag != NULL) - tag_free(c->tag); + delete c->tag; - c->tag = tag_new(); - tag_add_item(c->tag, TAG_NAME, c->meta_name); + c->tag = new Tag(); + c->tag->AddItem(TAG_NAME, c->meta_name); } else if (g_ascii_strcasecmp(name, "icy-metaint") == 0) { char buffer[64]; size_t icy_metaint; diff --git a/src/input/DespotifyInputPlugin.cxx b/src/input/DespotifyInputPlugin.cxx index 1e5a8c606..18e896608 100644 --- a/src/input/DespotifyInputPlugin.cxx +++ b/src/input/DespotifyInputPlugin.cxx @@ -23,7 +23,7 @@ #include "InputInternal.hxx" #include "InputStream.hxx" #include "InputPlugin.hxx" -#include "tag.h" +#include "Tag.hxx" extern "C" { #include @@ -42,7 +42,7 @@ struct DespotifyInputStream { struct despotify_session *session; struct ds_track *track; - struct tag *tag; + Tag *tag; struct ds_pcm_data pcm; size_t len_available; bool eof; @@ -64,8 +64,7 @@ struct DespotifyInputStream { } ~DespotifyInputStream() { - if (tag != NULL) - tag_free(tag); + delete tag; despotify_free_track(track); } @@ -216,11 +215,11 @@ input_despotify_seek(G_GNUC_UNUSED struct input_stream *is, return false; } -static struct tag * +static Tag * input_despotify_tag(struct input_stream *is) { DespotifyInputStream *ctx = (DespotifyInputStream *)is; - struct tag *tag = ctx->tag; + Tag *tag = ctx->tag; ctx->tag = NULL; diff --git a/src/input/RewindInputPlugin.cxx b/src/input/RewindInputPlugin.cxx index d93d7d1ce..d68fd3d73 100644 --- a/src/input/RewindInputPlugin.cxx +++ b/src/input/RewindInputPlugin.cxx @@ -22,11 +22,12 @@ #include "InputInternal.hxx" #include "InputStream.hxx" #include "InputPlugin.hxx" -#include "tag.h" +#include "Tag.hxx" #include #include +#include #include #undef G_LOG_DOMAIN @@ -127,7 +128,7 @@ input_rewind_update(struct input_stream *is) r->CopyAttributes(); } -static struct tag * +static Tag * input_rewind_tag(struct input_stream *is) { RewindInputStream *r = (RewindInputStream *)is; -- cgit v1.2.3