summaryrefslogtreecommitdiff
path: root/libs/ardour/plugin_manager.cc
diff options
context:
space:
mode:
authorRobin Gareus <robin@gareus.org>2018-01-30 03:12:09 +0100
committerRobin Gareus <robin@gareus.org>2018-01-30 03:12:09 +0100
commit73bafc36eab647d0cd7eaa5fa586df0a7c84a8f6 (patch)
treec393d279cae04fdb5c5c8e1afae42933cf09e738 /libs/ardour/plugin_manager.cc
parent49130df35be6743b1bcd4761db41da8466fbbace (diff)
Clean up tag tokenization code
* accept " ,\n" as separator * produce only " " as separator * squelch error message for empty-string tokenization * clean up code, use existing API methods for lower-case transform
Diffstat (limited to 'libs/ardour/plugin_manager.cc')
-rw-r--r--libs/ardour/plugin_manager.cc41
1 files changed, 22 insertions, 19 deletions
diff --git a/libs/ardour/plugin_manager.cc b/libs/ardour/plugin_manager.cc
index a8379d74a8..eaf5eede9c 100644
--- a/libs/ardour/plugin_manager.cc
+++ b/libs/ardour/plugin_manager.cc
@@ -69,9 +69,10 @@
#include <glibmm/fileutils.h>
#include <glibmm/miscutils.h>
-#include "pbd/whitespace.h"
+#include "pbd/convert.h"
#include "pbd/file_utils.h"
#include "pbd/tokenizer.h"
+#include "pbd/whitespace.h"
#include "ardour/directory_names.h"
#include "ardour/debug.h"
@@ -1487,10 +1488,7 @@ PluginManager::get_tags (const PluginInfoPtr& pi) const
PluginTag ps (to_generic_vst(pi->type), pi->unique_id, "", false);
PluginTagList::const_iterator i = find (ptags.begin(), ptags.end(), ps);
if (i != ptags.end ()) {
-
- if (!PBD::tokenize (i->tags, string(" "), std::back_inserter (tags), true)) {
- cout << _("PluginManager: Could not tokenize string: ") << i->tags << endmsg;
- }
+ PBD::tokenize (i->tags, string(" "), std::back_inserter (tags), true);
SortByTag sorter;
sort (tags.begin(), tags.end(), sorter);
}
@@ -1606,25 +1604,25 @@ PluginManager::set_tags (PluginType t, string id, string tag, bool factory, bool
std::string
PluginManager::sanitize_tag (const std::string to_sanitize) const
{
+ if (to_sanitize.empty ()) {
+ return "";
+ }
string sanitized = to_sanitize;
vector<string> tags;
- if (!PBD::tokenize (sanitized, string(" "), std::back_inserter (tags), true)) {
- cout << _("PluginManager::sanitize_tag could not tokenize string: ") << sanitized << endmsg;
+ if (!PBD::tokenize (sanitized, string(" ,\n"), std::back_inserter (tags), true)) {
+#ifndef NDEBUG
+ cerr << _("PluginManager::sanitize_tag could not tokenize string: ") << sanitized << endmsg;
+#endif
return "";
}
- /* convert tokens to lower-case, comma-separated list */
+ /* convert tokens to lower-case, space-separated list */
sanitized = "";
for (vector<string>::iterator t = tags.begin(); t != tags.end(); ++t) {
- string temp(*t);
- std::transform (temp.begin(), temp.end(), temp.begin(), ::tolower);
- sanitized.append(temp);
- sanitized.append(" ");
- }
-
- /* remove trailing space */
- if (sanitized.length() > 0) {
- sanitized.erase (sanitized.length()-1, 1);
+ if (t != tags.begin ()) {
+ sanitized.append(" ");
+ }
+ sanitized.append (downcase (*t));
}
return sanitized;
@@ -1637,6 +1635,9 @@ PluginManager::get_all_tags (bool favorites_only) const
PluginTagList::const_iterator pt;
for (pt = ptags.begin(); pt != ptags.end(); ++pt) {
+ if ((*pt).tags.empty ()) {
+ continue;
+ }
/* if favorites_only then we need to check the info ptr and maybe skip */
if (favorites_only) {
@@ -1651,8 +1652,10 @@ PluginManager::get_all_tags (bool favorites_only) const
/* parse each plugin's tag string into separate tags */
vector<string> tags;
- if (!PBD::tokenize ((*pt).tags, string(",\n"), std::back_inserter (tags), true)) {
- cout << _("PluginManager: Could not tokenize string: ") << (*pt).tags << endmsg;
+ if (!PBD::tokenize ((*pt).tags, string(" "), std::back_inserter (tags), true)) {
+#ifndef NDEBUG
+ cerr << _("PluginManager: Could not tokenize string: ") << (*pt).tags << endmsg;
+#endif
continue;
}