lib/expat/ExpatParser: move InputStream overload to separate source file

Eliminate one unnecessary dependency for debug programs which don't
need the InputStream API.
This commit is contained in:
Max Kellermann 2017-01-07 15:46:36 +01:00
parent 64dc5212f9
commit 860aa9d6d0
3 changed files with 40 additions and 18 deletions

View File

@ -1577,6 +1577,7 @@ endif
if ENABLE_EXPAT
libplaylist_plugins_a_SOURCES += \
src/lib/expat/StreamExpatParser.cxx \
src/lib/expat/ExpatParser.cxx src/lib/expat/ExpatParser.hxx \
src/playlist/plugins/XspfPlaylistPlugin.cxx \
src/playlist/plugins/XspfPlaylistPlugin.hxx \

View File

@ -19,7 +19,6 @@
#include "config.h"
#include "ExpatParser.hxx"
#include "input/InputStream.hxx"
#include "util/ASCII.hxx"
#include <string.h>
@ -31,23 +30,6 @@ ExpatParser::Parse(const char *data, size_t length, bool is_final)
throw ExpatError(parser);
}
void
ExpatParser::Parse(InputStream &is)
{
assert(is.IsReady());
while (true) {
char buffer[4096];
size_t nbytes = is.LockRead(buffer, sizeof(buffer));
if (nbytes == 0)
break;
Parse(buffer, nbytes, false);
}
Parse("", 0, true);
}
const char *
ExpatParser::GetAttribute(const XML_Char **atts,
const char *name)

View File

@ -0,0 +1,39 @@
/*
* Copyright 2003-2017 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "config.h"
#include "ExpatParser.hxx"
#include "input/InputStream.hxx"
void
ExpatParser::Parse(InputStream &is)
{
assert(is.IsReady());
while (true) {
char buffer[4096];
size_t nbytes = is.LockRead(buffer, sizeof(buffer));
if (nbytes == 0)
break;
Parse(buffer, nbytes, false);
}
Parse("", 0, true);
}