LMMS
Loading...
Searching...
No Matches
juce_PluginDescription.cpp
Go to the documentation of this file.
1/*
2 ==============================================================================
3
4 This file is part of the JUCE library.
5 Copyright (c) 2022 - Raw Material Software Limited
6
7 JUCE is an open source library subject to commercial or open-source
8 licensing.
9
10 By using JUCE, you agree to the terms of both the JUCE 7 End-User License
11 Agreement and JUCE Privacy Policy.
12
13 End User License Agreement: www.juce.com/juce-7-licence
14 Privacy Policy: www.juce.com/juce-privacy-policy
15
16 Or: You may also use this code under the terms of the GPL v3 (see
17 www.gnu.org/licenses).
18
19 JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
20 EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
21 DISCLAIMED.
22
23 ==============================================================================
24*/
25
26namespace juce
27{
28
29bool PluginDescription::isDuplicateOf (const PluginDescription& other) const noexcept
30{
31 const auto tie = [] (const PluginDescription& d)
32 {
33 return std::tie (d.fileOrIdentifier, d.deprecatedUid, d.uniqueId);
34 };
35
36 return tie (*this) == tie (other);
37}
38
40{
41 return "-" + String::toHexString (d.fileOrIdentifier.hashCode())
42 + "-" + String::toHexString (uid);
43}
44
45bool PluginDescription::matchesIdentifierString (const String& identifierString) const
46{
47 const auto matches = [&] (int uid)
48 {
49 return identifierString.endsWithIgnoreCase (getPluginDescSuffix (*this, uid));
50 };
51
52 return matches (uniqueId) || matches (deprecatedUid);
53}
54
56{
57 const auto idToUse = uniqueId != 0 ? uniqueId : deprecatedUid;
58 return pluginFormatName + "-" + name + getPluginDescSuffix (*this, idToUse);
59}
60
61std::unique_ptr<XmlElement> PluginDescription::createXml() const
62{
63 auto e = std::make_unique<XmlElement> ("PLUGIN");
64
65 e->setAttribute ("name", name);
66
67 if (descriptiveName != name)
68 e->setAttribute ("descriptiveName", descriptiveName);
69
70 e->setAttribute ("format", pluginFormatName);
71 e->setAttribute ("category", category);
72 e->setAttribute ("manufacturer", manufacturerName);
73 e->setAttribute ("version", version);
74 e->setAttribute ("file", fileOrIdentifier);
75 e->setAttribute ("uniqueId", String::toHexString (uniqueId));
76 e->setAttribute ("isInstrument", isInstrument);
77 e->setAttribute ("fileTime", String::toHexString (lastFileModTime.toMilliseconds()));
78 e->setAttribute ("infoUpdateTime", String::toHexString (lastInfoUpdateTime.toMilliseconds()));
79 e->setAttribute ("numInputs", numInputChannels);
80 e->setAttribute ("numOutputs", numOutputChannels);
81 e->setAttribute ("isShell", hasSharedContainer);
82 e->setAttribute ("hasARAExtension", hasARAExtension);
83
84 e->setAttribute ("uid", String::toHexString (deprecatedUid));
85
86 return e;
87}
88
90{
91 if (xml.hasTagName ("PLUGIN"))
92 {
93 name = xml.getStringAttribute ("name");
94 descriptiveName = xml.getStringAttribute ("descriptiveName", name);
95 pluginFormatName = xml.getStringAttribute ("format");
96 category = xml.getStringAttribute ("category");
97 manufacturerName = xml.getStringAttribute ("manufacturer");
98 version = xml.getStringAttribute ("version");
100 isInstrument = xml.getBoolAttribute ("isInstrument", false);
102 lastInfoUpdateTime = Time (xml.getStringAttribute ("infoUpdateTime").getHexValue64());
103 numInputChannels = xml.getIntAttribute ("numInputs");
104 numOutputChannels = xml.getIntAttribute ("numOutputs");
105 hasSharedContainer = xml.getBoolAttribute ("isShell", false);
106 hasARAExtension = xml.getBoolAttribute ("hasARAExtension", false);
107
109 uniqueId = xml.getStringAttribute ("uniqueId", "0").getHexValue32();
110
111 return true;
112 }
113
114 return false;
115}
116
117} // namespace juce
static String toHexString(int number)
Definition String.cpp:1830
Definition juce_PluginDescription.h:43
int numOutputChannels
Definition juce_PluginDescription.h:127
String pluginFormatName
Definition juce_PluginDescription.h:65
std::unique_ptr< XmlElement > createXml() const
Definition juce_PluginDescription.cpp:61
bool loadFromXml(const XmlElement &xml)
Definition juce_PluginDescription.cpp:89
bool isInstrument
Definition juce_PluginDescription.h:121
bool matchesIdentifierString(const String &identifierString) const
Definition juce_PluginDescription.cpp:45
String category
Definition juce_PluginDescription.h:68
String version
Definition juce_PluginDescription.h:74
bool hasSharedContainer
Definition juce_PluginDescription.h:130
bool isDuplicateOf(const PluginDescription &other) const noexcept
Definition juce_PluginDescription.cpp:29
int numInputChannels
Definition juce_PluginDescription.h:124
String name
Definition juce_PluginDescription.h:56
String manufacturerName
Definition juce_PluginDescription.h:71
int deprecatedUid
Definition juce_PluginDescription.h:103
bool hasARAExtension
Definition juce_PluginDescription.h:133
int uniqueId
Definition juce_PluginDescription.h:118
Time lastFileModTime
Definition juce_PluginDescription.h:87
String descriptiveName
Definition juce_PluginDescription.h:62
String fileOrIdentifier
Definition juce_PluginDescription.h:82
String createIdentifierString() const
Definition juce_PluginDescription.cpp:55
Time lastInfoUpdateTime
Definition juce_PluginDescription.h:92
Definition juce_String.h:53
bool endsWithIgnoreCase(StringRef text) const noexcept
Definition juce_String.cpp:1438
static String toHexString(IntegerType number)
Definition juce_String.h:1097
int64 getHexValue64() const noexcept
Definition juce_String.cpp:1954
int getHexValue32() const noexcept
Definition juce_String.cpp:1953
Definition juce_Time.h:37
Definition juce_XmlElement.h:83
bool getBoolAttribute(StringRef attributeName, bool defaultReturnValue=false) const
Definition juce_XmlElement.cpp:587
bool hasTagName(StringRef possibleTagName) const noexcept
Definition juce_XmlElement.cpp:470
int getIntAttribute(StringRef attributeName, int defaultReturnValue=0) const
Definition juce_XmlElement.cpp:571
const String & getStringAttribute(StringRef attributeName) const noexcept
Definition juce_XmlElement.cpp:555
* e
Definition inflate.c:1404
unsigned d
Definition inflate.c:940
Definition carla_juce.cpp:31
static auto tie(const AudioDeviceManager::AudioDeviceSetup &s)
Definition juce_AudioDeviceManager.cpp:41
static String getPluginDescSuffix(const PluginDescription &d, int uid)
Definition juce_PluginDescription.cpp:39