Khepri path API.
A path is the type used by Khepri to reference nodes in the tree structure. A path describes how to reach a node from the root node.
A path, or native path, is a list of components. Components can be Erlang atoms and binaries. Example:
%% Native path.
Path = [stock, wood, <<"oak">>].
A path may contain conditions to tune how a node is matched or to match
multiple nodes at once. This is called a path pattern. A path
pattern may contain conditions in addition to regular components (Erlang
atoms and binaries). See khepri_condition
to learn more about
conditions. Example:
%% Path pattern with a condition on `wood'.
PathPattern = [stock,
#if_all{conditions = [wood,
#if_node_exists{exists = true}]},
oak].
To be user-friendly, Unix-like string-based paths are accepted by most functions. These Unix paths have the following syntax:
/
.:
character: :wood
.oak
./
, otherwise it is considered a
relative path.
and ..
represent ?THIS_NODE
and ?PARENT_NODE
respectivelyabc*def
is the same as #if_name_matches{regex = "^abc.*def$"}
*
is the same as ?STAR
or #if_name_matches{regex = any}
**
is the same as ?STAR_STAR
or if_path_matches{regex = any}
%% Unix path, equivalent of the first native path example.
UnixPath = "/:stock/:wood/oak".
component() = node_id() | 47 | 46 | 94
Component name in a path to a node.
node_id() = atom() | binary()
A node name.
path() = [component()]
Path to a node.
pattern() = [pattern_component()]
Path pattern which may match zero, one or more nodes.
pattern_component() = component() | khepri_condition:condition()
from_string/1 | |
maybe_from_string/1 | |
to_string/1 | |
combine_with_conditions/2 | |
targets_specific_node/1 | |
is_valid/1 | |
ensure_is_valid/1 | |
abspath/2 | |
realpath/1 | |
pattern_includes_root_node/1 |
to_string(Path::path()) -> string()
combine_with_conditions(Path::pattern(), Conditions::[khepri_condition:condition()]) -> pattern()
is_valid(PathPattern) -> IsValid
PathPattern = pattern()
IsValid = true | {false, pattern_component()}
ensure_is_valid(PathPattern) -> ok | no_return()
PathPattern = pattern()
pattern_includes_root_node(Path) -> any()
Generated by EDoc