| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560 |
- #include "core/PluginCatalog.h"
- #include <algorithm>
- #include <cctype>
- #include <cstdlib>
- #include <functional>
- #include <sstream>
- namespace lynx::plugincatalog
- {
- namespace
- {
- std::string lower (std::string s)
- {
- std::transform (s.begin(), s.end(), s.begin(), [] (unsigned char c) { return (char) std::tolower (c); });
- return s;
- }
- bool has (const std::string& haystack, std::initializer_list<const char*> words)
- {
- return std::any_of (words.begin(), words.end(), [&haystack] (const char* w) { return haystack.find (w) != std::string::npos; });
- }
- // a short word as a whole token, or a token's start / end ("eq" in "Pro-EQ", "EQ8", not in "Frequency")
- bool hasToken (const std::string& text, std::initializer_list<const char*> words)
- {
- std::vector<std::string> tokens;
- std::string token;
- for (const auto c : text + " ")
- if (std::isalnum ((unsigned char) c))
- token += c;
- else if (! token.empty())
- {
- tokens.push_back (token);
- token.clear();
- }
- for (const auto* w : words)
- {
- const std::string word (w);
- for (const auto& t : tokens)
- if (t.size() >= word.size() && (t.compare (0, word.size(), word) == 0 || t.compare (t.size() - word.size(), word.size(), word) == 0))
- {
- // "eq8" / "proeq" yes; "equalis..." is matched by its own word, "sequencer" never (neither start nor end)
- return true;
- }
- }
- return false;
- }
- // LYNX's category names (the picker shows them translated)
- constexpr const char* synth = "Synth";
- constexpr const char* sampler = "Sampler";
- constexpr const char* drum = "Drum";
- constexpr const char* keys = "Piano & keys";
- constexpr const char* other = "Other";
- constexpr const char* delayReverb = "Delay & reverb";
- constexpr const char* distortion = "Distortion";
- constexpr const char* dynamics = "Dynamics";
- constexpr const char* eqFilter = "EQ & filter";
- constexpr const char* modulation = "Modulation";
- constexpr const char* pitch = "Pitch & vocal";
- constexpr const char* analyzer = "Analyzer";
- constexpr const char* visual = "Visual"; // FL's picker has a Visual group (Wave Candy, ZGameEditor Visualizer; round 164c)
- constexpr const char* utility = "Utility";
- std::string effectCategory (const std::string& declared, const std::string& name)
- {
- // what the plugin declares first (VST3 "Fx|Reverb", CLAP "audio-effect reverb"), then its name
- for (const auto* text : { &declared, &name })
- {
- const auto& t = *text;
- if (has (t, { "visualiz", "visualis", "video", "milkdrop", "projectm", "plugin dance", "big clock", "notebook" }) || hasToken (t, { "visual" }))
- return visual; // (round 165g: FL's Big Clock and HTML NoteBook sit in FL's Visual group)
- if (has (t, { "analy", "meter", "scope", "spectrum", "loudness", "tuner" }))
- return analyzer;
- if (has (t, { "reverb", "verb", "delay", "echo", "plate", "room", "hall", "spring" }))
- return delayReverb;
- if (has (t, { "pitch", "tune", "tuning", "vocal", "voice", "formant", "alterboy", "harmon" }))
- return pitch;
- if (has (t, { "compress", "limit", "dynamic", "gate", "expander", "de-ess", "deess", "transient", "clipper", "maxim", "leveler", "cla-2a",
- "la-2a", "1176" }) || hasToken (t, { "comp" }))
- return dynamics;
- if (has (t, { "filter", "equal", "channel strip", "channelstrip", "sslchannel", "pro-q" }) || hasToken (t, { "eq" }))
- return eqFilter;
- if (has (t, { "chorus", "flang", "phase", "modulat", "tremolo", "vibrato", "doubler", "ensemble", "rotary", "panman", "autopan", "wider", "stereo" }))
- return modulation;
- if (has (t, { "distort", "drive", "satur", "decapitator", "tube", "tape", "crush", "fuzz", "warm", "exciter", "fresh air" }) || hasToken (t, { "amp" }))
- return distortion;
- if (has (t, { "tools", "utility", "gain", "trim", "mono", "routing", "restoration", "noise", "spatial", "mute" }))
- return utility;
- }
- return other;
- }
- std::string instrumentCategory (const std::string& declared, const std::string& name)
- {
- for (const auto* text : { &declared, &name })
- {
- const auto& t = *text;
- if (has (t, { "drum", "beat", "kick", "808", "percussion" }))
- return drum;
- if (has (t, { "sampler", "sample", "rompler", "slicer" }))
- return sampler;
- if (has (t, { "piano", "keys", "organ", "rhodes", "e-piano" }))
- return keys;
- if (has (t, { "synth", "osc", "wavetable", "analog", "bass" }))
- return synth;
- }
- return other;
- }
- } // namespace
- std::string categoryOf (const Entry& entry)
- {
- auto declared = lower (entry.category);
- // the bare kind words say nothing about the category
- for (const auto* generic : { "instrument", "fx", "effect", "audio-effect", "synth|", "generator" })
- if (declared == generic)
- declared.clear();
- if (entry.instrument && (declared == "synth" || declared == "instrument|synth"))
- declared.clear(); // VST2's "Synth": all instruments say it; the name decides (a drum machine, a sampler)
- const auto name = lower (entry.name);
- return entry.instrument ? instrumentCategory (declared, name) : effectCategory (declared, name);
- }
- const std::vector<std::string>& categories (bool instruments)
- {
- static const std::vector<std::string> generators { synth, sampler, drum, keys, other };
- static const std::vector<std::string> effects { delayReverb, distortion, dynamics, eqFilter, modulation, pitch, analyzer, visual, utility, other };
- return instruments ? generators : effects;
- }
- std::vector<int> select (const std::vector<Entry>& entries, const std::set<std::string>& favourites, const Filter& filter)
- {
- std::vector<std::string> words;
- {
- std::string word;
- for (const auto c : lower (filter.query) + " ")
- if (c == ' ')
- {
- if (! word.empty())
- words.push_back (word);
- word.clear();
- }
- else
- word += c;
- }
- std::vector<int> shown;
- for (int i = 0; i < (int) entries.size(); ++i)
- {
- const auto& e = entries[(std::size_t) i];
- if (e.instrument != filter.instruments)
- continue;
- if (filter.favouritesOnly && favourites.count (e.id) == 0)
- continue;
- if (! filter.vendor.empty() && e.vendor != filter.vendor)
- continue;
- const auto category = categoryOf (e);
- if (! filter.category.empty() && category != filter.category)
- continue;
- if (! words.empty())
- {
- const auto text = lower (e.name + " " + e.renamed + " " + e.vendor + " " + e.format + " " + category);
- if (! std::all_of (words.begin(), words.end(), [&text] (const std::string& w) { return text.find (w) != std::string::npos; }))
- continue;
- }
- shown.push_back (i);
- }
- std::sort (shown.begin(), shown.end(), [&] (int a, int b) {
- const auto& x = entries[(std::size_t) a];
- const auto& y = entries[(std::size_t) b];
- if (filter.favouritesFirst)
- {
- const auto fx = favourites.count (x.id) > 0, fy = favourites.count (y.id) > 0;
- if (fx != fy)
- return fx;
- }
- const auto nx = lower (x.shownName()), ny = lower (y.shownName());
- if (nx != ny)
- return nx < ny;
- return x.format < y.format;
- });
- return shown;
- }
- std::vector<std::string> vendors (const std::vector<Entry>& entries, bool instruments)
- {
- std::vector<std::string> list;
- for (const auto& e : entries)
- if (e.instrument == instruments && ! e.vendor.empty() && std::find (list.begin(), list.end(), e.vendor) == list.end())
- list.push_back (e.vendor);
- std::sort (list.begin(), list.end(), [] (const std::string& a, const std::string& b) { return lower (a) < lower (b); });
- return list;
- }
- int countIn (const std::vector<Entry>& entries, bool instruments, const std::string& category)
- {
- return (int) std::count_if (entries.begin(), entries.end(),
- [&] (const Entry& e) { return e.instrument == instruments && (category.empty() || categoryOf (e) == category); });
- }
- // --- round 166f: the user's plugin folders ------------------------------------------------------------------------
- namespace
- {
- std::vector<std::string> splitPath (const std::string& path)
- {
- std::vector<std::string> parts;
- std::string part;
- auto flush = [&] {
- const auto a = part.find_first_not_of (" \t");
- if (a != std::string::npos) parts.push_back (part.substr (a, part.find_last_not_of (" \t") - a + 1));
- part.clear();
- };
- for (const auto c : path)
- if (c == '/' || c == '\\') flush();
- else if (c != '\t' && c != '\n' && c != '\r') part += c;
- flush();
- return parts;
- }
- bool within (const std::string& path, const std::string& folder) // path == folder or inside it
- {
- return path == folder || (path.size() > folder.size() && path.compare (0, folder.size(), folder) == 0 && path[folder.size()] == '/');
- }
- std::string nameKey (const std::string& s)
- {
- std::string k;
- for (const auto c : s)
- if (std::isalnum ((unsigned char) c)) k += (char) std::tolower ((unsigned char) c);
- return k;
- }
- // natural order ("EQ 2" before "EQ 10"), case-insensitive, by path parts
- int naturalCompare (const std::string& a, const std::string& b)
- {
- std::size_t i = 0, j = 0;
- while (i < a.size() && j < b.size())
- {
- if (std::isdigit ((unsigned char) a[i]) && std::isdigit ((unsigned char) b[j]))
- {
- std::size_t i2 = i, j2 = j;
- while (i2 < a.size() && std::isdigit ((unsigned char) a[i2])) ++i2;
- while (j2 < b.size() && std::isdigit ((unsigned char) b[j2])) ++j2;
- const auto na = std::stoull (a.substr (i, std::min<std::size_t> (18, i2 - i))), nb = std::stoull (b.substr (j, std::min<std::size_t> (18, j2 - j)));
- if (na != nb) return na < nb ? -1 : 1;
- i = i2; j = j2;
- continue;
- }
- // '/' sorts first so a parent comes right before its children
- const auto ca = a[i] == '/' ? (char) 1 : (char) std::tolower ((unsigned char) a[i]);
- const auto cb = b[j] == '/' ? (char) 1 : (char) std::tolower ((unsigned char) b[j]);
- if (ca != cb) return ca < cb ? -1 : 1;
- ++i; ++j;
- }
- return a.size() - i == b.size() - j ? 0 : (a.size() - i < b.size() - j ? -1 : 1);
- }
- } // namespace
- std::string cleanFolder (const std::string& path)
- {
- auto parts = splitPath (path);
- if ((int) parts.size() > maxFolderDepth) parts.resize ((std::size_t) maxFolderDepth);
- std::string out;
- for (const auto& p : parts) out += (out.empty() ? "" : "/") + p;
- return out;
- }
- std::string parentFolder (const std::string& path)
- {
- const auto slash = path.rfind ('/');
- return slash == std::string::npos ? std::string() : path.substr (0, slash);
- }
- std::string folderLeaf (const std::string& path)
- {
- const auto slash = path.rfind ('/');
- return slash == std::string::npos ? path : path.substr (slash + 1);
- }
- std::string addFolder (Folders& folders, bool instruments, const std::string& path)
- {
- const auto clean = cleanFolder (path);
- for (auto p = clean; ! p.empty(); p = parentFolder (p))
- folders.kind (instruments).insert (p);
- return clean;
- }
- Folders parseFolders (const std::string& text)
- {
- Folders f;
- std::istringstream in (text);
- std::string line;
- while (std::getline (in, line))
- {
- if (! line.empty() && line.back() == '\r') line.pop_back();
- const auto t1 = line.find ('\t');
- if (t1 == std::string::npos) continue;
- const auto tag = line.substr (0, t1);
- const auto rest = line.substr (t1 + 1);
- if (tag == "fx" || tag == "gen")
- addFolder (f, tag == "gen", rest);
- else if (tag == "view")
- f.view = std::clamp (std::atoi (rest.c_str()), 0, 2);
- else if (tag == "key")
- {
- const auto t2 = rest.rfind ('\t');
- if (t2 == std::string::npos || t2 == 0) continue;
- const auto key = rest.substr (0, t2);
- if (const auto path = cleanFolder (rest.substr (t2 + 1)); ! path.empty()) f.of[key] = path;
- }
- }
- return f;
- }
- std::string formatFolders (const Folders& folders)
- {
- std::string out;
- if (folders.view != 0) out += "view\t" + std::to_string (folders.view) + "\n";
- for (const auto* kind : { "fx", "gen" })
- for (const auto& path : folders.kind (std::string (kind) == "gen"))
- out += std::string (kind) + "\t" + path + "\n";
- for (const auto& [key, path] : folders.of)
- if (! key.empty() && key.find_first_of ("\t\n") == std::string::npos && ! path.empty())
- out += "key\t" + key + "\t" + path + "\n";
- return out;
- }
- bool renameFolder (Folders& folders, bool instruments, const std::string& from, const std::string& to)
- {
- const auto target = cleanFolder (to);
- auto& set = folders.kind (instruments);
- if (target.empty() || ! set.count (from) || within (target, from) || (target != from && set.count (target))) return target == from && ! target.empty();
- std::set<std::string> moved;
- for (auto it = set.begin(); it != set.end();)
- if (within (*it, from)) { moved.insert (target + it->substr (from.size())); it = set.erase (it); }
- else ++it;
- for (const auto& m : moved) addFolder (folders, instruments, m);
- for (auto& [key, path] : folders.of)
- if (within (path, from) && set.count (target + path.substr (from.size())))
- path = target + path.substr (from.size());
- return true;
- }
- void removeFolder (Folders& folders, bool instruments, const std::string& path, const std::vector<std::string>& keys)
- {
- auto& set = folders.kind (instruments);
- for (auto it = set.begin(); it != set.end();)
- it = within (*it, path) ? set.erase (it) : std::next (it);
- for (const auto& key : keys)
- if (const auto it = folders.of.find (key); it != folders.of.end() && within (it->second, path))
- folders.of.erase (it);
- }
- void moveToFolder (Folders& folders, bool instruments, const std::string& key, const std::string& path)
- {
- const auto clean = addFolder (folders, instruments, path);
- if (clean.empty()) folders.of.erase (key);
- else folders.of[key] = clean;
- folders.top.erase (key); // (a choice made in LYNX: no longer a root entry)
- }
- std::vector<MenuFolder> menuTree (const Folders& folders, bool instruments, const std::vector<std::string>& keys)
- {
- const auto& set = folders.kind (instruments);
- std::map<std::string, std::vector<int>> direct;
- for (int i = 0; i < (int) keys.size(); ++i)
- if (const auto it = folders.of.find (keys[(std::size_t) i]); it != folders.of.end() && set.count (it->second))
- direct[it->second].push_back (i);
- std::function<std::vector<MenuFolder> (const std::string&)> build = [&] (const std::string& parent) {
- std::vector<MenuFolder> out;
- for (const auto& path : set)
- if (parentFolder (path) == parent)
- {
- MenuFolder f;
- f.path = path;
- f.name = folderLeaf (path);
- f.sub = build (path);
- if (const auto it = direct.find (path); it != direct.end()) f.items = it->second;
- if (! f.items.empty() || ! f.sub.empty()) out.push_back (std::move (f));
- }
- std::sort (out.begin(), out.end(), [] (const MenuFolder& a, const MenuFolder& b) {
- const auto la = a.path == lynxCategory, lb = b.path == lynxCategory; // LYNX's own plugins first (round 170b)
- if (la != lb)
- return la;
- return naturalCompare (a.name, b.name) < 0;
- });
- return out;
- };
- return build ({});
- }
- std::vector<int> allItems (const std::vector<MenuFolder>& tree)
- {
- std::vector<int> out;
- for (const auto& f : tree)
- {
- const auto inner = allItems (f.sub);
- out.insert (out.end(), inner.begin(), inner.end());
- out.insert (out.end(), f.items.begin(), f.items.end());
- }
- return out;
- }
- std::vector<int> rootItems (const Folders& folders, bool instruments, const std::vector<std::string>& keys)
- {
- std::vector<int> out;
- const auto& set = folders.kind (instruments);
- for (int i = 0; i < (int) keys.size(); ++i)
- {
- const auto& key = keys[(std::size_t) i];
- if (! folders.top.count (key))
- continue;
- if (const auto it = folders.of.find (key); it != folders.of.end() && set.count (it->second))
- continue;
- out.push_back (i);
- }
- return out;
- }
- std::string groupHeading (const std::string& path)
- {
- std::string out;
- for (const auto c : path)
- out += c == '/' ? std::string (" \xe2\x80\xba ") : std::string (1, c); // " › "
- return out;
- }
- int importFlFolders (Folders& folders, bool instruments, const std::vector<std::string>& files,
- const std::vector<std::pair<std::string, std::string>>& keyAndName)
- {
- std::map<std::string, std::string> keyOfName;
- for (const auto& [key, name] : keyAndName)
- keyOfName.emplace (nameKey (name), key);
- int placed = 0;
- for (const auto& file : files)
- {
- auto parts = splitPath (file);
- if (parts.size() < 2) continue; // a preset at the top of the folder: no folder
- auto stem = parts.back();
- if (const auto dot = stem.rfind ('.'); dot != std::string::npos) stem = stem.substr (0, dot);
- parts.pop_back();
- std::string folder;
- for (const auto& p : parts) folder += (folder.empty() ? "" : "/") + p;
- const auto it = keyOfName.find (nameKey (stem));
- if (it == keyOfName.end() || cleanFolder (folder).empty()) continue;
- moveToFolder (folders, instruments, it->second, folder);
- ++placed;
- }
- return placed;
- }
- namespace
- {
- // letters and digits only, lower case ("Fruity X-Y Controller" -> "fruityxycontroller")
- std::string squash (const std::string& name)
- {
- std::string out;
- for (const auto c : name)
- if (std::isalnum ((unsigned char) c))
- out += (char) std::tolower ((unsigned char) c);
- return out;
- }
- struct CategoryList
- {
- const char* folder;
- std::vector<const char*> names;
- };
- const std::vector<CategoryList>& flEffectFolders()
- {
- static const std::vector<CategoryList> list {
- { "Controller", { "Control Surface", "Fruity Formula Controller", "Fruity Peak Controller", "Fruity X-Y Controller", "Fruity X-Y-Z Controller" } },
- { "Delay reverb", { "Fruity Convolver", "Fruity Delay 2", "Fruity Delay 3", "Fruity Delay Bank", "Fruity Reeverb 2", "LuxeVerb", "Multiband Delay",
- /* legacy */ "Fruity Delay", "Fruity Reeverb" } },
- { "Distortion", { "Distructor", "Fruity Blood Overdrive", "Fruity Fast Dist", "Fruity Soft Clipper", "Fruity Squeeze", "Fruity WaveShaper", "Hardcore" } },
- { "Dynamics", { "Emphasis", "Emphasizer", "Fruity Compressor", "Fruity Limiter", "Fruity Multiband Compressor", "Maximus", "Soundgoodizer",
- "Transient Processor" } },
- { "Filter", { "EQUO", "Frequency Splitter", "Fruity Filter", "Fruity Love Philter", "Fruity Parametric EQ 2", "Fruity Parametric EQ",
- /* legacy */ "Fruity 7 Band EQ", "Fruity Bass Boost", "Fruity Fast LP", "Fruity Free Filter" } },
- { "Flanger", { "Fruity Chorus", "Fruity Flanger", "Fruity Flangus", "Fruity Phaser", "Hyper Chorus", "Vintage Chorus", "Vintage Phaser" } },
- { "Gain", { "Fruity Balance", "Fruity PanOMatic", "Fruity Send", "Fruity Stereo Enhancer", "Fruity Stereo Shaper", "Spreader",
- /* legacy */ "Fruity Center", "Fruity Mute 2", "Fruity Phase Inverter" } },
- { "Misc", { "Edison", "Effector", "FL Studio Mobile Rack FX", "Frequency Shifter", "Fruity LSD", "Fruity Scratcher", "Fruity Vocoder", "Gross Beat",
- "Low Lifter", "Newtime", "Newtone", "Pitch Shifter", "Pitcher", "Transmitter", "Transporter", "Vocodex" } },
- { "Patcher", { "Patcher", "VFX Color Mapper", "VFX Envelope", "VFX Key Mapper", "VFX Keyboard Splitter", "VFX Level Scaler", "VFX Script", "VFX Sequencer" } },
- { "Visual", { "Fruity Big Clock", "Fruity HTML NoteBook", "Fruity NoteBook 2", "Fruity NoteBook", "Fruity Spectroman", "Fruity dB Meter", "Razer Chroma",
- "Tuner", "Wave Candy", "ZGameEditor Visualizer", /* LYNX's name of it */ "Visualizer" } },
- };
- return list;
- }
- const std::vector<CategoryList>& flGeneratorFolders()
- {
- static const std::vector<CategoryList> list {
- { "Controller", { "Fruity Envelope Controller", "Fruity Keyboard Controller" } },
- { "Drum", { "BassDrum", "Drumaxx", "Drumpad", "FPC", "Fruit Kick", "Fruity DrumSynth Live", "Fruity Slicer", "Fruity Slicer 2", "Slicex" } },
- { "MIDI", { "Dashboard", "MIDI Out" } },
- { "Misc", { "Audio Clip", "Automation Clip", "BooBass", "FL Keys", "FL Studio Mobile", "FL Studio Mobile Rack", "Fruity Voltage Controller", "Layer",
- "ReWired", "SoundFont Player" } },
- { "Patcher", { "Patcher", "VFX Color Mapper", "VFX Envelope", "VFX Key Mapper", "VFX Keyboard Splitter", "VFX Level Scaler", "VFX Script", "VFX Sequencer" } },
- { "Sampler", { "DirectWave", "Fruity Granulizer", "Sampler", "Wave Traveller" } },
- { "Synth classic", { "3x Osc", "FLEX", "Fruity DX10", "GMS", "Harmless", "Helix", "Kepler", "Kepler Exo", "MiniSynth", "Pocket SuperSaw", "PoiZone", "Sawer", "SimSynth", "Sytrus",
- "Tetra", "Toxic Biohazard", "Transistor Bass" } },
- // (FL lists Ogun under Drum and Synth special; one folder per plugin here: Synth special)
- { "Synth special", { "Autogun", "BeepMap", "Harmor", "Morphine", "Ogun", "Plucked!", "Sakura" } },
- { "Visual", { "Fruity Dance", "Fruity Video Player" } },
- };
- return list;
- }
- } // namespace
- std::string flCategory (const std::string& name, bool instruments, bool fruityPrefix)
- {
- const auto want = squash (name);
- if (want.empty())
- return {};
- for (const auto& folder : instruments ? flGeneratorFolders() : flEffectFolders())
- for (const auto* n : folder.names)
- if (const auto have = squash (n); have == want || (fruityPrefix && have == "fruity" + want))
- return folder.folder;
- return {};
- }
- Folders withDefaultCategories (const Folders& user, bool instruments, const std::vector<BuiltinPlugin>& builtins)
- {
- auto out = user;
- for (const auto& b : builtins)
- {
- if (const auto it = out.of.find (b.key); it != out.of.end() && out.kind (instruments).count (it->second))
- continue; // the user's folder wins
- if (out.hidden.count (b.key))
- continue; // taken out of the database by the user (round 190ba)
- if (out.top.count (b.key))
- continue; // at the top of the database, in no folder (round 190bf)
- auto folder = flCategory (b.name, instruments, b.fruityPrefix || b.flPlugin);
- if (folder.empty())
- folder = b.flPlugin ? "Misc" : lynxCategory;
- out.kind (instruments).insert (folder);
- out.of[b.key] = folder;
- }
- return out;
- }
- std::vector<std::string> combinedBits (const std::vector<std::pair<std::string, bool>>& items)
- {
- std::map<std::string, int> builds; // identity -> bit 1: a 32-bit build, bit 2: a 64-bit build
- for (const auto& [key, is32] : items)
- builds[key] |= is32 ? 1 : 2;
- std::vector<std::string> out;
- out.reserve (items.size());
- for (const auto& [key, is32] : items)
- {
- const auto both = builds[key] == 3;
- out.push_back (both ? (is32 ? "" : "32+64") : (is32 ? "32" : "64"));
- }
- return out;
- }
- } // namespace lynx::plugincatalog
|