tag: convert to C++

This commit is contained in:
Max Kellermann
2013-07-30 20:11:57 +02:00
parent 6a9ab8bc0e
commit 06f898cc12
105 changed files with 711 additions and 723 deletions

View File

@@ -22,7 +22,7 @@
#include "MemoryPlaylistProvider.hxx"
#include "input_stream.h"
#include "Song.hxx"
#include "tag.h"
#include "Tag.hxx"
#include <glib.h>
@@ -169,9 +169,9 @@ asx_text(G_GNUC_UNUSED GMarkupParseContext *context,
case AsxParser::ENTRY:
if (parser->tag != TAG_NUM_OF_ITEM_TYPES) {
if (parser->song->tag == NULL)
parser->song->tag = tag_new();
tag_add_item_n(parser->song->tag, parser->tag,
text, text_len);
parser->song->tag = new Tag();
parser->song->tag->AddItem(parser->tag,
text, text_len);
}
break;

View File

@@ -20,7 +20,7 @@
#include "config.h"
#include "CuePlaylistPlugin.hxx"
#include "PlaylistPlugin.hxx"
#include "tag.h"
#include "Tag.hxx"
#include "Song.hxx"
#include "input_stream.h"
#include "cue/CueParser.hxx"

View File

@@ -21,7 +21,7 @@
#include "DespotifyPlaylistPlugin.hxx"
#include "DespotifyUtils.hxx"
#include "MemoryPlaylistProvider.hxx"
#include "tag.h"
#include "Tag.hxx"
#include "Song.hxx"
extern "C" {

View File

@@ -26,7 +26,7 @@
#include "config.h"
#include "EmbeddedCuePlaylistPlugin.hxx"
#include "PlaylistPlugin.hxx"
#include "tag.h"
#include "Tag.hxx"
#include "TagHandler.hxx"
#include "TagId3.hxx"
#include "ApeTag.hxx"

View File

@@ -21,7 +21,7 @@
#include "ExtM3uPlaylistPlugin.hxx"
#include "PlaylistPlugin.hxx"
#include "Song.hxx"
#include "tag.h"
#include "Tag.hxx"
#include "util/StringUtil.hxx"
#include "TextInputStream.hxx"
@@ -70,13 +70,13 @@ extm3u_close(struct playlist_provider *_playlist)
*
* @param line the rest of the input line after the colon
*/
static struct tag *
static Tag *
extm3u_parse_tag(const char *line)
{
long duration;
char *endptr;
const char *name;
struct tag *tag;
Tag *tag;
duration = strtol(line, &endptr, 10);
if (endptr[0] != ',')
@@ -93,14 +93,14 @@ extm3u_parse_tag(const char *line)
object */
return NULL;
tag = tag_new();
tag = new Tag();
tag->time = duration;
/* unfortunately, there is no real specification for the
EXTM3U format, so we must assume that the string after the
comma is opaque, and is just the song name*/
if (*name != 0)
tag_add_item(tag, TAG_NAME, name);
tag->AddItem(TAG_NAME, name);
return tag;
}
@@ -109,23 +109,21 @@ static Song *
extm3u_read(struct playlist_provider *_playlist)
{
ExtM3uPlaylist *playlist = (ExtM3uPlaylist *)_playlist;
struct tag *tag = NULL;
Tag *tag = NULL;
std::string line;
const char *line_s;
Song *song;
do {
if (!playlist->tis->ReadLine(line)) {
if (tag != NULL)
tag_free(tag);
delete tag;
return NULL;
}
line_s = line.c_str();
if (g_str_has_prefix(line_s, "#EXTINF:")) {
if (tag != NULL)
tag_free(tag);
delete tag;
tag = extm3u_parse_tag(line_s + 8);
continue;
}

View File

@@ -22,7 +22,7 @@
#include "MemoryPlaylistProvider.hxx"
#include "input_stream.h"
#include "Song.hxx"
#include "tag.h"
#include "Tag.hxx"
#include <glib.h>
@@ -71,8 +71,8 @@ pls_parser(GKeyFile *keyfile, std::forward_list<SongPointer> &songs)
g_free(key);
if(error == NULL && value){
if (song->tag == NULL)
song->tag = tag_new();
tag_add_item(song->tag,TAG_TITLE, value);
song->tag = new Tag();
song->tag->AddItem(TAG_TITLE, value);
}
/* Ignore errors? Most likely value not present */
if(error) g_error_free(error);
@@ -85,7 +85,7 @@ pls_parser(GKeyFile *keyfile, std::forward_list<SongPointer> &songs)
g_free(key);
if(error == NULL && length > 0){
if (song->tag == NULL)
song->tag = tag_new();
song->tag = new Tag();
song->tag->time = length;
}
/* Ignore errors? Most likely value not present */

View File

@@ -22,7 +22,7 @@
#include "MemoryPlaylistProvider.hxx"
#include "input_stream.h"
#include "Song.hxx"
#include "tag.h"
#include "Tag.hxx"
#include <glib.h>
@@ -166,9 +166,9 @@ rss_text(G_GNUC_UNUSED GMarkupParseContext *context,
case RssParser::ITEM:
if (parser->tag != TAG_NUM_OF_ITEM_TYPES) {
if (parser->song->tag == NULL)
parser->song->tag = tag_new();
tag_add_item_n(parser->song->tag, parser->tag,
text, text_len);
parser->song->tag = new Tag();
parser->song->tag->AddItem(parser->tag,
text, text_len);
}
break;

View File

@@ -23,7 +23,7 @@
#include "conf.h"
#include "input_stream.h"
#include "Song.hxx"
#include "tag.h"
#include "Tag.hxx"
#include <glib.h>
#include <yajl/yajl_parse.h>
@@ -204,16 +204,16 @@ static int handle_end_map(void *ctx)
data->got_url = 0;
Song *s;
struct tag *t;
char *u;
u = g_strconcat(data->stream_url, "?client_id=", soundcloud_config.apikey, NULL);
s = Song::NewRemote(u);
g_free(u);
t = tag_new();
Tag *t = new Tag();
t->time = data->duration / 1000;
if (data->title != NULL)
tag_add_item(t, TAG_NAME, data->title);
t->AddItem(TAG_NAME, data->title);
s->tag = t;
data->songs.emplace_front(s);

View File

@@ -21,7 +21,7 @@
#include "XspfPlaylistPlugin.hxx"
#include "MemoryPlaylistProvider.hxx"
#include "input_stream.h"
#include "tag.h"
#include "Tag.hxx"
#include <glib.h>
@@ -177,9 +177,8 @@ xspf_text(G_GNUC_UNUSED GMarkupParseContext *context,
if (parser->song != NULL &&
parser->tag != TAG_NUM_OF_ITEM_TYPES) {
if (parser->song->tag == NULL)
parser->song->tag = tag_new();
tag_add_item_n(parser->song->tag, parser->tag,
text, text_len);
parser->song->tag = new Tag();
parser->song->tag->AddItem(parser->tag, text, text_len);
}
break;