46HostApplication::HostApplication ()
50 mPlugInterfaceSupport =
owned (
new PlugInterfaceSupport);
56 return VST3::StringConvert::convert (
"My VST3 HostApplication", name) ? kResultTrue :
63 if (FUnknownPrivate::iidEqual (cid, IMessage::iid) &&
64 FUnknownPrivate::iidEqual (_iid, IMessage::iid))
69 if (FUnknownPrivate::iidEqual (cid, IAttributeList::iid) &&
70 FUnknownPrivate::iidEqual (_iid, IAttributeList::iid))
89 if (mPlugInterfaceSupport && mPlugInterfaceSupport->queryInterface (iid, obj) == kResultTrue)
111IMPLEMENT_FUNKNOWN_METHODS (HostMessage, IMessage, IMessage::iid)
113HostMessage::HostMessage () {FUNKNOWN_CTOR}
116HostMessage::~HostMessage () noexcept
118 setMessageID (
nullptr);
129void PLUGIN_API HostMessage::setMessageID (
const char* mid)
136 size_t len =
strlen (mid) + 1;
137 messageId =
new char[len];
147 return attributeList;
165 Attribute (int64 value) : type (Type::kInteger) { v.intValue = value; }
166 Attribute (
double value) : type (Type::kFloat) { v.floatValue = value; }
169 : size (sizeInCodeUnit), type (Type::kString)
171 v.stringValue =
new TChar[sizeInCodeUnit];
172 memcpy (v.stringValue, value, sizeInCodeUnit * sizeof (
TChar));
174 Attribute (
const void* value, uint32 sizeInBytes) : size (sizeInBytes), type (Type::kBinary)
176 v.binaryValue =
new char[sizeInBytes];
177 memcpy (v.binaryValue, value, sizeInBytes);
186 o.type = Type::kUninitialized;
193 delete[] v.binaryValue;
196 int64 intValue ()
const {
return v.intValue; }
197 double floatValue ()
const {
return v.floatValue; }
199 const TChar* stringValue (uint32& sizeInCodeUnit)
201 sizeInCodeUnit = size;
202 return v.stringValue;
204 const void* binaryValue (uint32& sizeInBytes)
207 return v.binaryValue;
210 Type getType ()
const {
return type; }
221 Type type {Type::kUninitialized};
236HostAttributeList::HostAttributeList () {FUNKNOWN_CTOR}
239HostAttributeList::~HostAttributeList () noexcept
248 return kInvalidArgument;
257 return kInvalidArgument;
258 auto it = list.find (aid);
259 if (it != list.end () && it->second.getType () == Attribute::Type::kInteger)
261 value = it->second.intValue ();
271 return kInvalidArgument;
280 return kInvalidArgument;
281 auto it = list.find (aid);
282 if (it != list.end () && it->second.getType () == Attribute::Type::kFloat)
284 value = it->second.floatValue ();
294 return kInvalidArgument;
296 auto length = tstrlen (
string) + 1;
305 return kInvalidArgument;
306 auto it = list.find (aid);
307 if (it != list.end () && it->second.getType () == Attribute::Type::kString)
309 uint32 sizeInCodeUnit = 0;
310 const TChar* _string = it->second.stringValue (sizeInCodeUnit);
311 memcpy (
string, _string, std::min<uint32> (sizeInCodeUnit *
sizeof (
TChar), sizeInBytes));
321 return kInvalidArgument;
322 list[aid] =
Attribute (data, sizeInBytes);
330 return kInvalidArgument;
331 auto it = list.find (aid);
332 if (it != list.end () && it->second.getType () == Attribute::Type::kBinary)
334 data = it->second.binaryValue (sizeInBytes);
virtual uint32 PLUGIN_API addRef()=0
Adds a reference and returns the new reference count.
virtual uint32 PLUGIN_API release()=0
Releases a reference and returns the new reference count.
virtual tresult PLUGIN_API queryInterface(const TUID _iid, void **obj)=0
Query for a pointer to the specified interface.
IPtr - Smart pointer template class.
tresult PLUGIN_API getName(String128 name) override
Gets host application name.
tresult PLUGIN_API createInstance(TUID cid, TUID _iid, void **obj) override
Creates host object (e.g.
Example, ready to use implementation of IAttributeList.
tresult PLUGIN_API getInt(AttrID aid, int64 &value) override
Gets integer value.
tresult PLUGIN_API setString(AttrID aid, const TChar *string) override
Sets string value (UTF16) (must be null-terminated!).
tresult PLUGIN_API getBinary(AttrID aid, const void *&data, uint32 &sizeInBytes) override
Gets binary data.
static IPtr< IAttributeList > make()
make a new attribute list instance
tresult PLUGIN_API setInt(AttrID aid, int64 value) override
Sets integer value.
tresult PLUGIN_API setFloat(AttrID aid, double value) override
Sets float value.
tresult PLUGIN_API getString(AttrID aid, TChar *string, uint32 sizeInBytes) override
Gets string value (UTF16).
tresult PLUGIN_API setBinary(AttrID aid, const void *data, uint32 sizeInBytes) override
Sets binary data.
tresult PLUGIN_API getFloat(AttrID aid, double &value) override
Gets float value.
Example implementation of IMessage.
IAttributeList *PLUGIN_API getAttributes() override
Returns the attribute list associated to the message.
const char *PLUGIN_API getMessageID() override
Returns the message ID (for example "TextMessage").
Attribute list used in IMessage and IStreamAttributes: Vst::IAttributeList.
Basic host callback interface: Vst::IHostApplication.
TChar String128[128]
128 character UTF-16 string
char16 TChar
UTF-16 character.
IPtr< I > owned(I *p)
Assigning newly created object to an IPtr.