21#include <juce_core/juce_core.h>
22#include <juce_data_structures/juce_data_structures.h>
31 static inline const juce::Identifier
Result {
"result" };
35 using Predicate = std::function<bool (juce::ValueTree)>;
41 using Comparison = std::function<int (
const juce::ValueTree&,
const juce::ValueTree&)>;
48 Query (
const juce::Identifier& resultType =
Result);
58 Query (Predicate filter,
const juce::Identifier& resultType =
Result);
89 juce::ValueTree
search (juce::ValueTree tree,
bool deep,
bool returnFirstFound =
false)
const;
110 juce::ValueTree
sort (juce::ValueTree tree, juce::UndoManager* undo =
nullptr,
bool stableSort =
false)
const;
120 bool filter (juce::ValueTree tree)
const;
123 friend class juce::ValueTree;
132 int compareElements (
const juce::ValueTree& left,
const juce::ValueTree& right)
const;
136 juce::Identifier type;
138 std::vector<Predicate> filters;
140 std::vector<Comparison> sorters;
Definition cello_query.h:28
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
static const juce::Identifier Result
The default identifier for the query results tree.
Definition cello_query.h:31
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