Browse Source

Added a DynamicObject::cloneAllProperties() method.

tags/2021-05-28
jules 11 years ago
parent
commit
f38dc2fe3a
2 changed files with 11 additions and 6 deletions
  1. +8
    -6
      modules/juce_core/containers/juce_DynamicObject.cpp
  2. +3
    -0
      modules/juce_core/containers/juce_DynamicObject.h

+ 8
- 6
modules/juce_core/containers/juce_DynamicObject.cpp View File

@@ -83,12 +83,9 @@ void DynamicObject::clear()
properties.clear();
}
DynamicObject::Ptr DynamicObject::clone()
void DynamicObject::cloneAllProperties()
{
DynamicObject* newCopy = new DynamicObject();
newCopy->properties = properties;
for (LinkedListPointer<NamedValueSet::NamedValue>* i = &(newCopy->properties.values);;)
for (LinkedListPointer<NamedValueSet::NamedValue>* i = &(properties.values);;)
{
if (NamedValueSet::NamedValue* const v = i->get())
{
@@ -98,8 +95,13 @@ DynamicObject::Ptr DynamicObject::clone()
else
break;
}
}
return newCopy;
DynamicObject::Ptr DynamicObject::clone()
{
Ptr d (new DynamicObject (*this));
d->cloneAllProperties();
return d;
}
void DynamicObject::writeAsJSON (OutputStream& out, const int indentLevel, const bool allOnOneLine)


+ 3
- 0
modules/juce_core/containers/juce_DynamicObject.h View File

@@ -103,6 +103,9 @@ public:
/** Returns the NamedValueSet that holds the object's properties. */
NamedValueSet& getProperties() noexcept { return properties; }
/** Calls var::clone() on all the properties that this object contains. */
void cloneAllProperties();
//==============================================================================
/** Returns a clone of this object.
The default implementation of this method just returns a new DynamicObject


Loading…
Cancel
Save