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++ --- test/DumpDatabase.cxx | 2 +- test/dump_playlist.cxx | 4 ++-- test/dump_rva2.cxx | 18 ++++-------------- test/read_tags.cxx | 2 +- test/run_decoder.cxx | 2 +- test/run_input.cxx | 8 ++++---- test/test_vorbis_encoder.cxx | 12 +++++------- test/visit_archive.cxx | 2 +- 8 files changed, 19 insertions(+), 31 deletions(-) (limited to 'test') diff --git a/test/DumpDatabase.cxx b/test/DumpDatabase.cxx index e917ec831..53b95ca22 100644 --- a/test/DumpDatabase.cxx +++ b/test/DumpDatabase.cxx @@ -25,7 +25,7 @@ #include "Song.hxx" #include "PlaylistVector.hxx" #include "conf.h" -#include "tag.h" +#include "Tag.hxx" #include "fs/Path.hxx" #include diff --git a/test/dump_playlist.cxx b/test/dump_playlist.cxx index 8eb1d6078..df7c6d739 100644 --- a/test/dump_playlist.cxx +++ b/test/dump_playlist.cxx @@ -106,7 +106,7 @@ decoder_data(G_GNUC_UNUSED struct decoder *decoder, enum decoder_command decoder_tag(G_GNUC_UNUSED struct decoder *decoder, G_GNUC_UNUSED struct input_stream *is, - G_GNUC_UNUSED const struct tag *tag) + G_GNUC_UNUSED const Tag *tag) { return DECODE_COMMAND_NONE; } @@ -232,7 +232,7 @@ int main(int argc, char **argv) (song->start_ms / 1000) % 60); if (song->tag != NULL) - tag_save(stdout, song->tag); + tag_save(stdout, *song->tag); song->Free(); } diff --git a/test/dump_rva2.cxx b/test/dump_rva2.cxx index c849f6a89..9dbb018d6 100644 --- a/test/dump_rva2.cxx +++ b/test/dump_rva2.cxx @@ -22,7 +22,7 @@ #include "TagRva2.hxx" #include "replay_gain_info.h" #include "conf.h" -#include "tag.h" +#include "Tag.hxx" #include @@ -41,23 +41,13 @@ config_get_string(gcc_unused enum ConfigOption option, return default_value; } -struct tag * -tag_new(void) -{ - return NULL; -} - void -tag_add_item_n(gcc_unused struct tag *tag, gcc_unused enum tag_type type, - gcc_unused const char *value, gcc_unused size_t len) +Tag::AddItem(gcc_unused enum tag_type type, + gcc_unused const char *value) { } -void -tag_free(struct tag *tag) -{ - g_free(tag); -} +Tag::~Tag() {} int main(int argc, char **argv) { diff --git a/test/read_tags.cxx b/test/read_tags.cxx index 9d8adf77e..515a84706 100644 --- a/test/read_tags.cxx +++ b/test/read_tags.cxx @@ -92,7 +92,7 @@ decoder_data(G_GNUC_UNUSED struct decoder *decoder, enum decoder_command decoder_tag(G_GNUC_UNUSED struct decoder *decoder, G_GNUC_UNUSED struct input_stream *is, - G_GNUC_UNUSED const struct tag *tag) + G_GNUC_UNUSED const Tag *tag) { return DECODE_COMMAND_NONE; } diff --git a/test/run_decoder.cxx b/test/run_decoder.cxx index f30914fc5..3c236ab2f 100644 --- a/test/run_decoder.cxx +++ b/test/run_decoder.cxx @@ -113,7 +113,7 @@ decoder_data(G_GNUC_UNUSED struct decoder *decoder, enum decoder_command decoder_tag(G_GNUC_UNUSED struct decoder *decoder, G_GNUC_UNUSED struct input_stream *is, - G_GNUC_UNUSED const struct tag *tag) + G_GNUC_UNUSED const Tag *tag) { return DECODE_COMMAND_NONE; } diff --git a/test/run_input.cxx b/test/run_input.cxx index 43e2f78b4..e93e817d3 100644 --- a/test/run_input.cxx +++ b/test/run_input.cxx @@ -20,7 +20,7 @@ #include "config.h" #include "TagSave.hxx" #include "stdbin.h" -#include "tag.h" +#include "Tag.hxx" #include "conf.h" #include "input_stream.h" #include "InputStream.hxx" @@ -75,11 +75,11 @@ dump_input_stream(struct input_stream *is) /* read data and tags from the stream */ while (!input_stream_eof(is)) { - struct tag *tag = input_stream_tag(is); + Tag *tag = input_stream_tag(is); if (tag != NULL) { g_printerr("Received a tag:\n"); - tag_save(stderr, tag); - tag_free(tag); + tag_save(stderr, *tag); + delete tag; } num_read = input_stream_read(is, buffer, sizeof(buffer), diff --git a/test/test_vorbis_encoder.cxx b/test/test_vorbis_encoder.cxx index 1e3b78065..650480319 100644 --- a/test/test_vorbis_encoder.cxx +++ b/test/test_vorbis_encoder.cxx @@ -23,7 +23,7 @@ #include "audio_format.h" #include "conf.h" #include "stdbin.h" -#include "tag.h" +#include "Tag.hxx" #include @@ -83,15 +83,13 @@ main(G_GNUC_UNUSED int argc, G_GNUC_UNUSED char **argv) encoder_to_stdout(*encoder); - struct tag *tag = tag_new(); - tag_add_item(tag, TAG_ARTIST, "Foo"); - tag_add_item(tag, TAG_TITLE, "Bar"); + Tag tag; + tag.AddItem(TAG_ARTIST, "Foo"); + tag.AddItem(TAG_TITLE, "Bar"); - success = encoder_tag(encoder, tag, NULL); + success = encoder_tag(encoder, &tag, NULL); assert(success); - tag_free(tag); - encoder_to_stdout(*encoder); /* write another block of data */ diff --git a/test/visit_archive.cxx b/test/visit_archive.cxx index 8306c7304..047fe62c0 100644 --- a/test/visit_archive.cxx +++ b/test/visit_archive.cxx @@ -19,7 +19,7 @@ #include "config.h" #include "stdbin.h" -#include "tag.h" +#include "Tag.hxx" #include "conf.h" #include "IOThread.hxx" #include "InputInit.hxx" -- cgit v1.2.3