diff --git a/modules/juce_data_structures/values/juce_ValueTree.cpp b/modules/juce_data_structures/values/juce_ValueTree.cpp index f601bf71cf..a76a0c48c9 100644 --- a/modules/juce_data_structures/values/juce_ValueTree.cpp +++ b/modules/juce_data_structures/values/juce_ValueTree.cpp @@ -743,6 +743,12 @@ var ValueTree::getProperty (const Identifier& name, const var& defaultReturnValu : object->properties.getWithDefault (name, defaultReturnValue); } +const var* ValueTree::getPropertyPointer (const Identifier& name) const noexcept +{ + return object == nullptr ? nullptr + : object->properties.getVarPointer (name); +} + ValueTree& ValueTree::setProperty (const Identifier& name, const var& newValue, UndoManager* undoManager) { jassert (name.toString().isNotEmpty()); // Must have a valid property name! diff --git a/modules/juce_data_structures/values/juce_ValueTree.h b/modules/juce_data_structures/values/juce_ValueTree.h index c65a08150a..edb611ddf7 100644 --- a/modules/juce_data_structures/values/juce_ValueTree.h +++ b/modules/juce_data_structures/values/juce_ValueTree.h @@ -145,17 +145,23 @@ public: /** Returns the value of a named property. If no such property has been set, this will return a void variant. You can also use operator[] to get a property. - @see var, setProperty, hasProperty + @see var, setProperty, getPropertyPointer, hasProperty */ const var& getProperty (const Identifier& name) const noexcept; - /** Returns the value of a named property, or a user-specified default if the property doesn't exist. - If no such property has been set, this will return the value of defaultReturnValue. + /** Returns the value of a named property, or the value of defaultReturnValue + if the property doesn't exist. You can also use operator[] and getProperty to get a property. - @see var, getProperty, setProperty, hasProperty + @see var, getProperty, getPropertyPointer, setProperty, hasProperty */ var getProperty (const Identifier& name, const var& defaultReturnValue) const; + /** Returns a pointer to the value of a named property, or nullptr if the property + doesn't exist. + @see var, getProperty, setProperty, hasProperty + */ + const var* getPropertyPointer (const Identifier& name) const noexcept; + /** Returns the value of a named property. If no such property has been set, this will return a void variant. This is the same as calling getProperty().