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.

102 lines
3.7KB

  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. return fileOrIdentifier == other.fileOrIdentifier
  23. && uid == other.uid;
  24. }
  25. static String getPluginDescSuffix (const PluginDescription& d)
  26. {
  27. return "-" + String::toHexString (d.fileOrIdentifier.hashCode())
  28. + "-" + String::toHexString (d.uid);
  29. }
  30. bool PluginDescription::matchesIdentifierString (const String& identifierString) const
  31. {
  32. return identifierString.endsWithIgnoreCase (getPluginDescSuffix (*this));
  33. }
  34. String PluginDescription::createIdentifierString() const
  35. {
  36. return pluginFormatName + "-" + name + getPluginDescSuffix (*this);
  37. }
  38. std::unique_ptr<XmlElement> PluginDescription::createXml() const
  39. {
  40. auto e = std::make_unique<XmlElement> ("PLUGIN");
  41. e->setAttribute ("name", name);
  42. if (descriptiveName != name)
  43. e->setAttribute ("descriptiveName", descriptiveName);
  44. e->setAttribute ("format", pluginFormatName);
  45. e->setAttribute ("category", category);
  46. e->setAttribute ("manufacturer", manufacturerName);
  47. e->setAttribute ("version", version);
  48. e->setAttribute ("file", fileOrIdentifier);
  49. e->setAttribute ("uid", String::toHexString (uid));
  50. e->setAttribute ("isInstrument", isInstrument);
  51. e->setAttribute ("fileTime", String::toHexString (lastFileModTime.toMilliseconds()));
  52. e->setAttribute ("infoUpdateTime", String::toHexString (lastInfoUpdateTime.toMilliseconds()));
  53. e->setAttribute ("numInputs", numInputChannels);
  54. e->setAttribute ("numOutputs", numOutputChannels);
  55. e->setAttribute ("isShell", hasSharedContainer);
  56. return e;
  57. }
  58. bool PluginDescription::loadFromXml (const XmlElement& xml)
  59. {
  60. if (xml.hasTagName ("PLUGIN"))
  61. {
  62. name = xml.getStringAttribute ("name");
  63. descriptiveName = xml.getStringAttribute ("descriptiveName", name);
  64. pluginFormatName = xml.getStringAttribute ("format");
  65. category = xml.getStringAttribute ("category");
  66. manufacturerName = xml.getStringAttribute ("manufacturer");
  67. version = xml.getStringAttribute ("version");
  68. fileOrIdentifier = xml.getStringAttribute ("file");
  69. uid = xml.getStringAttribute ("uid").getHexValue32();
  70. isInstrument = xml.getBoolAttribute ("isInstrument", false);
  71. lastFileModTime = Time (xml.getStringAttribute ("fileTime").getHexValue64());
  72. lastInfoUpdateTime = Time (xml.getStringAttribute ("infoUpdateTime").getHexValue64());
  73. numInputChannels = xml.getIntAttribute ("numInputs");
  74. numOutputChannels = xml.getIntAttribute ("numOutputs");
  75. hasSharedContainer = xml.getBoolAttribute ("isShell", false);
  76. return true;
  77. }
  78. return false;
  79. }
  80. } // namespace juce