135 std::initializer_list<NamedValueSet::NamedValue> properties,
136 std::initializer_list<ValueTree> subTrees = {});
159 bool operator== (
const ValueTree&)
const noexcept;
165 bool operator!= (
const ValueTree&)
const noexcept;
173 bool isEquivalentTo (
const ValueTree&)
const;
179 bool isValid() const noexcept {
return object !=
nullptr; }
208 bool hasType (const
Identifier& typeName) const noexcept;
216 const
var& getProperty (const
Identifier& name) const noexcept;
223 var getProperty (const
Identifier& name, const
var& defaultReturnValue) const;
229 const
var* getPropertyPointer (const
Identifier& name) const noexcept;
236 const
var& operator[] (const
Identifier& name) const noexcept;
248 bool hasProperty (const
Identifier& name) const noexcept;
260 void removeAllProperties (
UndoManager* undoManager);
265 int getNumProperties() const noexcept;
273 Identifier getPropertyName (
int index) const noexcept;
284 bool shouldUpdateSynchronously = false);
290 int getNumChildren() const noexcept;
349 void removeChild (
int childIndex,
UndoManager* undoManager);
369 void moveChild (
int currentIndex,
int newIndex,
UndoManager* undoManager);
374 bool isAChildOf (const
ValueTree& possibleParent) const noexcept;
379 int indexOf (const
ValueTree& child) const noexcept;
398 ValueTree getSibling (
int delta) const noexcept;
410 bool operator== (
const Iterator&)
const;
411 bool operator!= (
const Iterator&)
const;
414 using difference_type = std::ptrdiff_t;
418 using iterator_category = std::forward_iterator_tag;
449 String toXmlString() const;
465 static
ValueTree readFromData (const
void* data,
size_t numBytes);
470 static
ValueTree readFromGZIPData (const
void* data,
size_t numBytes);
511 int indexFromWhichChildWasRemoved) = 0;
521 int oldIndex,
int newIndex) = 0;
535 virtual void valueTreeRedirected (
ValueTree& treeWhichHasBeenChanged);
552 void addListener (
Listener* listener);
555 void removeListener (
Listener* listener);
567 void sendPropertyChangeMessage (
const Identifier& property);
591 template <
typename ElementComparator>
592 void sort (ElementComparator& comparator,
UndoManager* undoManager,
bool retainOrderOfEquivalentItems)
594 if (
object !=
nullptr)
597 createListOfChildren (sortedList);
598 ComparatorAdapter<ElementComparator> adapter (comparator);
599 sortedList.
sort (adapter, retainOrderOfEquivalentItems);
600 reorderChildren (sortedList, undoManager);
607 int getReferenceCount() const noexcept;
612 JUCE_DEPRECATED_STATIC (static const
ValueTree invalid;)
616 JUCE_PUBLIC_IN_DLL_BUILD (class SharedObject)
617 friend class SharedObject;
622 template <typename ElementComparator>
623 struct ComparatorAdapter
625 ComparatorAdapter (ElementComparator& comp) noexcept : comparator (comp) {}
627 int compareElements (
const ValueTree*
const first,
const ValueTree*
const second)
629 return comparator.compareElements (*first, *second);
633 ElementComparator& comparator;
634 JUCE_DECLARE_NON_COPYABLE (ComparatorAdapter)
637 void createListOfChildren (OwnedArray<ValueTree>&)
const;
638 void reorderChildren (
const OwnedArray<ValueTree>&, UndoManager*);
640 explicit ValueTree (ReferenceCountedObjectPtr<SharedObject>)
noexcept;
641 explicit ValueTree (SharedObject&)
noexcept;
Represents a string identifier, designed for accessing properties by name.
Holds a set of objects and can invoke a member function callback on each object in the set with a sin...
The base class for streams that write data to some kind of destination.
An array designed for holding objects.
void sort(ElementComparator &comparator, bool retainOrderOfEquivalentItems=false) const noexcept
Sorts the elements in the array.
A smart-pointer class which points to a reference-counted object.
Manages a list of undo/redo commands.
Listener class for events that happen to a ValueTree.
virtual void valueTreeChildRemoved(ValueTree &parentTree, ValueTree &childWhichHasBeenRemoved, int indexFromWhichChildWasRemoved)=0
This method is called when a child sub-tree is removed.
virtual void valueTreeChildAdded(ValueTree &parentTree, ValueTree &childWhichHasBeenAdded)=0
This method is called when a child sub-tree is added.
virtual ~Listener()=default
Destructor.
virtual void valueTreeParentChanged(ValueTree &treeWhoseParentHasChanged)=0
This method is called when a tree has been added or removed from a parent.
virtual void valueTreeChildOrderChanged(ValueTree &parentTreeWhoseChildrenHaveMoved, int oldIndex, int newIndex)=0
This method is called when a tree's children have been re-shuffled.
virtual void valueTreePropertyChanged(ValueTree &treeWhosePropertyHasChanged, const Identifier &property)=0
This method is called when a property of this tree (or of one of its sub-trees) is changed.
A powerful tree structure that can be used to hold free-form data, and which can handle its own undo ...
bool isValid() const noexcept
Returns true if this tree refers to some valid data.
void sort(ElementComparator &comparator, UndoManager *undoManager, bool retainOrderOfEquivalentItems)
This method uses a comparator object to sort the tree's children into order.
Represents a shared variant value.
Used to build a tree of elements representing an XML document.
A variant class, that can be used to hold a range of primitive values.
#define JUCE_API
This macro is added to all JUCE public class declarations.
Iterator for a ValueTree.