2009-12-14 21:09:28 +01:00
|
|
|
/*
|
2017-01-03 20:48:59 +01:00
|
|
|
* Copyright 2003-2017 The Music Player Daemon Project
|
2009-12-14 21:09:28 +01:00
|
|
|
* 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"
|
2018-01-02 23:09:36 +01:00
|
|
|
#include "LoadChain.hxx"
|
2018-08-18 20:57:02 +02:00
|
|
|
#include "Factory.hxx"
|
2018-01-01 18:48:34 +01:00
|
|
|
#include "Prepared.hxx"
|
2017-12-27 09:17:15 +01:00
|
|
|
#include "plugins/ChainFilterPlugin.hxx"
|
2009-12-14 21:09:28 +01:00
|
|
|
|
2013-10-19 16:34:11 +02:00
|
|
|
#include <algorithm>
|
2018-08-18 20:57:02 +02:00
|
|
|
#include <string>
|
2013-01-30 22:39:19 +01:00
|
|
|
|
2009-12-14 21:09:28 +01:00
|
|
|
#include <string.h>
|
|
|
|
|
2016-09-04 20:07:05 +02:00
|
|
|
static void
|
2018-08-18 20:57:02 +02:00
|
|
|
filter_chain_append_new(PreparedFilter &chain, FilterFactory &factory,
|
2018-07-17 21:47:32 +02:00
|
|
|
const char *template_name)
|
2013-10-19 16:26:51 +02:00
|
|
|
{
|
2018-08-18 20:57:02 +02:00
|
|
|
filter_chain_append(chain, template_name,
|
|
|
|
factory.MakeFilter(template_name));
|
2013-10-19 16:26:51 +02:00
|
|
|
}
|
|
|
|
|
2016-09-04 20:07:05 +02:00
|
|
|
void
|
2018-07-17 21:47:32 +02:00
|
|
|
filter_chain_parse(PreparedFilter &chain,
|
2018-08-18 20:57:02 +02:00
|
|
|
FilterFactory &factory,
|
2018-07-17 21:47:32 +02:00
|
|
|
const char *spec)
|
2009-12-14 21:09:28 +01:00
|
|
|
{
|
2013-10-19 16:34:11 +02:00
|
|
|
const char *const end = spec + strlen(spec);
|
|
|
|
|
|
|
|
while (true) {
|
|
|
|
const char *comma = std::find(spec, end, ',');
|
|
|
|
if (comma > spec) {
|
|
|
|
const std::string name(spec, comma);
|
2018-08-18 20:57:02 +02:00
|
|
|
filter_chain_append_new(chain, factory, name.c_str());
|
2013-10-19 16:34:11 +02:00
|
|
|
}
|
2009-12-14 21:09:28 +01:00
|
|
|
|
2013-10-19 16:34:11 +02:00
|
|
|
if (comma == end)
|
|
|
|
break;
|
2009-12-14 21:09:28 +01:00
|
|
|
|
2013-10-19 16:34:11 +02:00
|
|
|
spec = comma + 1;
|
2009-12-14 21:09:28 +01:00
|
|
|
}
|
|
|
|
}
|