2012-08-29 20:03:37 +02:00
|
|
|
/*
|
2018-09-02 10:42:47 +02:00
|
|
|
* Copyright 2003-2018 The Music Player Daemon Project
|
2012-08-29 20:03:37 +02: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.
|
|
|
|
*/
|
|
|
|
|
2014-01-24 16:18:50 +01:00
|
|
|
#include "Selection.hxx"
|
2018-08-02 13:45:43 +02:00
|
|
|
#include "song/Filter.hxx"
|
2012-08-29 20:03:37 +02:00
|
|
|
|
2013-10-29 18:54:34 +01:00
|
|
|
DatabaseSelection::DatabaseSelection(const char *_uri, bool _recursive,
|
2018-09-02 10:43:18 +02:00
|
|
|
const SongFilter *_filter) noexcept
|
2018-09-02 10:42:54 +02:00
|
|
|
:uri(_uri), filter(_filter), recursive(_recursive)
|
2013-10-29 18:54:34 +01:00
|
|
|
{
|
|
|
|
/* optimization: if the caller didn't specify a base URI, pick
|
|
|
|
the one from SongFilter */
|
2015-06-25 23:14:40 +02:00
|
|
|
if (uri.empty() && filter != nullptr) {
|
|
|
|
auto base = filter->GetBase();
|
|
|
|
if (base != nullptr)
|
|
|
|
uri = base;
|
|
|
|
}
|
2013-10-29 18:54:34 +01:00
|
|
|
}
|
|
|
|
|
2014-06-23 09:12:51 +02:00
|
|
|
bool
|
2017-05-08 14:44:49 +02:00
|
|
|
DatabaseSelection::IsEmpty() const noexcept
|
2014-06-23 09:12:51 +02:00
|
|
|
{
|
|
|
|
return uri.empty() && (filter == nullptr || filter->IsEmpty());
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2017-05-08 14:44:49 +02:00
|
|
|
DatabaseSelection::HasOtherThanBase() const noexcept
|
2014-06-23 09:12:51 +02:00
|
|
|
{
|
|
|
|
return filter != nullptr && filter->HasOtherThanBase();
|
|
|
|
}
|
|
|
|
|
2012-08-29 20:03:37 +02:00
|
|
|
bool
|
2017-05-08 14:44:49 +02:00
|
|
|
DatabaseSelection::Match(const LightSong &song) const noexcept
|
2012-08-29 20:03:37 +02:00
|
|
|
{
|
2012-08-29 19:27:03 +02:00
|
|
|
return filter == nullptr || filter->Match(song);
|
2012-08-29 20:03:37 +02:00
|
|
|
}
|