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.

110 lines
4.0KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2020 - Raw Material Software Limited
  5. JUCE is an open source library subject to commercial or open-source
  6. licensing.
  7. By using JUCE, you agree to the terms of both the JUCE 6 End-User License
  8. Agreement and JUCE Privacy Policy (both effective as of the 16th June 2020).
  9. End User License Agreement: www.juce.com/juce-6-licence
  10. Privacy Policy: www.juce.com/juce-privacy-policy
  11. Or: You may also use this code under the terms of the GPL v3 (see
  12. www.gnu.org/licenses).
  13. JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
  14. EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
  15. DISCLAIMED.
  16. ==============================================================================
  17. */
  18. namespace juce
  19. {
  20. bool PluginDescription::isDuplicateOf (const PluginDescription& other) const noexcept
  21. {
  22. const auto tie = [] (const PluginDescription& d)
  23. {
  24. return std::tie (d.fileOrIdentifier, d.deprecatedUid, d.uniqueId);
  25. };
  26. return tie (*this) == tie (other);
  27. }
  28. static String getPluginDescSuffix (const PluginDescription& d)
  29. {
  30. return "-" + String::toHexString (d.fileOrIdentifier.hashCode())
  31. + "-" + String::toHexString (d.uniqueId);
  32. }
  33. bool PluginDescription::matchesIdentifierString (const String& identifierString) const
  34. {
  35. return identifierString.endsWithIgnoreCase (getPluginDescSuffix (*this));
  36. }
  37. String PluginDescription::createIdentifierString() const
  38. {
  39. return pluginFormatName + "-" + name + getPluginDescSuffix (*this);
  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 ("uid", String::toHexString (deprecatedUid));
  60. return e;
  61. }
  62. bool PluginDescription::loadFromXml (const XmlElement& xml)
  63. {
  64. if (xml.hasTagName ("PLUGIN"))
  65. {
  66. name = xml.getStringAttribute ("name");
  67. descriptiveName = xml.getStringAttribute ("descriptiveName", name);
  68. pluginFormatName = xml.getStringAttribute ("format");
  69. category = xml.getStringAttribute ("category");
  70. manufacturerName = xml.getStringAttribute ("manufacturer");
  71. version = xml.getStringAttribute ("version");
  72. fileOrIdentifier = xml.getStringAttribute ("file");
  73. isInstrument = xml.getBoolAttribute ("isInstrument", false);
  74. lastFileModTime = Time (xml.getStringAttribute ("fileTime").getHexValue64());
  75. lastInfoUpdateTime = Time (xml.getStringAttribute ("infoUpdateTime").getHexValue64());
  76. numInputChannels = xml.getIntAttribute ("numInputs");
  77. numOutputChannels = xml.getIntAttribute ("numOutputs");
  78. hasSharedContainer = xml.getBoolAttribute ("isShell", false);
  79. deprecatedUid = xml.getStringAttribute ("uid").getHexValue32();
  80. uniqueId = xml.getStringAttribute ("uniqueId", "0").getHexValue32();
  81. return true;
  82. }
  83. return false;
  84. }
  85. } // namespace juce