13
0

move match_search_strings() function from plugin utils to PBD

This commit is contained in:
Paul Davis 2023-01-22 17:33:43 -07:00
parent 79033d8ee5
commit d982507085
3 changed files with 47 additions and 16 deletions

View File

@ -407,6 +407,8 @@ plugin_type (const PluginType t)
bool
PluginManagerUI::show_this_plugin (boost::shared_ptr<PluginScanLogEntry> psle, PluginInfoPtr pip, const std::string& searchstr)
{
using PBD::match_search_strings;
if (searchstr.empty ()) {
return true;
}

View File

@ -22,7 +22,7 @@
#include <list>
#include <string>
#include <boost/tokenizer.hpp>
#include "pbd/match.h"
#include "ardour/plugin.h"
#include "ardour/plugin_manager.h"
@ -37,21 +37,6 @@ setup_search_string (std::string& searchstr)
transform (searchstr.begin (), searchstr.end (), searchstr.begin (), ::toupper);
}
inline static bool
match_search_strings (std::string const& haystack, std::string const& needle)
{
boost::char_separator<char> sep (" ");
typedef boost::tokenizer<boost::char_separator<char> > tokenizer;
tokenizer t (needle, sep);
for (tokenizer::iterator ti = t.begin (); ti != t.end (); ++ti) {
if (haystack.find (*ti) == std::string::npos) {
return false;
}
}
return true;
}
struct PluginUIOrderSorter {
public:
bool operator() (ARDOUR::PluginInfoPtr a, ARDOUR::PluginInfoPtr b) const

44
libs/pbd/pbd/match.h Normal file
View File

@ -0,0 +1,44 @@
/*
* Copyright (C) 2020 Robin Gareus <robin@gareus.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.
*/
#ifndef __libpbd_match_h__
#define __libpbd_match_h__
#include <string>
#include <boost/tokenizer.hpp>
namespace PBD {
inline static bool
match_search_strings (std::string const& haystack, std::string const& needle)
{
boost::char_separator<char> sep (" ");
typedef boost::tokenizer<boost::char_separator<char> > tokenizer;
tokenizer t (needle, sep);
for (tokenizer::iterator ti = t.begin (); ti != t.end (); ++ti) {
if (haystack.find (*ti) == std::string::npos) {
return false;
}
}
return true;
}
}
#endif /* __libpbd_match_h__ */