text_input_stream: convert to class

This commit is contained in:
Denis Krjuchkov
2013-05-12 20:02:27 +06:00
parent 49a3845135
commit e9e55b0812
8 changed files with 138 additions and 159 deletions

View File

@@ -21,17 +21,14 @@
#include "M3uPlaylistPlugin.hxx"
#include "PlaylistPlugin.hxx"
#include "song.h"
extern "C" {
#include "text_input_stream.h"
}
#include "TextInputStream.hxx"
#include <glib.h>
struct M3uPlaylist {
struct playlist_provider base;
struct text_input_stream *tis;
TextInputStream *tis;
};
static struct playlist_provider *
@@ -40,7 +37,7 @@ m3u_open_stream(struct input_stream *is)
M3uPlaylist *playlist = g_new(M3uPlaylist, 1);
playlist_provider_init(&playlist->base, &m3u_playlist_plugin);
playlist->tis = text_input_stream_new(is);
playlist->tis = new TextInputStream(is);
return &playlist->base;
}
@@ -50,7 +47,7 @@ m3u_close(struct playlist_provider *_playlist)
{
M3uPlaylist *playlist = (M3uPlaylist *)_playlist;
text_input_stream_free(playlist->tis);
delete playlist->tis;
g_free(playlist);
}
@@ -58,18 +55,20 @@ static struct song *
m3u_read(struct playlist_provider *_playlist)
{
M3uPlaylist *playlist = (M3uPlaylist *)_playlist;
const char *line;
std::string line;
const char *line_s;
do {
line = text_input_stream_read(playlist->tis);
if (line == NULL)
if (!playlist->tis->ReadLine(line))
return NULL;
while (*line != 0 && g_ascii_isspace(*line))
++line;
} while (line[0] == '#' || *line == 0);
line_s = line.c_str();
return song_remote_new(line);
while (*line_s != 0 && g_ascii_isspace(*line_s))
++line_s;
} while (line_s[0] == '#' || *line_s == 0);
return song_remote_new(line_s);
}
static const char *const m3u_suffixes[] = {