The JUCE cross-platform C++ framework, with DISTRHO/KXStudio specific changes
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

111 lines
4.1KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE 7 technical preview.
  4. Copyright (c) 2022 - Raw Material Software Limited
  5. You may use this code under the terms of the GPL v3
  6. (see www.gnu.org/licenses).
  7. For the technical preview this file cannot be licensed commercially.
  8. JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
  9. EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
  10. DISCLAIMED.
  11. ==============================================================================
  12. */
  13. namespace juce
  14. {
  15. bool PluginDescription::isDuplicateOf (const PluginDescription& other) const noexcept
  16. {
  17. const auto tie = [] (const PluginDescription& d)
  18. {
  19. return std::tie (d.fileOrIdentifier, d.deprecatedUid, d.uniqueId);
  20. };
  21. return tie (*this) == tie (other);
  22. }
  23. static String getPluginDescSuffix (const PluginDescription& d, int uid)
  24. {
  25. return "-" + String::toHexString (d.fileOrIdentifier.hashCode())
  26. + "-" + String::toHexString (uid);
  27. }
  28. bool PluginDescription::matchesIdentifierString (const String& identifierString) const
  29. {
  30. const auto matches = [&] (int uid)
  31. {
  32. return identifierString.endsWithIgnoreCase (getPluginDescSuffix (*this, uid));
  33. };
  34. return matches (uniqueId) || matches (deprecatedUid);
  35. }
  36. String PluginDescription::createIdentifierString() const
  37. {
  38. const auto idToUse = uniqueId != 0 ? uniqueId : deprecatedUid;
  39. return pluginFormatName + "-" + name + getPluginDescSuffix (*this, idToUse);
  40. }
  41. std::unique_ptr<XmlElement> PluginDescription::createXml() const
  42. {
  43. auto e = std::make_unique<XmlElement> ("PLUGIN");
  44. e->setAttribute ("name", name);
  45. if (descriptiveName != name)
  46. e->setAttribute ("descriptiveName", descriptiveName);
  47. e->setAttribute ("format", pluginFormatName);
  48. e->setAttribute ("category", category);
  49. e->setAttribute ("manufacturer", manufacturerName);
  50. e->setAttribute ("version", version);
  51. e->setAttribute ("file", fileOrIdentifier);
  52. e->setAttribute ("uniqueId", String::toHexString (uniqueId));
  53. e->setAttribute ("isInstrument", isInstrument);
  54. e->setAttribute ("fileTime", String::toHexString (lastFileModTime.toMilliseconds()));
  55. e->setAttribute ("infoUpdateTime", String::toHexString (lastInfoUpdateTime.toMilliseconds()));
  56. e->setAttribute ("numInputs", numInputChannels);
  57. e->setAttribute ("numOutputs", numOutputChannels);
  58. e->setAttribute ("isShell", hasSharedContainer);
  59. e->setAttribute ("hasARAExtension", hasARAExtension);
  60. e->setAttribute ("uid", String::toHexString (deprecatedUid));
  61. return e;
  62. }
  63. bool PluginDescription::loadFromXml (const XmlElement& xml)
  64. {
  65. if (xml.hasTagName ("PLUGIN"))
  66. {
  67. name = xml.getStringAttribute ("name");
  68. descriptiveName = xml.getStringAttribute ("descriptiveName", name);
  69. pluginFormatName = xml.getStringAttribute ("format");
  70. category = xml.getStringAttribute ("category");
  71. manufacturerName = xml.getStringAttribute ("manufacturer");
  72. version = xml.getStringAttribute ("version");
  73. fileOrIdentifier = xml.getStringAttribute ("file");
  74. isInstrument = xml.getBoolAttribute ("isInstrument", false);
  75. lastFileModTime = Time (xml.getStringAttribute ("fileTime").getHexValue64());
  76. lastInfoUpdateTime = Time (xml.getStringAttribute ("infoUpdateTime").getHexValue64());
  77. numInputChannels = xml.getIntAttribute ("numInputs");
  78. numOutputChannels = xml.getIntAttribute ("numOutputs");
  79. hasSharedContainer = xml.getBoolAttribute ("isShell", false);
  80. hasARAExtension = xml.getBoolAttribute ("hasARAExtension", false);
  81. deprecatedUid = xml.getStringAttribute ("uid").getHexValue32();
  82. uniqueId = xml.getStringAttribute ("uniqueId", "0").getHexValue32();
  83. return true;
  84. }
  85. return false;
  86. }
  87. } // namespace juce