From d98250708552ea1db3e5b57021d2e08e4d1ccd02 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Sun, 22 Jan 2023 17:33:43 -0700 Subject: [PATCH] move match_search_strings() function from plugin utils to PBD --- gtk2_ardour/plugin_manager_ui.cc | 2 ++ gtk2_ardour/plugin_utils.h | 17 +----------- libs/pbd/pbd/match.h | 44 ++++++++++++++++++++++++++++++++ 3 files changed, 47 insertions(+), 16 deletions(-) create mode 100644 libs/pbd/pbd/match.h diff --git a/gtk2_ardour/plugin_manager_ui.cc b/gtk2_ardour/plugin_manager_ui.cc index fbc6fc84e3..3d7db836c6 100644 --- a/gtk2_ardour/plugin_manager_ui.cc +++ b/gtk2_ardour/plugin_manager_ui.cc @@ -407,6 +407,8 @@ plugin_type (const PluginType t) bool PluginManagerUI::show_this_plugin (boost::shared_ptr psle, PluginInfoPtr pip, const std::string& searchstr) { + using PBD::match_search_strings; + if (searchstr.empty ()) { return true; } diff --git a/gtk2_ardour/plugin_utils.h b/gtk2_ardour/plugin_utils.h index cc026122a6..d93c87b08b 100644 --- a/gtk2_ardour/plugin_utils.h +++ b/gtk2_ardour/plugin_utils.h @@ -22,7 +22,7 @@ #include #include -#include +#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 sep (" "); - typedef boost::tokenizer > 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 diff --git a/libs/pbd/pbd/match.h b/libs/pbd/pbd/match.h new file mode 100644 index 0000000000..33d0c5d283 --- /dev/null +++ b/libs/pbd/pbd/match.h @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2020 Robin Gareus + * + * 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 +#include + +namespace PBD { + +inline static bool +match_search_strings (std::string const& haystack, std::string const& needle) +{ + boost::char_separator sep (" "); + typedef boost::tokenizer > 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__ */