cello
JUCE ValueTrees for Humans
Loading...
Searching...
No Matches
cello::Path Class Reference

Class to navigate between subtrees that are all connected together. More...

#include <cello_path.h>

Public Types

enum class  SearchType { query , createTarget , createAll }
 
enum  SearchResult { notFound , found , created }
 

Public Member Functions

 Path (const juce::String &pathString)
 
juce::ValueTree findValueTree (juce::ValueTree &origin, SearchType searchType, juce::UndoManager *undo=nullptr)
 Navigate the path from origin to a tree that is expected at the end of the current path specification.
 
SearchResult getSearchResult () const
 Find out whether performing a search succeeded, and if so, needed to create a new tree.
 

Static Public Attributes

static const juce::String sep { "/" }
 Path separator.
 
static const juce::String ancestor { "^" }
 
static const juce::String parent { ".." }
 
static const juce::String current { "." }
 

Detailed Description

Class to navigate between subtrees that are all connected together.

This is designed to operate similarly to directory paths, using a slash-separated string to declare a path between a ValueTree and some other ancestor, sibling, or descendant tree that can be reached from it.

Syntax works as follows:

  • "child" without additional indications, a segment refers to a child.
  • ".." the parent of the current tree
  • "/" separates segments. Begin a path string with this to indicate paths beginning at the root tree.
  • "^{treeType}" navigate to the first parent tree of this type.
  • "" (empty path string) refers to the current tree.

These work together as expected, so that "../siblingName" would specify a sibling of the current tree, "child/grandChild</tt>" specifies a descendant tree two levels below the current one.

Member Enumeration Documentation

◆ SearchResult

Enumerator
notFound 

unable to find the requested tree

found 

the sought tree existed already and was found

created 

performing a search created a new tree

◆ SearchType

enum class cello::Path::SearchType
strong
Enumerator
query 

only search, do not create anything.

createTarget 

create final tree in specification, but no intermediate trees

createAll 

create final tree and all intermediate trees needed to reach it.

Member Function Documentation

◆ findValueTree()

juce::ValueTree cello::Path::findValueTree ( juce::ValueTree & origin,
Path::SearchType searchType,
juce::UndoManager * undo = nullptr )

Navigate the path from origin to a tree that is expected at the end of the current path specification.

Parameters
originInitial/"current" value tree from which to begin search
searchType
Returns
juce::ValueTree; if search type was query may be an invalid tree

◆ getSearchResult()

SearchResult cello::Path::getSearchResult ( ) const
inline

Find out whether performing a search succeeded, and if so, needed to create a new tree.

Returns
SearchResult

The documentation for this class was generated from the following files: