Module khepri_path

Khepri path API.

Description

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 "/path/to/node" and is the equivalent of the [path, to, node] native path.

%% Unix path, equivalent of the first native path example.
UnixPath = "/stock/wood/oak".

Data Types

component()

component() = node_id() | 47 | 46 | 94

Component name in a path to a node.

node_id()

node_id() = atom() | binary()

A node name.

path()

path() = [component()]

Path to a node.

pattern()

pattern() = [pattern_component()]

Path pattern which may match zero, one or more nodes.

pattern_component()

pattern_component() = component() | khepri_condition:condition()

Function Index

from_string/1
component_from_string/1
maybe_from_string/1
to_string/1
component_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

Function Details

from_string/1

from_string(PathString::string()) -> pattern()

component_from_string/1

component_from_string(Component::string()) -> pattern_component()

maybe_from_string/1

maybe_from_string(Path::pattern() | string()) -> pattern()

to_string/1

to_string(Path::path()) -> string()

component_to_string/1

component_to_string(Component::component()) -> string()

combine_with_conditions/2

combine_with_conditions(Path::pattern(), Conditions::[khepri_condition:condition()]) -> pattern()

targets_specific_node/1

targets_specific_node(PathPattern::pattern()) -> {true, path()} | false

is_valid/1

is_valid(PathPattern) -> IsValid

ensure_is_valid/1

ensure_is_valid(PathPattern) -> ok | no_return()

abspath/2

abspath(AbsolutePath::pattern(), BasePath::pattern()) -> pattern()

realpath/1

realpath(Path::pattern()) -> pattern()

pattern_includes_root_node/1

pattern_includes_root_node(X1) -> any()


Generated by EDoc