From 4488813de7226c033febcb4be4315b691723a04c Mon Sep 17 00:00:00 2001 From: reuk Date: Tue, 25 Nov 2025 12:40:34 +0000 Subject: [PATCH] DynamicObject: Add implementation of equals() --- modules/juce_core/containers/juce_DynamicObject.cpp | 5 +++++ modules/juce_core/containers/juce_DynamicObject.h | 13 +++++++++++++ 2 files changed, 18 insertions(+) diff --git a/modules/juce_core/containers/juce_DynamicObject.cpp b/modules/juce_core/containers/juce_DynamicObject.cpp index eb9d0c10ac..fa7b3fb7a4 100644 --- a/modules/juce_core/containers/juce_DynamicObject.cpp +++ b/modules/juce_core/containers/juce_DynamicObject.cpp @@ -151,6 +151,11 @@ void DynamicObject::writeAsJSON (OutputStream& out, const JSON::FormatOptions& f out << '}'; } +bool DynamicObject::equals (const DynamicObject& other) const +{ + return properties == other.properties; +} + //============================================================================== //============================================================================== diff --git a/modules/juce_core/containers/juce_DynamicObject.h b/modules/juce_core/containers/juce_DynamicObject.h index 0bac0b023a..69b782bb42 100644 --- a/modules/juce_core/containers/juce_DynamicObject.h +++ b/modules/juce_core/containers/juce_DynamicObject.h @@ -125,6 +125,19 @@ public: */ virtual void writeAsJSON (OutputStream&, const JSON::FormatOptions&); + /** Returns true if the properties of this object match the properties of the specified object, + or false otherwise. + */ + bool equals (const DynamicObject& other) const; + + /** Returns true if the properties of this object match the properties of the specified object, + or false otherwise. + */ + bool operator== (const DynamicObject& other) const { return equals (other); } + + /** The inverse of operator==() */ + bool operator!= (const DynamicObject& other) const { return ! operator== (other); } + private: /** Derived classes may override this function to take additional actions after properties are assigned or removed.