20#include "cello_query.h"
37 filters.push_back (filter);
41juce::ValueTree
Query::search (juce::ValueTree tree,
bool deep,
bool returnFirstFound)
const
43 juce::ValueTree result { type };
44 for (
auto child : tree)
48 auto childCopy { juce::ValueTree { child.getType () } };
50 childCopy.copyPropertiesAndChildrenFrom (child,
nullptr);
52 childCopy.copyPropertiesFrom (child,
nullptr);
55 result.appendChild (childCopy,
nullptr);
66bool Query::filter (juce::ValueTree tree)
const
68 if (filters.size () > 0)
70 for (
auto fn : filters)
81 sorters.push_back (sorter);
85juce::ValueTree
Query::sort (juce::ValueTree tree, juce::UndoManager* undo,
bool stableSort)
const
87 if (sorters.size () > 0)
88 tree.
sort (*
this, undo, stableSort);
92int Query::compareElements (
const juce::ValueTree& left,
const juce::ValueTree& right)
const
94 for (
auto sorter : sorters)
96 auto sortOrder { sorter (left, right) };
105#include "test/test_cello_query.inl"
juce::ValueTree sort(juce::ValueTree tree, juce::UndoManager *undo=nullptr, bool stableSort=false) const
Use the list of comparison functions to sort the tree arg into its desired order.
Definition cello_query.cpp:85
Query & addComparison(Comparison sorter)
Add a comparison function to the list we use to sort a list of children.
Definition cello_query.cpp:79
Query & addFilter(Predicate filter)
Append a filter predicate to the end of our list; these are executed in the sequence they're added,...
Definition cello_query.cpp:35
Query(const juce::Identifier &resultType=Result)
Construct a new Query object.
Definition cello_query.cpp:24
juce::ValueTree search(juce::ValueTree tree, bool deep, bool returnFirstFound=false) const
Execute the query we're programmed for – iterate through the children of tree, returning a new tree o...
Definition cello_query.cpp:41